blob: 2fb3a63ae9ab719be34b2506aca44ea05432bed9 [file] [log] [blame]
Mike Marshallf7ab0932015-07-17 10:38:11 -04001#include <linux/spinlock_types.h>
2#include <linux/types.h>
3#include <linux/slab.h>
4
5extern struct client_debug_mask *cdm_array;
6extern char *debug_help_string;
7extern int help_string_initialized;
8extern struct dentry *debug_dir;
9extern struct dentry *help_file_dentry;
10extern struct dentry *client_debug_dentry;
11extern const struct file_operations debug_help_fops;
12extern int client_all_index;
13extern int client_verbose_index;
14extern int cdm_element_count;
15#define DEBUG_HELP_STRING_SIZE 4096
16#define HELP_STRING_UNINITIALIZED \
17 "Client Debug Keywords are unknown until the first time\n" \
18 "the client is started after boot.\n"
19#define ORANGEFS_KMOD_DEBUG_HELP_FILE "debug-help"
20#define ORANGEFS_KMOD_DEBUG_FILE "kernel-debug"
21#define ORANGEFS_CLIENT_DEBUG_FILE "client-debug"
22#define PVFS2_VERBOSE "verbose"
23#define PVFS2_ALL "all"
24
25/* pvfs2-config.h ***********************************************************/
26#define PVFS2_VERSION_MAJOR 2
27#define PVFS2_VERSION_MINOR 9
28#define PVFS2_VERSION_SUB 0
29
30/* khandle stuff ***********************************************************/
31
32/*
33 * The 2.9 core will put 64 bit handles in here like this:
34 * 1234 0000 0000 5678
35 * The 3.0 and beyond cores will put 128 bit handles in here like this:
36 * 1234 5678 90AB CDEF
37 * The kernel module will always use the first four bytes and
38 * the last four bytes as an inum.
39 */
40struct pvfs2_khandle {
41 unsigned char u[16];
42} __aligned(8);
43
44/*
45 * kernel version of an object ref.
46 */
47struct pvfs2_object_kref {
48 struct pvfs2_khandle khandle;
49 __s32 fs_id;
50 __s32 __pad1;
51};
52
53/*
54 * compare 2 khandles assumes little endian thus from large address to
55 * small address
56 */
57static inline int PVFS_khandle_cmp(const struct pvfs2_khandle *kh1,
58 const struct pvfs2_khandle *kh2)
59{
60 int i;
61
62 for (i = 15; i >= 0; i--) {
63 if (kh1->u[i] > kh2->u[i])
64 return 1;
65 if (kh1->u[i] < kh2->u[i])
66 return -1;
67 }
68
69 return 0;
70}
71
72/* copy a khandle to a field of arbitrary size */
73static inline void PVFS_khandle_to(const struct pvfs2_khandle *kh,
74 void *p, int size)
75{
76 int i;
77 unsigned char *c = p;
78
79 memset(p, 0, size);
80
81 for (i = 0; i < 16 && i < size; i++)
82 c[i] = kh->u[i];
83}
84
85/* copy a khandle from a field of arbitrary size */
86static inline void PVFS_khandle_from(struct pvfs2_khandle *kh,
87 void *p, int size)
88{
89 int i;
90 unsigned char *c = p;
91
92 memset(kh, 0, 16);
93
94 for (i = 0; i < 16 && i < size; i++)
95 kh->u[i] = c[i];
96}
97
98/* pvfs2-types.h ************************************************************/
99typedef __u32 PVFS_uid;
100typedef __u32 PVFS_gid;
101typedef __s32 PVFS_fs_id;
102typedef __u32 PVFS_permissions;
103typedef __u64 PVFS_time;
104typedef __s64 PVFS_size;
105typedef __u64 PVFS_flags;
106typedef __u64 PVFS_ds_position;
107typedef __s32 PVFS_error;
108typedef __s64 PVFS_offset;
109
110#define PVFS2_SUPER_MAGIC 0x20030528
111#define PVFS_ERROR_BIT (1 << 30)
112#define PVFS_NON_ERRNO_ERROR_BIT (1 << 29)
113#define IS_PVFS_ERROR(__error) ((__error)&(PVFS_ERROR_BIT))
114#define IS_PVFS_NON_ERRNO_ERROR(__error) \
115(((__error)&(PVFS_NON_ERRNO_ERROR_BIT)) && IS_PVFS_ERROR(__error))
116#define PVFS_ERROR_TO_ERRNO(__error) PVFS_get_errno_mapping(__error)
117
118/* 7 bits are used for the errno mapped error codes */
119#define PVFS_ERROR_CODE(__error) \
120((__error) & (__s32)(0x7f|PVFS_ERROR_BIT))
121#define PVFS_ERROR_CLASS(__error) \
122((__error) & ~((__s32)(0x7f|PVFS_ERROR_BIT|PVFS_NON_ERRNO_ERROR_BIT)))
123#define PVFS_NON_ERRNO_ERROR_CODE(__error) \
124((__error) & (__s32)(127|PVFS_ERROR_BIT|PVFS_NON_ERRNO_ERROR_BIT))
125
126/* PVFS2 error codes, compliments of asm/errno.h */
127#define PVFS_EPERM E(1) /* Operation not permitted */
128#define PVFS_ENOENT E(2) /* No such file or directory */
129#define PVFS_EINTR E(3) /* Interrupted system call */
130#define PVFS_EIO E(4) /* I/O error */
131#define PVFS_ENXIO E(5) /* No such device or address */
132#define PVFS_EBADF E(6) /* Bad file number */
133#define PVFS_EAGAIN E(7) /* Try again */
134#define PVFS_ENOMEM E(8) /* Out of memory */
135#define PVFS_EFAULT E(9) /* Bad address */
136#define PVFS_EBUSY E(10) /* Device or resource busy */
137#define PVFS_EEXIST E(11) /* File exists */
138#define PVFS_ENODEV E(12) /* No such device */
139#define PVFS_ENOTDIR E(13) /* Not a directory */
140#define PVFS_EISDIR E(14) /* Is a directory */
141#define PVFS_EINVAL E(15) /* Invalid argument */
142#define PVFS_EMFILE E(16) /* Too many open files */
143#define PVFS_EFBIG E(17) /* File too large */
144#define PVFS_ENOSPC E(18) /* No space left on device */
145#define PVFS_EROFS E(19) /* Read-only file system */
146#define PVFS_EMLINK E(20) /* Too many links */
147#define PVFS_EPIPE E(21) /* Broken pipe */
148#define PVFS_EDEADLK E(22) /* Resource deadlock would occur */
149#define PVFS_ENAMETOOLONG E(23) /* File name too long */
150#define PVFS_ENOLCK E(24) /* No record locks available */
151#define PVFS_ENOSYS E(25) /* Function not implemented */
152#define PVFS_ENOTEMPTY E(26) /* Directory not empty */
153 /*
154#define PVFS_ELOOP E(27) * Too many symbolic links encountered
155 */
156#define PVFS_EWOULDBLOCK E(28) /* Operation would block */
157#define PVFS_ENOMSG E(29) /* No message of desired type */
158#define PVFS_EUNATCH E(30) /* Protocol driver not attached */
159#define PVFS_EBADR E(31) /* Invalid request descriptor */
160#define PVFS_EDEADLOCK E(32)
161#define PVFS_ENODATA E(33) /* No data available */
162#define PVFS_ETIME E(34) /* Timer expired */
163#define PVFS_ENONET E(35) /* Machine is not on the network */
164#define PVFS_EREMOTE E(36) /* Object is remote */
165#define PVFS_ECOMM E(37) /* Communication error on send */
166#define PVFS_EPROTO E(38) /* Protocol error */
167#define PVFS_EBADMSG E(39) /* Not a data message */
168 /*
169#define PVFS_EOVERFLOW E(40) * Value too large for defined data
170 * type
171 */
172 /*
173#define PVFS_ERESTART E(41) * Interrupted system call should be
174 * restarted
175 */
176#define PVFS_EMSGSIZE E(42) /* Message too long */
177#define PVFS_EPROTOTYPE E(43) /* Protocol wrong type for socket */
178#define PVFS_ENOPROTOOPT E(44) /* Protocol not available */
179#define PVFS_EPROTONOSUPPORT E(45) /* Protocol not supported */
180 /*
181#define PVFS_EOPNOTSUPP E(46) * Operation not supported on transport
182 * endpoint
183 */
184#define PVFS_EADDRINUSE E(47) /* Address already in use */
185#define PVFS_EADDRNOTAVAIL E(48) /* Cannot assign requested address */
186#define PVFS_ENETDOWN E(49) /* Network is down */
187#define PVFS_ENETUNREACH E(50) /* Network is unreachable */
188 /*
189#define PVFS_ENETRESET E(51) * Network dropped connection because
190 * of reset
191 */
192#define PVFS_ENOBUFS E(52) /* No buffer space available */
193#define PVFS_ETIMEDOUT E(53) /* Connection timed out */
194#define PVFS_ECONNREFUSED E(54) /* Connection refused */
195#define PVFS_EHOSTDOWN E(55) /* Host is down */
196#define PVFS_EHOSTUNREACH E(56) /* No route to host */
197#define PVFS_EALREADY E(57) /* Operation already in progress */
198#define PVFS_EACCES E(58) /* Access not allowed */
199#define PVFS_ECONNRESET E(59) /* Connection reset by peer */
200#define PVFS_ERANGE E(60) /* Math out of range or buf too small */
201
202/***************** non-errno/pvfs2 specific error codes *****************/
203#define PVFS_ECANCEL (1|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT))
204#define PVFS_EDEVINIT (2|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT))
205#define PVFS_EDETAIL (3|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT))
206#define PVFS_EHOSTNTFD (4|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT))
207#define PVFS_EADDRNTFD (5|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT))
208#define PVFS_ENORECVR (6|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT))
209#define PVFS_ETRYAGAIN (7|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT))
210#define PVFS_ENOTPVFS (8|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT))
211#define PVFS_ESECURITY (9|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT))
212
213/*
214 * NOTE: PLEASE DO NOT ARBITRARILY ADD NEW ERRNO ERROR CODES!
215 *
216 * IF YOU CHOOSE TO ADD A NEW ERROR CODE (DESPITE OUR PLEA), YOU ALSO
217 * NEED TO INCREMENT PVFS_ERRNO MAX (BELOW) AND ADD A MAPPING TO A
218 * UNIX ERRNO VALUE IN THE MACROS BELOW (USED IN
219 * src/common/misc/errno-mapping.c and the kernel module)
220 */
221#define PVFS_ERRNO_MAX 61
222
223#define PVFS_ERROR_BMI (1 << 7) /* BMI-specific error */
224#define PVFS_ERROR_TROVE (2 << 7) /* Trove-specific error */
225#define PVFS_ERROR_FLOW (3 << 7)
226#define PVFS_ERROR_SM (4 << 7) /* state machine specific error */
227#define PVFS_ERROR_SCHED (5 << 7)
228#define PVFS_ERROR_CLIENT (6 << 7)
229#define PVFS_ERROR_DEV (7 << 7) /* device file interaction */
230
231#define PVFS_ERROR_CLASS_BITS \
232 (PVFS_ERROR_BMI | \
233 PVFS_ERROR_TROVE | \
234 PVFS_ERROR_FLOW | \
235 PVFS_ERROR_SM | \
236 PVFS_ERROR_SCHED | \
237 PVFS_ERROR_CLIENT | \
238 PVFS_ERROR_DEV)
239
240#define DECLARE_ERRNO_MAPPING() \
241__s32 PINT_errno_mapping[PVFS_ERRNO_MAX + 1] = { \
242 0, /* leave this one empty */ \
243 EPERM, /* 1 */ \
244 ENOENT, \
245 EINTR, \
246 EIO, \
247 ENXIO, \
248 EBADF, \
249 EAGAIN, \
250 ENOMEM, \
251 EFAULT, \
252 EBUSY, /* 10 */ \
253 EEXIST, \
254 ENODEV, \
255 ENOTDIR, \
256 EISDIR, \
257 EINVAL, \
258 EMFILE, \
259 EFBIG, \
260 ENOSPC, \
261 EROFS, \
262 EMLINK, /* 20 */ \
263 EPIPE, \
264 EDEADLK, \
265 ENAMETOOLONG, \
266 ENOLCK, \
267 ENOSYS, \
268 ENOTEMPTY, \
269 ELOOP, \
270 EWOULDBLOCK, \
271 ENOMSG, \
272 EUNATCH, /* 30 */ \
273 EBADR, \
274 EDEADLOCK, \
275 ENODATA, \
276 ETIME, \
277 ENONET, \
278 EREMOTE, \
279 ECOMM, \
280 EPROTO, \
281 EBADMSG, \
282 EOVERFLOW, /* 40 */ \
283 ERESTART, \
284 EMSGSIZE, \
285 EPROTOTYPE, \
286 ENOPROTOOPT, \
287 EPROTONOSUPPORT, \
288 EOPNOTSUPP, \
289 EADDRINUSE, \
290 EADDRNOTAVAIL, \
291 ENETDOWN, \
292 ENETUNREACH, /* 50 */ \
293 ENETRESET, \
294 ENOBUFS, \
295 ETIMEDOUT, \
296 ECONNREFUSED, \
297 EHOSTDOWN, \
298 EHOSTUNREACH, \
299 EALREADY, \
300 EACCES, \
301 ECONNRESET, /* 59 */ \
302 ERANGE, \
303 0 /* PVFS_ERRNO_MAX */ \
304}; \
305const char *PINT_non_errno_strerror_mapping[] = { \
306 "Success", /* 0 */ \
307 "Operation cancelled (possibly due to timeout)", \
308 "Device initialization failed", \
309 "Detailed per-server errors are available", \
310 "Unknown host", \
311 "No address associated with name", \
312 "Unknown server error", \
313 "Host name lookup failure", \
314 "Path contains non-PVFS elements", \
315 "Security error", \
316}; \
317__s32 PINT_non_errno_mapping[] = { \
318 0, /* leave this one empty */ \
319 PVFS_ECANCEL, /* 1 */ \
320 PVFS_EDEVINIT, /* 2 */ \
321 PVFS_EDETAIL, /* 3 */ \
322 PVFS_EHOSTNTFD, /* 4 */ \
323 PVFS_EADDRNTFD, /* 5 */ \
324 PVFS_ENORECVR, /* 6 */ \
325 PVFS_ETRYAGAIN, /* 7 */ \
326 PVFS_ENOTPVFS, /* 8 */ \
327 PVFS_ESECURITY, /* 9 */ \
328}
329
330/*
331 * NOTE: PVFS_get_errno_mapping will convert a PVFS_ERROR_CODE to an
332 * errno value. If the error code is a pvfs2 specific error code
333 * (i.e. a PVFS_NON_ERRNO_ERROR_CODE), PVFS_get_errno_mapping will
334 * return an index into the PINT_non_errno_strerror_mapping array which
335 * can be used for getting the pvfs2 specific strerror message given
336 * the error code. if the value is not a recognized error code, the
337 * passed in value will be returned unchanged.
338 */
339#define DECLARE_ERRNO_MAPPING_AND_FN() \
340extern __s32 PINT_errno_mapping[]; \
341extern __s32 PINT_non_errno_mapping[]; \
342extern const char *PINT_non_errno_strerror_mapping[]; \
343__s32 PVFS_get_errno_mapping(__s32 error) \
344{ \
345 __s32 ret = error, mask = 0; \
346 __s32 positive = ((error > -1) ? 1 : 0); \
347 if (IS_PVFS_NON_ERRNO_ERROR((positive ? error : -error))) { \
348 mask = (PVFS_NON_ERRNO_ERROR_BIT | \
349 PVFS_ERROR_BIT | \
350 PVFS_ERROR_CLASS_BITS); \
351 ret = PVFS_NON_ERRNO_ERROR_CODE(((positive ? \
352 error : \
353 abs(error))) & \
354 ~mask); \
355 } \
356 else if (IS_PVFS_ERROR((positive ? error : -error))) { \
357 mask = (PVFS_ERROR_BIT | \
358 PVFS_ERROR_CLASS_BITS); \
359 ret = PINT_errno_mapping[PVFS_ERROR_CODE(((positive ? \
360 error : \
361 abs(error))) & \
362 ~mask)]; \
363 } \
364 return ret; \
365} \
366__s32 PVFS_errno_to_error(int err) \
367{ \
368 __s32 e = 0; \
369 \
370 for (; e < PVFS_ERRNO_MAX; ++e) \
371 if (PINT_errno_mapping[e] == err) \
372 return e | PVFS_ERROR_BIT; \
373 \
374 return err; \
375} \
376DECLARE_ERRNO_MAPPING()
377
378/* permission bits */
379#define PVFS_O_EXECUTE (1 << 0)
380#define PVFS_O_WRITE (1 << 1)
381#define PVFS_O_READ (1 << 2)
382#define PVFS_G_EXECUTE (1 << 3)
383#define PVFS_G_WRITE (1 << 4)
384#define PVFS_G_READ (1 << 5)
385#define PVFS_U_EXECUTE (1 << 6)
386#define PVFS_U_WRITE (1 << 7)
387#define PVFS_U_READ (1 << 8)
388/* no PVFS_U_VTX (sticky bit) */
389#define PVFS_G_SGID (1 << 10)
390#define PVFS_U_SUID (1 << 11)
391
392/* definition taken from stdint.h */
393#define INT32_MAX (2147483647)
394#define PVFS_ITERATE_START (INT32_MAX - 1)
395#define PVFS_ITERATE_END (INT32_MAX - 2)
396#define PVFS_READDIR_START PVFS_ITERATE_START
397#define PVFS_READDIR_END PVFS_ITERATE_END
398#define PVFS_IMMUTABLE_FL FS_IMMUTABLE_FL
399#define PVFS_APPEND_FL FS_APPEND_FL
400#define PVFS_NOATIME_FL FS_NOATIME_FL
401#define PVFS_MIRROR_FL 0x01000000ULL
402#define PVFS_O_EXECUTE (1 << 0)
403#define PVFS_FS_ID_NULL ((__s32)0)
404#define PVFS_ATTR_SYS_UID (1 << 0)
405#define PVFS_ATTR_SYS_GID (1 << 1)
406#define PVFS_ATTR_SYS_PERM (1 << 2)
407#define PVFS_ATTR_SYS_ATIME (1 << 3)
408#define PVFS_ATTR_SYS_CTIME (1 << 4)
409#define PVFS_ATTR_SYS_MTIME (1 << 5)
410#define PVFS_ATTR_SYS_TYPE (1 << 6)
411#define PVFS_ATTR_SYS_ATIME_SET (1 << 7)
412#define PVFS_ATTR_SYS_MTIME_SET (1 << 8)
413#define PVFS_ATTR_SYS_SIZE (1 << 20)
414#define PVFS_ATTR_SYS_LNK_TARGET (1 << 24)
415#define PVFS_ATTR_SYS_DFILE_COUNT (1 << 25)
416#define PVFS_ATTR_SYS_DIRENT_COUNT (1 << 26)
417#define PVFS_ATTR_SYS_BLKSIZE (1 << 28)
418#define PVFS_ATTR_SYS_MIRROR_COPIES_COUNT (1 << 29)
419#define PVFS_ATTR_SYS_COMMON_ALL \
420 (PVFS_ATTR_SYS_UID | \
421 PVFS_ATTR_SYS_GID | \
422 PVFS_ATTR_SYS_PERM | \
423 PVFS_ATTR_SYS_ATIME | \
424 PVFS_ATTR_SYS_CTIME | \
425 PVFS_ATTR_SYS_MTIME | \
426 PVFS_ATTR_SYS_TYPE)
427
428#define PVFS_ATTR_SYS_ALL_SETABLE \
429(PVFS_ATTR_SYS_COMMON_ALL-PVFS_ATTR_SYS_TYPE)
430
431#define PVFS_ATTR_SYS_ALL_NOHINT \
432 (PVFS_ATTR_SYS_COMMON_ALL | \
433 PVFS_ATTR_SYS_SIZE | \
434 PVFS_ATTR_SYS_LNK_TARGET | \
435 PVFS_ATTR_SYS_DFILE_COUNT | \
436 PVFS_ATTR_SYS_MIRROR_COPIES_COUNT | \
437 PVFS_ATTR_SYS_DIRENT_COUNT | \
438 PVFS_ATTR_SYS_BLKSIZE)
439#define PVFS_XATTR_REPLACE 0x2
440#define PVFS_XATTR_CREATE 0x1
441#define PVFS_MAX_SERVER_ADDR_LEN 256
442#define PVFS_NAME_MAX 256
443/*
444 * max extended attribute name len as imposed by the VFS and exploited for the
445 * upcall request types.
446 * NOTE: Please retain them as multiples of 8 even if you wish to change them
447 * This is *NECESSARY* for supporting 32 bit user-space binaries on a 64-bit
448 * kernel. Due to implementation within DBPF, this really needs to be
449 * PVFS_NAME_MAX, which it was the same value as, but no reason to let it
450 * break if that changes in the future.
451 */
452#define PVFS_MAX_XATTR_NAMELEN PVFS_NAME_MAX /* Not the same as
453 * XATTR_NAME_MAX defined
454 * by <linux/xattr.h>
455 */
456#define PVFS_MAX_XATTR_VALUELEN 8192 /* Not the same as XATTR_SIZE_MAX
457 * defined by <linux/xattr.h>
458 */
459#define PVFS_MAX_XATTR_LISTLEN 16 /* Not the same as XATTR_LIST_MAX
460 * defined by <linux/xattr.h>
461 */
462/*
463 * PVFS I/O operation types, used in both system and server interfaces.
464 */
465enum PVFS_io_type {
466 PVFS_IO_READ = 1,
467 PVFS_IO_WRITE = 2
468};
469
470/*
471 * If this enum is modified the server parameters related to the precreate pool
472 * batch and low threshold sizes may need to be modified to reflect this
473 * change.
474 */
475enum pvfs2_ds_type {
476 PVFS_TYPE_NONE = 0,
477 PVFS_TYPE_METAFILE = (1 << 0),
478 PVFS_TYPE_DATAFILE = (1 << 1),
479 PVFS_TYPE_DIRECTORY = (1 << 2),
480 PVFS_TYPE_SYMLINK = (1 << 3),
481 PVFS_TYPE_DIRDATA = (1 << 4),
482 PVFS_TYPE_INTERNAL = (1 << 5) /* for the server's private use */
483};
484
485/*
486 * PVFS_certificate simply stores a buffer with the buffer size.
487 * The buffer can be converted to an OpenSSL X509 struct for use.
488 */
489struct PVFS_certificate {
490 __u32 buf_size;
491 unsigned char *buf;
492};
493
494/*
495 * A credential identifies a user and is signed by the client/user
496 * private key.
497 */
498struct PVFS_credential {
499 __u32 userid; /* user id */
500 __u32 num_groups; /* length of group_array */
501 __u32 *group_array; /* groups for which the user is a member */
502 char *issuer; /* alias of the issuing server */
503 __u64 timeout; /* seconds after epoch to time out */
504 __u32 sig_size; /* length of the signature in bytes */
505 unsigned char *signature; /* digital signature */
506 struct PVFS_certificate certificate; /* user certificate buffer */
507};
508#define extra_size_PVFS_credential (PVFS_REQ_LIMIT_GROUPS * \
509 sizeof(__u32) + \
510 PVFS_REQ_LIMIT_ISSUER + \
511 PVFS_REQ_LIMIT_SIGNATURE + \
512 extra_size_PVFS_certificate)
513
514/* This structure is used by the VFS-client interaction alone */
515struct PVFS_keyval_pair {
516 char key[PVFS_MAX_XATTR_NAMELEN];
517 __s32 key_sz; /* __s32 for portable, fixed-size structures */
518 __s32 val_sz;
519 char val[PVFS_MAX_XATTR_VALUELEN];
520};
521
522/* pvfs2-sysint.h ***********************************************************/
523/* Describes attributes for a file, directory, or symlink. */
524struct PVFS_sys_attr_s {
525 __u32 owner;
526 __u32 group;
527 __u32 perms;
528 __u64 atime;
529 __u64 mtime;
530 __u64 ctime;
531 __s64 size;
532
533 /* NOTE: caller must free if valid */
534 char *link_target;
535
536 /* Changed to __s32 so that size of structure does not change */
537 __s32 dfile_count;
538
539 /* Changed to __s32 so that size of structure does not change */
540 __s32 distr_dir_servers_initial;
541
542 /* Changed to __s32 so that size of structure does not change */
543 __s32 distr_dir_servers_max;
544
545 /* Changed to __s32 so that size of structure does not change */
546 __s32 distr_dir_split_size;
547
548 __u32 mirror_copies_count;
549
550 /* NOTE: caller must free if valid */
551 char *dist_name;
552
553 /* NOTE: caller must free if valid */
554 char *dist_params;
555
556 __s64 dirent_count;
557 enum pvfs2_ds_type objtype;
558 __u64 flags;
559 __u32 mask;
560 __s64 blksize;
561};
562
563#define PVFS2_LOOKUP_LINK_NO_FOLLOW 0
564#define PVFS2_LOOKUP_LINK_FOLLOW 1
565
566/* pint-dev.h ***************************************************************/
567
568/* parameter structure used in PVFS_DEV_DEBUG ioctl command */
569struct dev_mask_info_s {
570 enum {
571 KERNEL_MASK,
572 CLIENT_MASK,
573 } mask_type;
574 __u64 mask_value;
575};
576
577struct dev_mask2_info_s {
578 __u64 mask1_value;
579 __u64 mask2_value;
580};
581
582/* pvfs2-util.h *************************************************************/
583#define PVFS_util_min(x1, x2) (((x1) > (x2)) ? (x2) : (x1))
584__s32 PVFS_util_translate_mode(int mode);
585
586/* pvfs2-debug.h ************************************************************/
587#include "pvfs2-debug.h"
588
589/* pvfs2-internal.h *********************************************************/
590#define llu(x) (unsigned long long)(x)
591#define lld(x) (long long)(x)
592
593/* pint-dev-shared.h ********************************************************/
594#define PVFS_DEV_MAGIC 'k'
595
596#define PVFS2_READDIR_DEFAULT_DESC_COUNT 5
597
598#define DEV_GET_MAGIC 0x1
599#define DEV_GET_MAX_UPSIZE 0x2
600#define DEV_GET_MAX_DOWNSIZE 0x3
601#define DEV_MAP 0x4
602#define DEV_REMOUNT_ALL 0x5
603#define DEV_DEBUG 0x6
604#define DEV_UPSTREAM 0x7
605#define DEV_CLIENT_MASK 0x8
606#define DEV_CLIENT_STRING 0x9
607#define DEV_MAX_NR 0xa
608
609/* supported ioctls, codes are with respect to user-space */
610enum {
611 PVFS_DEV_GET_MAGIC = _IOW(PVFS_DEV_MAGIC, DEV_GET_MAGIC, __s32),
612 PVFS_DEV_GET_MAX_UPSIZE =
613 _IOW(PVFS_DEV_MAGIC, DEV_GET_MAX_UPSIZE, __s32),
614 PVFS_DEV_GET_MAX_DOWNSIZE =
615 _IOW(PVFS_DEV_MAGIC, DEV_GET_MAX_DOWNSIZE, __s32),
616 PVFS_DEV_MAP = _IO(PVFS_DEV_MAGIC, DEV_MAP),
617 PVFS_DEV_REMOUNT_ALL = _IO(PVFS_DEV_MAGIC, DEV_REMOUNT_ALL),
618 PVFS_DEV_DEBUG = _IOR(PVFS_DEV_MAGIC, DEV_DEBUG, __s32),
619 PVFS_DEV_UPSTREAM = _IOW(PVFS_DEV_MAGIC, DEV_UPSTREAM, int),
620 PVFS_DEV_CLIENT_MASK = _IOW(PVFS_DEV_MAGIC,
621 DEV_CLIENT_MASK,
622 struct dev_mask2_info_s),
623 PVFS_DEV_CLIENT_STRING = _IOW(PVFS_DEV_MAGIC,
624 DEV_CLIENT_STRING,
625 char *),
626 PVFS_DEV_MAXNR = DEV_MAX_NR,
627};
628
629/*
630 * version number for use in communicating between kernel space and user
631 * space
632 */
633/*
634#define PVFS_KERNEL_PROTO_VERSION \
635 ((PVFS2_VERSION_MAJOR * 10000) + \
636 (PVFS2_VERSION_MINOR * 100) + \
637 PVFS2_VERSION_SUB)
638*/
639#define PVFS_KERNEL_PROTO_VERSION 0
640
641/*
642 * describes memory regions to map in the PVFS_DEV_MAP ioctl.
643 * NOTE: See devpvfs2-req.c for 32 bit compat structure.
644 * Since this structure has a variable-sized layout that is different
645 * on 32 and 64 bit platforms, we need to normalize to a 64 bit layout
646 * on such systems before servicing ioctl calls from user-space binaries
647 * that may be 32 bit!
648 */
649struct PVFS_dev_map_desc {
650 void *ptr;
651 __s32 total_size;
652 __s32 size;
653 __s32 count;
654};
655
656/* gossip.h *****************************************************************/
657
658#ifdef GOSSIP_DISABLE_DEBUG
659#define gossip_debug(mask, format, f...) do {} while (0)
660#else
661extern __u64 gossip_debug_mask;
662extern struct client_debug_mask client_debug_mask;
663
664/* try to avoid function call overhead by checking masks in macro */
665#define gossip_debug(mask, format, f...) \
666do { \
667 if (gossip_debug_mask & mask) \
668 printk(format, ##f); \
669} while (0)
670#endif /* GOSSIP_DISABLE_DEBUG */
671
672/* do file and line number printouts w/ the GNU preprocessor */
673#define gossip_ldebug(mask, format, f...) \
674 gossip_debug(mask, "%s: " format, __func__, ##f)
675
676#define gossip_err printk
677#define gossip_lerr(format, f...) \
678 gossip_err("%s line %d: " format, \
679 __FILE__, \
680 __LINE__, \
681 ##f)