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