protocol.h 24 KB

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