nfs_xdr.h 30 KB

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