nfs_xdr.h 29 KB

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