nfs_xdr.h 28 KB

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