nfs_xdr.h 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180
  1. #ifndef _LINUX_NFS_XDR_H
  2. #define _LINUX_NFS_XDR_H
  3. #include <linux/nfsacl.h>
  4. #include <linux/nfs3.h>
  5. #include <linux/sunrpc/gss_api.h>
  6. /*
  7. * To change the maximum rsize and wsize supported by the NFS client, adjust
  8. * NFS_MAX_FILE_IO_SIZE. 64KB is a typical maximum, but some servers can
  9. * support a megabyte or more. The default is left at 4096 bytes, which is
  10. * reasonable for NFS over UDP.
  11. */
  12. #define NFS_MAX_FILE_IO_SIZE (1048576U)
  13. #define NFS_DEF_FILE_IO_SIZE (4096U)
  14. #define NFS_MIN_FILE_IO_SIZE (1024U)
  15. /* Forward declaration for NFS v3 */
  16. struct nfs4_secinfo_flavors;
  17. struct nfs_fsid {
  18. uint64_t major;
  19. uint64_t minor;
  20. };
  21. /*
  22. * Helper for checking equality between 2 fsids.
  23. */
  24. static inline int nfs_fsid_equal(const struct nfs_fsid *a, const struct nfs_fsid *b)
  25. {
  26. return a->major == b->major && a->minor == b->minor;
  27. }
  28. struct nfs_fattr {
  29. unsigned int valid; /* which fields are valid */
  30. umode_t mode;
  31. __u32 nlink;
  32. __u32 uid;
  33. __u32 gid;
  34. dev_t rdev;
  35. __u64 size;
  36. union {
  37. struct {
  38. __u32 blocksize;
  39. __u32 blocks;
  40. } nfs2;
  41. struct {
  42. __u64 used;
  43. } nfs3;
  44. } du;
  45. struct nfs_fsid fsid;
  46. __u64 fileid;
  47. struct timespec atime;
  48. struct timespec mtime;
  49. struct timespec ctime;
  50. __u64 change_attr; /* NFSv4 change attribute */
  51. __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
  52. __u64 pre_size; /* pre_op_attr.size */
  53. struct timespec pre_mtime; /* pre_op_attr.mtime */
  54. struct timespec pre_ctime; /* pre_op_attr.ctime */
  55. unsigned long time_start;
  56. unsigned long gencount;
  57. };
  58. #define NFS_ATTR_FATTR_TYPE (1U << 0)
  59. #define NFS_ATTR_FATTR_MODE (1U << 1)
  60. #define NFS_ATTR_FATTR_NLINK (1U << 2)
  61. #define NFS_ATTR_FATTR_OWNER (1U << 3)
  62. #define NFS_ATTR_FATTR_GROUP (1U << 4)
  63. #define NFS_ATTR_FATTR_RDEV (1U << 5)
  64. #define NFS_ATTR_FATTR_SIZE (1U << 6)
  65. #define NFS_ATTR_FATTR_PRESIZE (1U << 7)
  66. #define NFS_ATTR_FATTR_BLOCKS_USED (1U << 8)
  67. #define NFS_ATTR_FATTR_SPACE_USED (1U << 9)
  68. #define NFS_ATTR_FATTR_FSID (1U << 10)
  69. #define NFS_ATTR_FATTR_FILEID (1U << 11)
  70. #define NFS_ATTR_FATTR_ATIME (1U << 12)
  71. #define NFS_ATTR_FATTR_MTIME (1U << 13)
  72. #define NFS_ATTR_FATTR_CTIME (1U << 14)
  73. #define NFS_ATTR_FATTR_PREMTIME (1U << 15)
  74. #define NFS_ATTR_FATTR_PRECTIME (1U << 16)
  75. #define NFS_ATTR_FATTR_CHANGE (1U << 17)
  76. #define NFS_ATTR_FATTR_PRECHANGE (1U << 18)
  77. #define NFS_ATTR_FATTR_V4_REFERRAL (1U << 19) /* NFSv4 referral */
  78. #define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \
  79. | NFS_ATTR_FATTR_MODE \
  80. | NFS_ATTR_FATTR_NLINK \
  81. | NFS_ATTR_FATTR_OWNER \
  82. | NFS_ATTR_FATTR_GROUP \
  83. | NFS_ATTR_FATTR_RDEV \
  84. | NFS_ATTR_FATTR_SIZE \
  85. | NFS_ATTR_FATTR_FSID \
  86. | NFS_ATTR_FATTR_FILEID \
  87. | NFS_ATTR_FATTR_ATIME \
  88. | NFS_ATTR_FATTR_MTIME \
  89. | NFS_ATTR_FATTR_CTIME)
  90. #define NFS_ATTR_FATTR_V2 (NFS_ATTR_FATTR \
  91. | NFS_ATTR_FATTR_BLOCKS_USED)
  92. #define NFS_ATTR_FATTR_V3 (NFS_ATTR_FATTR \
  93. | NFS_ATTR_FATTR_SPACE_USED)
  94. #define NFS_ATTR_FATTR_V4 (NFS_ATTR_FATTR \
  95. | NFS_ATTR_FATTR_SPACE_USED \
  96. | NFS_ATTR_FATTR_CHANGE)
  97. /*
  98. * Info on the file system
  99. */
  100. struct nfs_fsinfo {
  101. struct nfs_fattr *fattr; /* Post-op attributes */
  102. __u32 rtmax; /* max. read transfer size */
  103. __u32 rtpref; /* pref. read transfer size */
  104. __u32 rtmult; /* reads should be multiple of this */
  105. __u32 wtmax; /* max. write transfer size */
  106. __u32 wtpref; /* pref. write transfer size */
  107. __u32 wtmult; /* writes should be multiple of this */
  108. __u32 dtpref; /* pref. readdir transfer size */
  109. __u64 maxfilesize;
  110. struct timespec time_delta; /* server time granularity */
  111. __u32 lease_time; /* in seconds */
  112. __u32 layouttype; /* supported pnfs layout driver */
  113. };
  114. struct nfs_fsstat {
  115. struct nfs_fattr *fattr; /* Post-op attributes */
  116. __u64 tbytes; /* total size in bytes */
  117. __u64 fbytes; /* # of free bytes */
  118. __u64 abytes; /* # of bytes available to user */
  119. __u64 tfiles; /* # of files */
  120. __u64 ffiles; /* # of free files */
  121. __u64 afiles; /* # of files available to user */
  122. };
  123. struct nfs2_fsstat {
  124. __u32 tsize; /* Server transfer size */
  125. __u32 bsize; /* Filesystem block size */
  126. __u32 blocks; /* No. of "bsize" blocks on filesystem */
  127. __u32 bfree; /* No. of free "bsize" blocks */
  128. __u32 bavail; /* No. of available "bsize" blocks */
  129. };
  130. struct nfs_pathconf {
  131. struct nfs_fattr *fattr; /* Post-op attributes */
  132. __u32 max_link; /* max # of hard links */
  133. __u32 max_namelen; /* max name length */
  134. };
  135. struct nfs4_change_info {
  136. u32 atomic;
  137. u64 before;
  138. u64 after;
  139. };
  140. struct nfs_seqid;
  141. /* nfs41 sessions channel attributes */
  142. struct nfs4_channel_attrs {
  143. u32 headerpadsz;
  144. u32 max_rqst_sz;
  145. u32 max_resp_sz;
  146. u32 max_resp_sz_cached;
  147. u32 max_ops;
  148. u32 max_reqs;
  149. };
  150. /* nfs41 sessions slot seqid */
  151. struct nfs4_slot {
  152. u32 seq_nr;
  153. };
  154. struct nfs4_sequence_args {
  155. struct nfs4_session *sa_session;
  156. u8 sa_slotid;
  157. u8 sa_cache_this;
  158. };
  159. struct nfs4_sequence_res {
  160. struct nfs4_session *sr_session;
  161. struct nfs4_slot *sr_slot; /* slot used to send request */
  162. int sr_status; /* sequence operation status */
  163. unsigned long sr_renewal_time;
  164. u32 sr_status_flags;
  165. };
  166. struct nfs4_get_lease_time_args {
  167. struct nfs4_sequence_args la_seq_args;
  168. };
  169. struct nfs4_get_lease_time_res {
  170. struct nfs_fsinfo *lr_fsinfo;
  171. struct nfs4_sequence_res lr_seq_res;
  172. };
  173. #define PNFS_LAYOUT_MAXSIZE 4096
  174. struct nfs4_layoutdriver_data {
  175. __u32 len;
  176. void *buf;
  177. };
  178. struct pnfs_layout_range {
  179. u32 iomode;
  180. u64 offset;
  181. u64 length;
  182. };
  183. struct nfs4_layoutget_args {
  184. __u32 type;
  185. struct pnfs_layout_range range;
  186. __u64 minlength;
  187. __u32 maxcount;
  188. struct inode *inode;
  189. struct nfs_open_context *ctx;
  190. struct nfs4_sequence_args seq_args;
  191. nfs4_stateid stateid;
  192. };
  193. struct nfs4_layoutget_res {
  194. __u32 return_on_close;
  195. struct pnfs_layout_range range;
  196. __u32 type;
  197. nfs4_stateid stateid;
  198. struct nfs4_layoutdriver_data layout;
  199. struct nfs4_sequence_res seq_res;
  200. };
  201. struct nfs4_layoutget {
  202. struct nfs4_layoutget_args args;
  203. struct nfs4_layoutget_res res;
  204. struct pnfs_layout_segment **lsegpp;
  205. };
  206. struct nfs4_getdeviceinfo_args {
  207. struct pnfs_device *pdev;
  208. struct nfs4_sequence_args seq_args;
  209. };
  210. struct nfs4_getdeviceinfo_res {
  211. struct pnfs_device *pdev;
  212. struct nfs4_sequence_res seq_res;
  213. };
  214. /*
  215. * Arguments to the open call.
  216. */
  217. struct nfs_openargs {
  218. const struct nfs_fh * fh;
  219. struct nfs_seqid * seqid;
  220. int open_flags;
  221. fmode_t fmode;
  222. __u64 clientid;
  223. __u64 id;
  224. union {
  225. struct {
  226. struct iattr * attrs; /* UNCHECKED, GUARDED */
  227. nfs4_verifier verifier; /* EXCLUSIVE */
  228. };
  229. nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
  230. fmode_t delegation_type; /* CLAIM_PREVIOUS */
  231. } u;
  232. const struct qstr * name;
  233. const struct nfs_server *server; /* Needed for ID mapping */
  234. const u32 * bitmask;
  235. __u32 claim;
  236. struct nfs4_sequence_args seq_args;
  237. };
  238. struct nfs_openres {
  239. nfs4_stateid stateid;
  240. struct nfs_fh fh;
  241. struct nfs4_change_info cinfo;
  242. __u32 rflags;
  243. struct nfs_fattr * f_attr;
  244. struct nfs_fattr * dir_attr;
  245. struct nfs_seqid * seqid;
  246. const struct nfs_server *server;
  247. fmode_t delegation_type;
  248. nfs4_stateid delegation;
  249. __u32 do_recall;
  250. __u64 maxsize;
  251. __u32 attrset[NFS4_BITMAP_SIZE];
  252. struct nfs4_sequence_res seq_res;
  253. };
  254. /*
  255. * Arguments to the open_confirm call.
  256. */
  257. struct nfs_open_confirmargs {
  258. const struct nfs_fh * fh;
  259. nfs4_stateid * stateid;
  260. struct nfs_seqid * seqid;
  261. };
  262. struct nfs_open_confirmres {
  263. nfs4_stateid stateid;
  264. struct nfs_seqid * seqid;
  265. };
  266. /*
  267. * Arguments to the close call.
  268. */
  269. struct nfs_closeargs {
  270. struct nfs_fh * fh;
  271. nfs4_stateid * stateid;
  272. struct nfs_seqid * seqid;
  273. fmode_t fmode;
  274. const u32 * bitmask;
  275. struct nfs4_sequence_args seq_args;
  276. };
  277. struct nfs_closeres {
  278. nfs4_stateid stateid;
  279. struct nfs_fattr * fattr;
  280. struct nfs_seqid * seqid;
  281. const struct nfs_server *server;
  282. struct nfs4_sequence_res seq_res;
  283. };
  284. /*
  285. * * Arguments to the lock,lockt, and locku call.
  286. * */
  287. struct nfs_lowner {
  288. __u64 clientid;
  289. __u64 id;
  290. dev_t s_dev;
  291. };
  292. struct nfs_lock_args {
  293. struct nfs_fh * fh;
  294. struct file_lock * fl;
  295. struct nfs_seqid * lock_seqid;
  296. nfs4_stateid * lock_stateid;
  297. struct nfs_seqid * open_seqid;
  298. nfs4_stateid * open_stateid;
  299. struct nfs_lowner lock_owner;
  300. unsigned char block : 1;
  301. unsigned char reclaim : 1;
  302. unsigned char new_lock_owner : 1;
  303. struct nfs4_sequence_args seq_args;
  304. };
  305. struct nfs_lock_res {
  306. nfs4_stateid stateid;
  307. struct nfs_seqid * lock_seqid;
  308. struct nfs_seqid * open_seqid;
  309. struct nfs4_sequence_res seq_res;
  310. };
  311. struct nfs_locku_args {
  312. struct nfs_fh * fh;
  313. struct file_lock * fl;
  314. struct nfs_seqid * seqid;
  315. nfs4_stateid * stateid;
  316. struct nfs4_sequence_args seq_args;
  317. };
  318. struct nfs_locku_res {
  319. nfs4_stateid stateid;
  320. struct nfs_seqid * seqid;
  321. struct nfs4_sequence_res seq_res;
  322. };
  323. struct nfs_lockt_args {
  324. struct nfs_fh * fh;
  325. struct file_lock * fl;
  326. struct nfs_lowner lock_owner;
  327. struct nfs4_sequence_args seq_args;
  328. };
  329. struct nfs_lockt_res {
  330. struct file_lock * denied; /* LOCK, LOCKT failed */
  331. struct nfs4_sequence_res seq_res;
  332. };
  333. struct nfs_release_lockowner_args {
  334. struct nfs_lowner lock_owner;
  335. };
  336. struct nfs4_delegreturnargs {
  337. const struct nfs_fh *fhandle;
  338. const nfs4_stateid *stateid;
  339. const u32 * bitmask;
  340. struct nfs4_sequence_args seq_args;
  341. };
  342. struct nfs4_delegreturnres {
  343. struct nfs_fattr * fattr;
  344. const struct nfs_server *server;
  345. struct nfs4_sequence_res seq_res;
  346. };
  347. /*
  348. * Arguments to the read call.
  349. */
  350. struct nfs_readargs {
  351. struct nfs_fh * fh;
  352. struct nfs_open_context *context;
  353. struct nfs_lock_context *lock_context;
  354. __u64 offset;
  355. __u32 count;
  356. unsigned int pgbase;
  357. struct page ** pages;
  358. struct nfs4_sequence_args seq_args;
  359. };
  360. struct nfs_readres {
  361. struct nfs_fattr * fattr;
  362. __u32 count;
  363. int eof;
  364. struct nfs4_sequence_res seq_res;
  365. };
  366. /*
  367. * Arguments to the write call.
  368. */
  369. struct nfs_writeargs {
  370. struct nfs_fh * fh;
  371. struct nfs_open_context *context;
  372. struct nfs_lock_context *lock_context;
  373. __u64 offset;
  374. __u32 count;
  375. enum nfs3_stable_how stable;
  376. unsigned int pgbase;
  377. struct page ** pages;
  378. const u32 * bitmask;
  379. struct nfs4_sequence_args seq_args;
  380. };
  381. struct nfs_writeverf {
  382. enum nfs3_stable_how committed;
  383. __be32 verifier[2];
  384. };
  385. struct nfs_writeres {
  386. struct nfs_fattr * fattr;
  387. struct nfs_writeverf * verf;
  388. __u32 count;
  389. const struct nfs_server *server;
  390. struct nfs4_sequence_res seq_res;
  391. };
  392. /*
  393. * Common arguments to the unlink call
  394. */
  395. struct nfs_removeargs {
  396. const struct nfs_fh *fh;
  397. struct qstr name;
  398. const u32 * bitmask;
  399. struct nfs4_sequence_args seq_args;
  400. };
  401. struct nfs_removeres {
  402. const struct nfs_server *server;
  403. struct nfs_fattr *dir_attr;
  404. struct nfs4_change_info cinfo;
  405. struct nfs4_sequence_res seq_res;
  406. };
  407. /*
  408. * Common arguments to the rename call
  409. */
  410. struct nfs_renameargs {
  411. const struct nfs_fh *old_dir;
  412. const struct nfs_fh *new_dir;
  413. const struct qstr *old_name;
  414. const struct qstr *new_name;
  415. const u32 *bitmask;
  416. struct nfs4_sequence_args seq_args;
  417. };
  418. struct nfs_renameres {
  419. const struct nfs_server *server;
  420. struct nfs4_change_info old_cinfo;
  421. struct nfs_fattr *old_fattr;
  422. struct nfs4_change_info new_cinfo;
  423. struct nfs_fattr *new_fattr;
  424. struct nfs4_sequence_res seq_res;
  425. };
  426. /*
  427. * Argument struct for decode_entry function
  428. */
  429. struct nfs_entry {
  430. __u64 ino;
  431. __u64 cookie,
  432. prev_cookie;
  433. const char * name;
  434. unsigned int len;
  435. int eof;
  436. struct nfs_fh * fh;
  437. struct nfs_fattr * fattr;
  438. unsigned char d_type;
  439. struct nfs_server * server;
  440. };
  441. /*
  442. * The following types are for NFSv2 only.
  443. */
  444. struct nfs_sattrargs {
  445. struct nfs_fh * fh;
  446. struct iattr * sattr;
  447. };
  448. struct nfs_diropargs {
  449. struct nfs_fh * fh;
  450. const char * name;
  451. unsigned int len;
  452. };
  453. struct nfs_createargs {
  454. struct nfs_fh * fh;
  455. const char * name;
  456. unsigned int len;
  457. struct iattr * sattr;
  458. };
  459. struct nfs_setattrargs {
  460. struct nfs_fh * fh;
  461. nfs4_stateid stateid;
  462. struct iattr * iap;
  463. const struct nfs_server * server; /* Needed for name mapping */
  464. const u32 * bitmask;
  465. struct nfs4_sequence_args seq_args;
  466. };
  467. struct nfs_setaclargs {
  468. struct nfs_fh * fh;
  469. size_t acl_len;
  470. unsigned int acl_pgbase;
  471. struct page ** acl_pages;
  472. struct nfs4_sequence_args seq_args;
  473. };
  474. struct nfs_setaclres {
  475. struct nfs4_sequence_res seq_res;
  476. };
  477. struct nfs_getaclargs {
  478. struct nfs_fh * fh;
  479. size_t acl_len;
  480. unsigned int acl_pgbase;
  481. struct page ** acl_pages;
  482. struct nfs4_sequence_args seq_args;
  483. };
  484. struct nfs_getaclres {
  485. size_t acl_len;
  486. struct nfs4_sequence_res seq_res;
  487. };
  488. struct nfs_setattrres {
  489. struct nfs_fattr * fattr;
  490. const struct nfs_server * server;
  491. struct nfs4_sequence_res seq_res;
  492. };
  493. struct nfs_linkargs {
  494. struct nfs_fh * fromfh;
  495. struct nfs_fh * tofh;
  496. const char * toname;
  497. unsigned int tolen;
  498. };
  499. struct nfs_symlinkargs {
  500. struct nfs_fh * fromfh;
  501. const char * fromname;
  502. unsigned int fromlen;
  503. struct page ** pages;
  504. unsigned int pathlen;
  505. struct iattr * sattr;
  506. };
  507. struct nfs_readdirargs {
  508. struct nfs_fh * fh;
  509. __u32 cookie;
  510. unsigned int count;
  511. struct page ** pages;
  512. };
  513. struct nfs3_getaclargs {
  514. struct nfs_fh * fh;
  515. int mask;
  516. struct page ** pages;
  517. };
  518. struct nfs3_setaclargs {
  519. struct inode * inode;
  520. int mask;
  521. struct posix_acl * acl_access;
  522. struct posix_acl * acl_default;
  523. size_t len;
  524. unsigned int npages;
  525. struct page ** pages;
  526. };
  527. struct nfs_diropok {
  528. struct nfs_fh * fh;
  529. struct nfs_fattr * fattr;
  530. };
  531. struct nfs_readlinkargs {
  532. struct nfs_fh * fh;
  533. unsigned int pgbase;
  534. unsigned int pglen;
  535. struct page ** pages;
  536. };
  537. struct nfs3_sattrargs {
  538. struct nfs_fh * fh;
  539. struct iattr * sattr;
  540. unsigned int guard;
  541. struct timespec guardtime;
  542. };
  543. struct nfs3_diropargs {
  544. struct nfs_fh * fh;
  545. const char * name;
  546. unsigned int len;
  547. };
  548. struct nfs3_accessargs {
  549. struct nfs_fh * fh;
  550. __u32 access;
  551. };
  552. struct nfs3_createargs {
  553. struct nfs_fh * fh;
  554. const char * name;
  555. unsigned int len;
  556. struct iattr * sattr;
  557. enum nfs3_createmode createmode;
  558. __be32 verifier[2];
  559. };
  560. struct nfs3_mkdirargs {
  561. struct nfs_fh * fh;
  562. const char * name;
  563. unsigned int len;
  564. struct iattr * sattr;
  565. };
  566. struct nfs3_symlinkargs {
  567. struct nfs_fh * fromfh;
  568. const char * fromname;
  569. unsigned int fromlen;
  570. struct page ** pages;
  571. unsigned int pathlen;
  572. struct iattr * sattr;
  573. };
  574. struct nfs3_mknodargs {
  575. struct nfs_fh * fh;
  576. const char * name;
  577. unsigned int len;
  578. enum nfs3_ftype type;
  579. struct iattr * sattr;
  580. dev_t rdev;
  581. };
  582. struct nfs3_linkargs {
  583. struct nfs_fh * fromfh;
  584. struct nfs_fh * tofh;
  585. const char * toname;
  586. unsigned int tolen;
  587. };
  588. struct nfs3_readdirargs {
  589. struct nfs_fh * fh;
  590. __u64 cookie;
  591. __be32 verf[2];
  592. int plus;
  593. unsigned int count;
  594. struct page ** pages;
  595. };
  596. struct nfs3_diropres {
  597. struct nfs_fattr * dir_attr;
  598. struct nfs_fh * fh;
  599. struct nfs_fattr * fattr;
  600. };
  601. struct nfs3_accessres {
  602. struct nfs_fattr * fattr;
  603. __u32 access;
  604. };
  605. struct nfs3_readlinkargs {
  606. struct nfs_fh * fh;
  607. unsigned int pgbase;
  608. unsigned int pglen;
  609. struct page ** pages;
  610. };
  611. struct nfs3_linkres {
  612. struct nfs_fattr * dir_attr;
  613. struct nfs_fattr * fattr;
  614. };
  615. struct nfs3_readdirres {
  616. struct nfs_fattr * dir_attr;
  617. __be32 * verf;
  618. int plus;
  619. };
  620. struct nfs3_getaclres {
  621. struct nfs_fattr * fattr;
  622. int mask;
  623. unsigned int acl_access_count;
  624. unsigned int acl_default_count;
  625. struct posix_acl * acl_access;
  626. struct posix_acl * acl_default;
  627. };
  628. #ifdef CONFIG_NFS_V4
  629. typedef u64 clientid4;
  630. struct nfs4_accessargs {
  631. const struct nfs_fh * fh;
  632. const u32 * bitmask;
  633. u32 access;
  634. struct nfs4_sequence_args seq_args;
  635. };
  636. struct nfs4_accessres {
  637. const struct nfs_server * server;
  638. struct nfs_fattr * fattr;
  639. u32 supported;
  640. u32 access;
  641. struct nfs4_sequence_res seq_res;
  642. };
  643. struct nfs4_create_arg {
  644. u32 ftype;
  645. union {
  646. struct {
  647. struct page ** pages;
  648. unsigned int len;
  649. } symlink; /* NF4LNK */
  650. struct {
  651. u32 specdata1;
  652. u32 specdata2;
  653. } device; /* NF4BLK, NF4CHR */
  654. } u;
  655. const struct qstr * name;
  656. const struct nfs_server * server;
  657. const struct iattr * attrs;
  658. const struct nfs_fh * dir_fh;
  659. const u32 * bitmask;
  660. struct nfs4_sequence_args seq_args;
  661. };
  662. struct nfs4_create_res {
  663. const struct nfs_server * server;
  664. struct nfs_fh * fh;
  665. struct nfs_fattr * fattr;
  666. struct nfs4_change_info dir_cinfo;
  667. struct nfs_fattr * dir_fattr;
  668. struct nfs4_sequence_res seq_res;
  669. };
  670. struct nfs4_fsinfo_arg {
  671. const struct nfs_fh * fh;
  672. const u32 * bitmask;
  673. struct nfs4_sequence_args seq_args;
  674. };
  675. struct nfs4_fsinfo_res {
  676. struct nfs_fsinfo *fsinfo;
  677. struct nfs4_sequence_res seq_res;
  678. };
  679. struct nfs4_getattr_arg {
  680. const struct nfs_fh * fh;
  681. const u32 * bitmask;
  682. struct nfs4_sequence_args seq_args;
  683. };
  684. struct nfs4_getattr_res {
  685. const struct nfs_server * server;
  686. struct nfs_fattr * fattr;
  687. struct nfs4_sequence_res seq_res;
  688. };
  689. struct nfs4_link_arg {
  690. const struct nfs_fh * fh;
  691. const struct nfs_fh * dir_fh;
  692. const struct qstr * name;
  693. const u32 * bitmask;
  694. struct nfs4_sequence_args seq_args;
  695. };
  696. struct nfs4_link_res {
  697. const struct nfs_server * server;
  698. struct nfs_fattr * fattr;
  699. struct nfs4_change_info cinfo;
  700. struct nfs_fattr * dir_attr;
  701. struct nfs4_sequence_res seq_res;
  702. };
  703. struct nfs4_lookup_arg {
  704. const struct nfs_fh * dir_fh;
  705. const struct qstr * name;
  706. const u32 * bitmask;
  707. struct nfs4_sequence_args seq_args;
  708. };
  709. struct nfs4_lookup_res {
  710. const struct nfs_server * server;
  711. struct nfs_fattr * fattr;
  712. struct nfs_fh * fh;
  713. struct nfs4_sequence_res seq_res;
  714. };
  715. struct nfs4_lookup_root_arg {
  716. const u32 * bitmask;
  717. struct nfs4_sequence_args seq_args;
  718. };
  719. struct nfs4_pathconf_arg {
  720. const struct nfs_fh * fh;
  721. const u32 * bitmask;
  722. struct nfs4_sequence_args seq_args;
  723. };
  724. struct nfs4_pathconf_res {
  725. struct nfs_pathconf *pathconf;
  726. struct nfs4_sequence_res seq_res;
  727. };
  728. struct nfs4_readdir_arg {
  729. const struct nfs_fh * fh;
  730. u64 cookie;
  731. nfs4_verifier verifier;
  732. u32 count;
  733. struct page ** pages; /* zero-copy data */
  734. unsigned int pgbase; /* zero-copy data */
  735. const u32 * bitmask;
  736. int plus;
  737. struct nfs4_sequence_args seq_args;
  738. };
  739. struct nfs4_readdir_res {
  740. nfs4_verifier verifier;
  741. unsigned int pgbase;
  742. struct nfs4_sequence_res seq_res;
  743. };
  744. struct nfs4_readlink {
  745. const struct nfs_fh * fh;
  746. unsigned int pgbase;
  747. unsigned int pglen; /* zero-copy data */
  748. struct page ** pages; /* zero-copy data */
  749. struct nfs4_sequence_args seq_args;
  750. };
  751. struct nfs4_readlink_res {
  752. struct nfs4_sequence_res seq_res;
  753. };
  754. #define NFS4_SETCLIENTID_NAMELEN (127)
  755. struct nfs4_setclientid {
  756. const nfs4_verifier * sc_verifier;
  757. unsigned int sc_name_len;
  758. char sc_name[NFS4_SETCLIENTID_NAMELEN + 1];
  759. u32 sc_prog;
  760. unsigned int sc_netid_len;
  761. char sc_netid[RPCBIND_MAXNETIDLEN + 1];
  762. unsigned int sc_uaddr_len;
  763. char sc_uaddr[RPCBIND_MAXUADDRLEN + 1];
  764. u32 sc_cb_ident;
  765. };
  766. struct nfs4_setclientid_res {
  767. u64 clientid;
  768. nfs4_verifier confirm;
  769. };
  770. struct nfs4_statfs_arg {
  771. const struct nfs_fh * fh;
  772. const u32 * bitmask;
  773. struct nfs4_sequence_args seq_args;
  774. };
  775. struct nfs4_statfs_res {
  776. struct nfs_fsstat *fsstat;
  777. struct nfs4_sequence_res seq_res;
  778. };
  779. struct nfs4_server_caps_arg {
  780. struct nfs_fh *fhandle;
  781. struct nfs4_sequence_args seq_args;
  782. };
  783. struct nfs4_server_caps_res {
  784. u32 attr_bitmask[2];
  785. u32 acl_bitmask;
  786. u32 has_links;
  787. u32 has_symlinks;
  788. struct nfs4_sequence_res seq_res;
  789. };
  790. struct nfs4_string {
  791. unsigned int len;
  792. char *data;
  793. };
  794. #define NFS4_PATHNAME_MAXCOMPONENTS 512
  795. struct nfs4_pathname {
  796. unsigned int ncomponents;
  797. struct nfs4_string components[NFS4_PATHNAME_MAXCOMPONENTS];
  798. };
  799. #define NFS4_FS_LOCATION_MAXSERVERS 10
  800. struct nfs4_fs_location {
  801. unsigned int nservers;
  802. struct nfs4_string servers[NFS4_FS_LOCATION_MAXSERVERS];
  803. struct nfs4_pathname rootpath;
  804. };
  805. #define NFS4_FS_LOCATIONS_MAXENTRIES 10
  806. struct nfs4_fs_locations {
  807. struct nfs_fattr fattr;
  808. const struct nfs_server *server;
  809. struct nfs4_pathname fs_path;
  810. int nlocations;
  811. struct nfs4_fs_location locations[NFS4_FS_LOCATIONS_MAXENTRIES];
  812. };
  813. struct nfs4_fs_locations_arg {
  814. const struct nfs_fh *dir_fh;
  815. const struct qstr *name;
  816. struct page *page;
  817. const u32 *bitmask;
  818. struct nfs4_sequence_args seq_args;
  819. };
  820. struct nfs4_fs_locations_res {
  821. struct nfs4_fs_locations *fs_locations;
  822. struct nfs4_sequence_res seq_res;
  823. };
  824. struct nfs4_secinfo_oid {
  825. unsigned int len;
  826. char data[GSS_OID_MAX_LEN];
  827. };
  828. struct nfs4_secinfo_gss {
  829. struct nfs4_secinfo_oid sec_oid4;
  830. unsigned int qop4;
  831. unsigned int service;
  832. };
  833. struct nfs4_secinfo_flavor {
  834. unsigned int flavor;
  835. struct nfs4_secinfo_gss gss;
  836. };
  837. struct nfs4_secinfo_flavors {
  838. unsigned int num_flavors;
  839. struct nfs4_secinfo_flavor flavors[0];
  840. };
  841. struct nfs4_secinfo_arg {
  842. const struct nfs_fh *dir_fh;
  843. const struct qstr *name;
  844. struct nfs4_sequence_args seq_args;
  845. };
  846. struct nfs4_secinfo_res {
  847. struct nfs4_secinfo_flavors *flavors;
  848. struct nfs4_sequence_res seq_res;
  849. };
  850. #endif /* CONFIG_NFS_V4 */
  851. struct nfstime4 {
  852. u64 seconds;
  853. u32 nseconds;
  854. };
  855. #ifdef CONFIG_NFS_V4_1
  856. struct nfs_impl_id4 {
  857. u32 domain_len;
  858. char *domain;
  859. u32 name_len;
  860. char *name;
  861. struct nfstime4 date;
  862. };
  863. #define NFS4_EXCHANGE_ID_LEN (48)
  864. struct nfs41_exchange_id_args {
  865. struct nfs_client *client;
  866. nfs4_verifier *verifier;
  867. unsigned int id_len;
  868. char id[NFS4_EXCHANGE_ID_LEN];
  869. u32 flags;
  870. };
  871. struct server_owner {
  872. uint64_t minor_id;
  873. uint32_t major_id_sz;
  874. char major_id[NFS4_OPAQUE_LIMIT];
  875. };
  876. struct server_scope {
  877. uint32_t server_scope_sz;
  878. char server_scope[NFS4_OPAQUE_LIMIT];
  879. };
  880. struct nfs41_exchange_id_res {
  881. struct nfs_client *client;
  882. u32 flags;
  883. };
  884. struct nfs41_create_session_args {
  885. struct nfs_client *client;
  886. uint32_t flags;
  887. uint32_t cb_program;
  888. struct nfs4_channel_attrs fc_attrs; /* Fore Channel */
  889. struct nfs4_channel_attrs bc_attrs; /* Back Channel */
  890. };
  891. struct nfs41_create_session_res {
  892. struct nfs_client *client;
  893. };
  894. struct nfs41_reclaim_complete_args {
  895. /* In the future extend to include curr_fh for use with migration */
  896. unsigned char one_fs:1;
  897. struct nfs4_sequence_args seq_args;
  898. };
  899. struct nfs41_reclaim_complete_res {
  900. struct nfs4_sequence_res seq_res;
  901. };
  902. #endif /* CONFIG_NFS_V4_1 */
  903. struct nfs_page;
  904. #define NFS_PAGEVEC_SIZE (8U)
  905. struct nfs_read_data {
  906. int flags;
  907. struct rpc_task task;
  908. struct inode *inode;
  909. struct rpc_cred *cred;
  910. struct nfs_fattr fattr; /* fattr storage */
  911. struct list_head pages; /* Coalesced read requests */
  912. struct nfs_page *req; /* multi ops per nfs_page */
  913. struct page **pagevec;
  914. unsigned int npages; /* Max length of pagevec */
  915. struct nfs_readargs args;
  916. struct nfs_readres res;
  917. unsigned long timestamp; /* For lease renewal */
  918. struct pnfs_layout_segment *lseg;
  919. struct nfs_client *ds_clp; /* pNFS data server */
  920. const struct rpc_call_ops *mds_ops;
  921. int (*read_done_cb) (struct rpc_task *task, struct nfs_read_data *data);
  922. __u64 mds_offset;
  923. struct page *page_array[NFS_PAGEVEC_SIZE];
  924. };
  925. struct nfs_write_data {
  926. int flags;
  927. struct rpc_task task;
  928. struct inode *inode;
  929. struct rpc_cred *cred;
  930. struct nfs_fattr fattr;
  931. struct nfs_writeverf verf;
  932. struct list_head pages; /* Coalesced requests we wish to flush */
  933. struct nfs_page *req; /* multi ops per nfs_page */
  934. struct page **pagevec;
  935. unsigned int npages; /* Max length of pagevec */
  936. struct nfs_writeargs args; /* argument struct */
  937. struct nfs_writeres res; /* result struct */
  938. struct pnfs_layout_segment *lseg;
  939. struct nfs_client *ds_clp; /* pNFS data server */
  940. const struct rpc_call_ops *mds_ops;
  941. int (*write_done_cb) (struct rpc_task *task, struct nfs_write_data *data);
  942. #ifdef CONFIG_NFS_V4
  943. unsigned long timestamp; /* For lease renewal */
  944. #endif
  945. __u64 mds_offset; /* Filelayout dense stripe */
  946. struct page *page_array[NFS_PAGEVEC_SIZE];
  947. };
  948. struct nfs_access_entry;
  949. struct nfs_client;
  950. struct rpc_timeout;
  951. /*
  952. * RPC procedure vector for NFSv2/NFSv3 demuxing
  953. */
  954. struct nfs_rpc_ops {
  955. u32 version; /* Protocol version */
  956. const struct dentry_operations *dentry_ops;
  957. const struct inode_operations *dir_inode_ops;
  958. const struct inode_operations *file_inode_ops;
  959. int (*getroot) (struct nfs_server *, struct nfs_fh *,
  960. struct nfs_fsinfo *);
  961. int (*lookupfh)(struct nfs_server *, struct nfs_fh *,
  962. struct qstr *, struct nfs_fh *,
  963. struct nfs_fattr *);
  964. int (*getattr) (struct nfs_server *, struct nfs_fh *,
  965. struct nfs_fattr *);
  966. int (*setattr) (struct dentry *, struct nfs_fattr *,
  967. struct iattr *);
  968. int (*lookup) (struct rpc_clnt *clnt, struct inode *, struct qstr *,
  969. struct nfs_fh *, struct nfs_fattr *);
  970. int (*access) (struct inode *, struct nfs_access_entry *);
  971. int (*readlink)(struct inode *, struct page *, unsigned int,
  972. unsigned int);
  973. int (*create) (struct inode *, struct dentry *,
  974. struct iattr *, int, struct nfs_open_context *);
  975. int (*remove) (struct inode *, struct qstr *);
  976. void (*unlink_setup) (struct rpc_message *, struct inode *dir);
  977. int (*unlink_done) (struct rpc_task *, struct inode *);
  978. int (*rename) (struct inode *, struct qstr *,
  979. struct inode *, struct qstr *);
  980. void (*rename_setup) (struct rpc_message *msg, struct inode *dir);
  981. int (*rename_done) (struct rpc_task *task, struct inode *old_dir, struct inode *new_dir);
  982. int (*link) (struct inode *, struct inode *, struct qstr *);
  983. int (*symlink) (struct inode *, struct dentry *, struct page *,
  984. unsigned int, struct iattr *);
  985. int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
  986. int (*rmdir) (struct inode *, struct qstr *);
  987. int (*readdir) (struct dentry *, struct rpc_cred *,
  988. u64, struct page **, unsigned int, int);
  989. int (*mknod) (struct inode *, struct dentry *, struct iattr *,
  990. dev_t);
  991. int (*statfs) (struct nfs_server *, struct nfs_fh *,
  992. struct nfs_fsstat *);
  993. int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
  994. struct nfs_fsinfo *);
  995. int (*pathconf) (struct nfs_server *, struct nfs_fh *,
  996. struct nfs_pathconf *);
  997. int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
  998. int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int);
  999. void (*read_setup) (struct nfs_read_data *, struct rpc_message *);
  1000. int (*read_done) (struct rpc_task *, struct nfs_read_data *);
  1001. void (*write_setup) (struct nfs_write_data *, struct rpc_message *);
  1002. int (*write_done) (struct rpc_task *, struct nfs_write_data *);
  1003. void (*commit_setup) (struct nfs_write_data *, struct rpc_message *);
  1004. int (*commit_done) (struct rpc_task *, struct nfs_write_data *);
  1005. int (*lock)(struct file *, int, struct file_lock *);
  1006. int (*lock_check_bounds)(const struct file_lock *);
  1007. void (*clear_acl_cache)(struct inode *);
  1008. void (*close_context)(struct nfs_open_context *ctx, int);
  1009. struct inode * (*open_context) (struct inode *dir,
  1010. struct nfs_open_context *ctx,
  1011. int open_flags,
  1012. struct iattr *iattr);
  1013. int (*init_client) (struct nfs_client *, const struct rpc_timeout *,
  1014. const char *, rpc_authflavor_t, int);
  1015. int (*secinfo)(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
  1016. };
  1017. /*
  1018. * NFS_CALL(getattr, inode, (fattr));
  1019. * into
  1020. * NFS_PROTO(inode)->getattr(fattr);
  1021. */
  1022. #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
  1023. /*
  1024. * Function vectors etc. for the NFS client
  1025. */
  1026. extern const struct nfs_rpc_ops nfs_v2_clientops;
  1027. extern const struct nfs_rpc_ops nfs_v3_clientops;
  1028. extern const struct nfs_rpc_ops nfs_v4_clientops;
  1029. extern struct rpc_version nfs_version2;
  1030. extern struct rpc_version nfs_version3;
  1031. extern struct rpc_version nfs_version4;
  1032. extern struct rpc_version nfsacl_version3;
  1033. extern struct rpc_program nfsacl_program;
  1034. #endif