protocol.h 24 KB

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