xref: /linux-6.15/include/linux/nfs_xdr.h (revision 2cef30d7)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_NFS_XDR_H
3 #define _LINUX_NFS_XDR_H
4 
5 #include <linux/nfsacl.h>
6 #include <linux/sunrpc/gss_api.h>
7 
8 /*
9  * To change the maximum rsize and wsize supported by the NFS client, adjust
10  * NFS_MAX_FILE_IO_SIZE.  64KB is a typical maximum, but some servers can
11  * support a megabyte or more.  The default is left at 4096 bytes, which is
12  * reasonable for NFS over UDP.
13  */
14 #define NFS_MAX_FILE_IO_SIZE	(1048576U)
15 #define NFS_DEF_FILE_IO_SIZE	(4096U)
16 #define NFS_MIN_FILE_IO_SIZE	(1024U)
17 
18 struct nfs4_string {
19 	unsigned int len;
20 	char *data;
21 };
22 
23 struct nfs_fsid {
24 	uint64_t		major;
25 	uint64_t		minor;
26 };
27 
28 /*
29  * Helper for checking equality between 2 fsids.
30  */
31 static inline int nfs_fsid_equal(const struct nfs_fsid *a, const struct nfs_fsid *b)
32 {
33 	return a->major == b->major && a->minor == b->minor;
34 }
35 
36 struct nfs4_threshold {
37 	__u32	bm;
38 	__u32	l_type;
39 	__u64	rd_sz;
40 	__u64	wr_sz;
41 	__u64	rd_io_sz;
42 	__u64	wr_io_sz;
43 };
44 
45 struct nfs_fattr {
46 	unsigned int		valid;		/* which fields are valid */
47 	umode_t			mode;
48 	__u32			nlink;
49 	kuid_t			uid;
50 	kgid_t			gid;
51 	dev_t			rdev;
52 	__u64			size;
53 	union {
54 		struct {
55 			__u32	blocksize;
56 			__u32	blocks;
57 		} nfs2;
58 		struct {
59 			__u64	used;
60 		} nfs3;
61 	} du;
62 	struct nfs_fsid		fsid;
63 	__u64			fileid;
64 	__u64			mounted_on_fileid;
65 	struct timespec64	atime;
66 	struct timespec64	mtime;
67 	struct timespec64	ctime;
68 	__u64			change_attr;	/* NFSv4 change attribute */
69 	__u64			pre_change_attr;/* pre-op NFSv4 change attribute */
70 	__u64			pre_size;	/* pre_op_attr.size	  */
71 	struct timespec64	pre_mtime;	/* pre_op_attr.mtime	  */
72 	struct timespec64	pre_ctime;	/* pre_op_attr.ctime	  */
73 	unsigned long		time_start;
74 	unsigned long		gencount;
75 	struct nfs4_string	*owner_name;
76 	struct nfs4_string	*group_name;
77 	struct nfs4_threshold	*mdsthreshold;	/* pNFS threshold hints */
78 	struct nfs4_label	*label;
79 };
80 
81 #define NFS_ATTR_FATTR_TYPE		(1U << 0)
82 #define NFS_ATTR_FATTR_MODE		(1U << 1)
83 #define NFS_ATTR_FATTR_NLINK		(1U << 2)
84 #define NFS_ATTR_FATTR_OWNER		(1U << 3)
85 #define NFS_ATTR_FATTR_GROUP		(1U << 4)
86 #define NFS_ATTR_FATTR_RDEV		(1U << 5)
87 #define NFS_ATTR_FATTR_SIZE		(1U << 6)
88 #define NFS_ATTR_FATTR_PRESIZE		(1U << 7)
89 #define NFS_ATTR_FATTR_BLOCKS_USED	(1U << 8)
90 #define NFS_ATTR_FATTR_SPACE_USED	(1U << 9)
91 #define NFS_ATTR_FATTR_FSID		(1U << 10)
92 #define NFS_ATTR_FATTR_FILEID		(1U << 11)
93 #define NFS_ATTR_FATTR_ATIME		(1U << 12)
94 #define NFS_ATTR_FATTR_MTIME		(1U << 13)
95 #define NFS_ATTR_FATTR_CTIME		(1U << 14)
96 #define NFS_ATTR_FATTR_PREMTIME		(1U << 15)
97 #define NFS_ATTR_FATTR_PRECTIME		(1U << 16)
98 #define NFS_ATTR_FATTR_CHANGE		(1U << 17)
99 #define NFS_ATTR_FATTR_PRECHANGE	(1U << 18)
100 #define NFS_ATTR_FATTR_V4_LOCATIONS	(1U << 19)
101 #define NFS_ATTR_FATTR_V4_REFERRAL	(1U << 20)
102 #define NFS_ATTR_FATTR_MOUNTPOINT	(1U << 21)
103 #define NFS_ATTR_FATTR_MOUNTED_ON_FILEID (1U << 22)
104 #define NFS_ATTR_FATTR_OWNER_NAME	(1U << 23)
105 #define NFS_ATTR_FATTR_GROUP_NAME	(1U << 24)
106 #define NFS_ATTR_FATTR_V4_SECURITY_LABEL (1U << 25)
107 
108 #define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \
109 		| NFS_ATTR_FATTR_MODE \
110 		| NFS_ATTR_FATTR_NLINK \
111 		| NFS_ATTR_FATTR_OWNER \
112 		| NFS_ATTR_FATTR_GROUP \
113 		| NFS_ATTR_FATTR_RDEV \
114 		| NFS_ATTR_FATTR_SIZE \
115 		| NFS_ATTR_FATTR_FSID \
116 		| NFS_ATTR_FATTR_FILEID \
117 		| NFS_ATTR_FATTR_ATIME \
118 		| NFS_ATTR_FATTR_MTIME \
119 		| NFS_ATTR_FATTR_CTIME \
120 		| NFS_ATTR_FATTR_CHANGE)
121 #define NFS_ATTR_FATTR_V2 (NFS_ATTR_FATTR \
122 		| NFS_ATTR_FATTR_BLOCKS_USED)
123 #define NFS_ATTR_FATTR_V3 (NFS_ATTR_FATTR \
124 		| NFS_ATTR_FATTR_SPACE_USED)
125 #define NFS_ATTR_FATTR_V4 (NFS_ATTR_FATTR \
126 		| NFS_ATTR_FATTR_SPACE_USED \
127 		| NFS_ATTR_FATTR_V4_SECURITY_LABEL)
128 
129 /*
130  * Maximal number of supported layout drivers.
131  */
132 #define NFS_MAX_LAYOUT_TYPES 8
133 
134 /*
135  * Info on the file system
136  */
137 struct nfs_fsinfo {
138 	struct nfs_fattr	*fattr; /* Post-op attributes */
139 	__u32			rtmax;	/* max.  read transfer size */
140 	__u32			rtpref;	/* pref. read transfer size */
141 	__u32			rtmult;	/* reads should be multiple of this */
142 	__u32			wtmax;	/* max.  write transfer size */
143 	__u32			wtpref;	/* pref. write transfer size */
144 	__u32			wtmult;	/* writes should be multiple of this */
145 	__u32			dtpref;	/* pref. readdir transfer size */
146 	__u64			maxfilesize;
147 	struct timespec64	time_delta; /* server time granularity */
148 	__u32			lease_time; /* in seconds */
149 	__u32			nlayouttypes; /* number of layouttypes */
150 	__u32			layouttype[NFS_MAX_LAYOUT_TYPES]; /* supported pnfs layout driver */
151 	__u32			blksize; /* preferred pnfs io block size */
152 	__u32			clone_blksize; /* granularity of a CLONE operation */
153 };
154 
155 struct nfs_fsstat {
156 	struct nfs_fattr	*fattr; /* Post-op attributes */
157 	__u64			tbytes;	/* total size in bytes */
158 	__u64			fbytes;	/* # of free bytes */
159 	__u64			abytes;	/* # of bytes available to user */
160 	__u64			tfiles;	/* # of files */
161 	__u64			ffiles;	/* # of free files */
162 	__u64			afiles;	/* # of files available to user */
163 };
164 
165 struct nfs2_fsstat {
166 	__u32			tsize;  /* Server transfer size */
167 	__u32			bsize;  /* Filesystem block size */
168 	__u32			blocks; /* No. of "bsize" blocks on filesystem */
169 	__u32			bfree;  /* No. of free "bsize" blocks */
170 	__u32			bavail; /* No. of available "bsize" blocks */
171 };
172 
173 struct nfs_pathconf {
174 	struct nfs_fattr	*fattr; /* Post-op attributes */
175 	__u32			max_link; /* max # of hard links */
176 	__u32			max_namelen; /* max name length */
177 };
178 
179 struct nfs4_change_info {
180 	u32			atomic;
181 	u64			before;
182 	u64			after;
183 };
184 
185 struct nfs_seqid;
186 
187 /* nfs41 sessions channel attributes */
188 struct nfs4_channel_attrs {
189 	u32			max_rqst_sz;
190 	u32			max_resp_sz;
191 	u32			max_resp_sz_cached;
192 	u32			max_ops;
193 	u32			max_reqs;
194 };
195 
196 struct nfs4_slot;
197 struct nfs4_sequence_args {
198 	struct nfs4_slot	*sa_slot;
199 	u8			sa_cache_this : 1,
200 				sa_privileged : 1;
201 };
202 
203 struct nfs4_sequence_res {
204 	struct nfs4_slot	*sr_slot;	/* slot used to send request */
205 	unsigned long		sr_timestamp;
206 	int			sr_status;	/* sequence operation status */
207 	u32			sr_status_flags;
208 	u32			sr_highest_slotid;
209 	u32			sr_target_highest_slotid;
210 };
211 
212 struct nfs4_get_lease_time_args {
213 	struct nfs4_sequence_args	la_seq_args;
214 };
215 
216 struct nfs4_get_lease_time_res {
217 	struct nfs4_sequence_res	lr_seq_res;
218 	struct nfs_fsinfo	       *lr_fsinfo;
219 };
220 
221 struct xdr_stream;
222 struct nfs4_xdr_opaque_data;
223 
224 struct nfs4_xdr_opaque_ops {
225 	void (*encode)(struct xdr_stream *, const void *args,
226 			const struct nfs4_xdr_opaque_data *);
227 	void (*free)(struct nfs4_xdr_opaque_data *);
228 };
229 
230 struct nfs4_xdr_opaque_data {
231 	const struct nfs4_xdr_opaque_ops *ops;
232 	void *data;
233 };
234 
235 #define PNFS_LAYOUT_MAXSIZE 4096
236 
237 struct nfs4_layoutdriver_data {
238 	struct page **pages;
239 	__u32 pglen;
240 	__u32 len;
241 };
242 
243 struct pnfs_layout_range {
244 	u32 iomode;
245 	u64 offset;
246 	u64 length;
247 };
248 
249 struct nfs4_layoutget_args {
250 	struct nfs4_sequence_args seq_args;
251 	__u32 type;
252 	struct pnfs_layout_range range;
253 	__u64 minlength;
254 	__u32 maxcount;
255 	struct inode *inode;
256 	struct nfs_open_context *ctx;
257 	nfs4_stateid stateid;
258 	struct nfs4_layoutdriver_data layout;
259 };
260 
261 struct nfs4_layoutget_res {
262 	struct nfs4_sequence_res seq_res;
263 	int status;
264 	__u32 return_on_close;
265 	struct pnfs_layout_range range;
266 	__u32 type;
267 	nfs4_stateid stateid;
268 	struct nfs4_layoutdriver_data *layoutp;
269 };
270 
271 struct nfs4_layoutget {
272 	struct nfs4_layoutget_args args;
273 	struct nfs4_layoutget_res res;
274 	const struct cred *cred;
275 	gfp_t gfp_flags;
276 };
277 
278 struct nfs4_getdeviceinfo_args {
279 	struct nfs4_sequence_args seq_args;
280 	struct pnfs_device *pdev;
281 	__u32 notify_types;
282 };
283 
284 struct nfs4_getdeviceinfo_res {
285 	struct nfs4_sequence_res seq_res;
286 	struct pnfs_device *pdev;
287 	__u32 notification;
288 };
289 
290 struct nfs4_layoutcommit_args {
291 	struct nfs4_sequence_args seq_args;
292 	nfs4_stateid stateid;
293 	__u64 lastbytewritten;
294 	struct inode *inode;
295 	const u32 *bitmask;
296 	size_t layoutupdate_len;
297 	struct page *layoutupdate_page;
298 	struct page **layoutupdate_pages;
299 	__be32 *start_p;
300 };
301 
302 struct nfs4_layoutcommit_res {
303 	struct nfs4_sequence_res seq_res;
304 	struct nfs_fattr *fattr;
305 	const struct nfs_server *server;
306 	int status;
307 };
308 
309 struct nfs4_layoutcommit_data {
310 	struct rpc_task task;
311 	struct nfs_fattr fattr;
312 	struct list_head lseg_list;
313 	const struct cred *cred;
314 	struct inode *inode;
315 	struct nfs4_layoutcommit_args args;
316 	struct nfs4_layoutcommit_res res;
317 };
318 
319 struct nfs4_layoutreturn_args {
320 	struct nfs4_sequence_args seq_args;
321 	struct pnfs_layout_hdr *layout;
322 	struct inode *inode;
323 	struct pnfs_layout_range range;
324 	nfs4_stateid stateid;
325 	__u32   layout_type;
326 	struct nfs4_xdr_opaque_data *ld_private;
327 };
328 
329 struct nfs4_layoutreturn_res {
330 	struct nfs4_sequence_res seq_res;
331 	u32 lrs_present;
332 	nfs4_stateid stateid;
333 };
334 
335 struct nfs4_layoutreturn {
336 	struct nfs4_layoutreturn_args args;
337 	struct nfs4_layoutreturn_res res;
338 	const struct cred *cred;
339 	struct nfs_client *clp;
340 	struct inode *inode;
341 	int rpc_status;
342 	struct nfs4_xdr_opaque_data ld_private;
343 };
344 
345 #define PNFS_LAYOUTSTATS_MAXSIZE 256
346 
347 struct nfs42_layoutstat_args;
348 struct nfs42_layoutstat_devinfo;
349 typedef	void (*layoutstats_encode_t)(struct xdr_stream *,
350 		struct nfs42_layoutstat_args *,
351 		struct nfs42_layoutstat_devinfo *);
352 
353 /* Per file per deviceid layoutstats */
354 struct nfs42_layoutstat_devinfo {
355 	struct nfs4_deviceid dev_id;
356 	__u64 offset;
357 	__u64 length;
358 	__u64 read_count;
359 	__u64 read_bytes;
360 	__u64 write_count;
361 	__u64 write_bytes;
362 	__u32 layout_type;
363 	struct nfs4_xdr_opaque_data ld_private;
364 };
365 
366 struct nfs42_layoutstat_args {
367 	struct nfs4_sequence_args seq_args;
368 	struct nfs_fh *fh;
369 	struct inode *inode;
370 	nfs4_stateid stateid;
371 	int num_dev;
372 	struct nfs42_layoutstat_devinfo *devinfo;
373 };
374 
375 struct nfs42_layoutstat_res {
376 	struct nfs4_sequence_res seq_res;
377 	int num_dev;
378 	int rpc_status;
379 };
380 
381 struct nfs42_layoutstat_data {
382 	struct inode *inode;
383 	struct nfs42_layoutstat_args args;
384 	struct nfs42_layoutstat_res res;
385 };
386 
387 struct nfs42_device_error {
388 	struct nfs4_deviceid dev_id;
389 	int status;
390 	enum nfs_opnum4 opnum;
391 };
392 
393 struct nfs42_layout_error {
394 	__u64 offset;
395 	__u64 length;
396 	nfs4_stateid stateid;
397 	struct nfs42_device_error errors[1];
398 };
399 
400 #define NFS42_LAYOUTERROR_MAX 5
401 
402 struct nfs42_layouterror_args {
403 	struct nfs4_sequence_args seq_args;
404 	struct inode *inode;
405 	unsigned int num_errors;
406 	struct nfs42_layout_error errors[NFS42_LAYOUTERROR_MAX];
407 };
408 
409 struct nfs42_layouterror_res {
410 	struct nfs4_sequence_res seq_res;
411 	unsigned int num_errors;
412 	int rpc_status;
413 };
414 
415 struct nfs42_layouterror_data {
416 	struct nfs42_layouterror_args args;
417 	struct nfs42_layouterror_res res;
418 	struct inode *inode;
419 	struct pnfs_layout_segment *lseg;
420 };
421 
422 struct nfs42_clone_args {
423 	struct nfs4_sequence_args	seq_args;
424 	struct nfs_fh			*src_fh;
425 	struct nfs_fh			*dst_fh;
426 	nfs4_stateid			src_stateid;
427 	nfs4_stateid			dst_stateid;
428 	__u64				src_offset;
429 	__u64				dst_offset;
430 	__u64				count;
431 	const u32			*dst_bitmask;
432 };
433 
434 struct nfs42_clone_res {
435 	struct nfs4_sequence_res	seq_res;
436 	unsigned int			rpc_status;
437 	struct nfs_fattr		*dst_fattr;
438 	const struct nfs_server		*server;
439 };
440 
441 struct stateowner_id {
442 	__u64	create_time;
443 	__u32	uniquifier;
444 };
445 
446 /*
447  * Arguments to the open call.
448  */
449 struct nfs_openargs {
450 	struct nfs4_sequence_args	seq_args;
451 	const struct nfs_fh *	fh;
452 	struct nfs_seqid *	seqid;
453 	int			open_flags;
454 	fmode_t			fmode;
455 	u32			share_access;
456 	u32			access;
457 	__u64                   clientid;
458 	struct stateowner_id	id;
459 	union {
460 		struct {
461 			struct iattr *  attrs;    /* UNCHECKED, GUARDED, EXCLUSIVE4_1 */
462 			nfs4_verifier   verifier; /* EXCLUSIVE */
463 		};
464 		nfs4_stateid	delegation;		/* CLAIM_DELEGATE_CUR */
465 		fmode_t		delegation_type;	/* CLAIM_PREVIOUS */
466 	} u;
467 	const struct qstr *	name;
468 	const struct nfs_server *server;	 /* Needed for ID mapping */
469 	const u32 *		bitmask;
470 	const u32 *		open_bitmap;
471 	enum open_claim_type4	claim;
472 	enum createmode4	createmode;
473 	const struct nfs4_label *label;
474 	umode_t			umask;
475 	struct nfs4_layoutget_args *lg_args;
476 };
477 
478 struct nfs_openres {
479 	struct nfs4_sequence_res	seq_res;
480 	nfs4_stateid            stateid;
481 	struct nfs_fh           fh;
482 	struct nfs4_change_info	cinfo;
483 	__u32                   rflags;
484 	struct nfs_fattr *      f_attr;
485 	struct nfs4_label	*f_label;
486 	struct nfs_seqid *	seqid;
487 	const struct nfs_server *server;
488 	fmode_t			delegation_type;
489 	nfs4_stateid		delegation;
490 	unsigned long		pagemod_limit;
491 	__u32			do_recall;
492 	__u32			attrset[NFS4_BITMAP_SIZE];
493 	struct nfs4_string	*owner;
494 	struct nfs4_string	*group_owner;
495 	__u32			access_request;
496 	__u32			access_supported;
497 	__u32			access_result;
498 	struct nfs4_layoutget_res *lg_res;
499 };
500 
501 /*
502  * Arguments to the open_confirm call.
503  */
504 struct nfs_open_confirmargs {
505 	struct nfs4_sequence_args	seq_args;
506 	const struct nfs_fh *	fh;
507 	nfs4_stateid *		stateid;
508 	struct nfs_seqid *	seqid;
509 };
510 
511 struct nfs_open_confirmres {
512 	struct nfs4_sequence_res	seq_res;
513 	nfs4_stateid            stateid;
514 	struct nfs_seqid *	seqid;
515 };
516 
517 /*
518  * Arguments to the close call.
519  */
520 struct nfs_closeargs {
521 	struct nfs4_sequence_args	seq_args;
522 	struct nfs_fh *         fh;
523 	nfs4_stateid 		stateid;
524 	struct nfs_seqid *	seqid;
525 	fmode_t			fmode;
526 	u32			share_access;
527 	const u32 *		bitmask;
528 	struct nfs4_layoutreturn_args *lr_args;
529 };
530 
531 struct nfs_closeres {
532 	struct nfs4_sequence_res	seq_res;
533 	nfs4_stateid            stateid;
534 	struct nfs_fattr *	fattr;
535 	struct nfs_seqid *	seqid;
536 	const struct nfs_server *server;
537 	struct nfs4_layoutreturn_res *lr_res;
538 	int lr_ret;
539 };
540 /*
541  *  * Arguments to the lock,lockt, and locku call.
542  *   */
543 struct nfs_lowner {
544 	__u64			clientid;
545 	__u64			id;
546 	dev_t			s_dev;
547 };
548 
549 struct nfs_lock_args {
550 	struct nfs4_sequence_args	seq_args;
551 	struct nfs_fh *		fh;
552 	struct file_lock *	fl;
553 	struct nfs_seqid *	lock_seqid;
554 	nfs4_stateid		lock_stateid;
555 	struct nfs_seqid *	open_seqid;
556 	nfs4_stateid		open_stateid;
557 	struct nfs_lowner	lock_owner;
558 	unsigned char		block : 1;
559 	unsigned char		reclaim : 1;
560 	unsigned char		new_lock : 1;
561 	unsigned char		new_lock_owner : 1;
562 };
563 
564 struct nfs_lock_res {
565 	struct nfs4_sequence_res	seq_res;
566 	nfs4_stateid		stateid;
567 	struct nfs_seqid *	lock_seqid;
568 	struct nfs_seqid *	open_seqid;
569 };
570 
571 struct nfs_locku_args {
572 	struct nfs4_sequence_args	seq_args;
573 	struct nfs_fh *		fh;
574 	struct file_lock *	fl;
575 	struct nfs_seqid *	seqid;
576 	nfs4_stateid 		stateid;
577 };
578 
579 struct nfs_locku_res {
580 	struct nfs4_sequence_res	seq_res;
581 	nfs4_stateid		stateid;
582 	struct nfs_seqid *	seqid;
583 };
584 
585 struct nfs_lockt_args {
586 	struct nfs4_sequence_args	seq_args;
587 	struct nfs_fh *		fh;
588 	struct file_lock *	fl;
589 	struct nfs_lowner	lock_owner;
590 };
591 
592 struct nfs_lockt_res {
593 	struct nfs4_sequence_res	seq_res;
594 	struct file_lock *	denied; /* LOCK, LOCKT failed */
595 };
596 
597 struct nfs_release_lockowner_args {
598 	struct nfs4_sequence_args	seq_args;
599 	struct nfs_lowner	lock_owner;
600 };
601 
602 struct nfs_release_lockowner_res {
603 	struct nfs4_sequence_res	seq_res;
604 };
605 
606 struct nfs4_delegreturnargs {
607 	struct nfs4_sequence_args	seq_args;
608 	const struct nfs_fh *fhandle;
609 	const nfs4_stateid *stateid;
610 	const u32 * bitmask;
611 	struct nfs4_layoutreturn_args *lr_args;
612 };
613 
614 struct nfs4_delegreturnres {
615 	struct nfs4_sequence_res	seq_res;
616 	struct nfs_fattr * fattr;
617 	struct nfs_server *server;
618 	struct nfs4_layoutreturn_res *lr_res;
619 	int lr_ret;
620 };
621 
622 /*
623  * Arguments to the write call.
624  */
625 struct nfs_write_verifier {
626 	char			data[8];
627 };
628 
629 struct nfs_writeverf {
630 	struct nfs_write_verifier verifier;
631 	enum nfs3_stable_how	committed;
632 };
633 
634 /*
635  * Arguments shared by the read and write call.
636  */
637 struct nfs_pgio_args {
638 	struct nfs4_sequence_args	seq_args;
639 	struct nfs_fh *		fh;
640 	struct nfs_open_context *context;
641 	struct nfs_lock_context *lock_context;
642 	nfs4_stateid		stateid;
643 	__u64			offset;
644 	__u32			count;
645 	unsigned int		pgbase;
646 	struct page **		pages;
647 	union {
648 		unsigned int		replen;			/* used by read */
649 		struct {
650 			const u32 *		bitmask;	/* used by write */
651 			enum nfs3_stable_how	stable;		/* used by write */
652 		};
653 	};
654 };
655 
656 struct nfs_pgio_res {
657 	struct nfs4_sequence_res	seq_res;
658 	struct nfs_fattr *	fattr;
659 	__u32			count;
660 	__u32			op_status;
661 	union {
662 		struct {
663 			unsigned int		replen;		/* used by read */
664 			int			eof;		/* used by read */
665 		};
666 		struct {
667 			struct nfs_writeverf *	verf;		/* used by write */
668 			const struct nfs_server *server;	/* used by write */
669 		};
670 	};
671 };
672 
673 /*
674  * Arguments to the commit call.
675  */
676 struct nfs_commitargs {
677 	struct nfs4_sequence_args	seq_args;
678 	struct nfs_fh		*fh;
679 	__u64			offset;
680 	__u32			count;
681 	const u32		*bitmask;
682 };
683 
684 struct nfs_commitres {
685 	struct nfs4_sequence_res	seq_res;
686 	__u32			op_status;
687 	struct nfs_fattr	*fattr;
688 	struct nfs_writeverf	*verf;
689 	const struct nfs_server *server;
690 };
691 
692 /*
693  * Common arguments to the unlink call
694  */
695 struct nfs_removeargs {
696 	struct nfs4_sequence_args	seq_args;
697 	const struct nfs_fh	*fh;
698 	struct qstr		name;
699 };
700 
701 struct nfs_removeres {
702 	struct nfs4_sequence_res 	seq_res;
703 	struct nfs_server *server;
704 	struct nfs_fattr	*dir_attr;
705 	struct nfs4_change_info	cinfo;
706 };
707 
708 /*
709  * Common arguments to the rename call
710  */
711 struct nfs_renameargs {
712 	struct nfs4_sequence_args	seq_args;
713 	const struct nfs_fh		*old_dir;
714 	const struct nfs_fh		*new_dir;
715 	const struct qstr		*old_name;
716 	const struct qstr		*new_name;
717 };
718 
719 struct nfs_renameres {
720 	struct nfs4_sequence_res	seq_res;
721 	struct nfs_server		*server;
722 	struct nfs4_change_info		old_cinfo;
723 	struct nfs_fattr		*old_fattr;
724 	struct nfs4_change_info		new_cinfo;
725 	struct nfs_fattr		*new_fattr;
726 };
727 
728 /* parsed sec= options */
729 #define NFS_AUTH_INFO_MAX_FLAVORS 12 /* see fs/nfs/super.c */
730 struct nfs_auth_info {
731 	unsigned int            flavor_len;
732 	rpc_authflavor_t        flavors[NFS_AUTH_INFO_MAX_FLAVORS];
733 };
734 
735 /*
736  * Argument struct for decode_entry function
737  */
738 struct nfs_entry {
739 	__u64			ino;
740 	__u64			cookie,
741 				prev_cookie;
742 	const char *		name;
743 	unsigned int		len;
744 	int			eof;
745 	struct nfs_fh *		fh;
746 	struct nfs_fattr *	fattr;
747 	struct nfs4_label  *label;
748 	unsigned char		d_type;
749 	struct nfs_server *	server;
750 };
751 
752 /*
753  * The following types are for NFSv2 only.
754  */
755 struct nfs_sattrargs {
756 	struct nfs_fh *		fh;
757 	struct iattr *		sattr;
758 };
759 
760 struct nfs_diropargs {
761 	struct nfs_fh *		fh;
762 	const char *		name;
763 	unsigned int		len;
764 };
765 
766 struct nfs_createargs {
767 	struct nfs_fh *		fh;
768 	const char *		name;
769 	unsigned int		len;
770 	struct iattr *		sattr;
771 };
772 
773 struct nfs_setattrargs {
774 	struct nfs4_sequence_args 	seq_args;
775 	struct nfs_fh *                 fh;
776 	nfs4_stateid                    stateid;
777 	struct iattr *                  iap;
778 	const struct nfs_server *	server; /* Needed for name mapping */
779 	const u32 *			bitmask;
780 	const struct nfs4_label		*label;
781 };
782 
783 struct nfs_setaclargs {
784 	struct nfs4_sequence_args	seq_args;
785 	struct nfs_fh *			fh;
786 	size_t				acl_len;
787 	struct page **			acl_pages;
788 };
789 
790 struct nfs_setaclres {
791 	struct nfs4_sequence_res	seq_res;
792 };
793 
794 struct nfs_getaclargs {
795 	struct nfs4_sequence_args 	seq_args;
796 	struct nfs_fh *			fh;
797 	size_t				acl_len;
798 	struct page **			acl_pages;
799 };
800 
801 /* getxattr ACL interface flags */
802 #define NFS4_ACL_TRUNC		0x0001	/* ACL was truncated */
803 struct nfs_getaclres {
804 	struct nfs4_sequence_res	seq_res;
805 	size_t				acl_len;
806 	size_t				acl_data_offset;
807 	int				acl_flags;
808 	struct page *			acl_scratch;
809 };
810 
811 struct nfs_setattrres {
812 	struct nfs4_sequence_res	seq_res;
813 	struct nfs_fattr *              fattr;
814 	struct nfs4_label		*label;
815 	const struct nfs_server *	server;
816 };
817 
818 struct nfs_linkargs {
819 	struct nfs_fh *		fromfh;
820 	struct nfs_fh *		tofh;
821 	const char *		toname;
822 	unsigned int		tolen;
823 };
824 
825 struct nfs_symlinkargs {
826 	struct nfs_fh *		fromfh;
827 	const char *		fromname;
828 	unsigned int		fromlen;
829 	struct page **		pages;
830 	unsigned int		pathlen;
831 	struct iattr *		sattr;
832 };
833 
834 struct nfs_readdirargs {
835 	struct nfs_fh *		fh;
836 	__u32			cookie;
837 	unsigned int		count;
838 	struct page **		pages;
839 };
840 
841 struct nfs3_getaclargs {
842 	struct nfs_fh *		fh;
843 	int			mask;
844 	struct page **		pages;
845 };
846 
847 struct nfs3_setaclargs {
848 	struct inode *		inode;
849 	int			mask;
850 	struct posix_acl *	acl_access;
851 	struct posix_acl *	acl_default;
852 	size_t			len;
853 	unsigned int		npages;
854 	struct page **		pages;
855 };
856 
857 struct nfs_diropok {
858 	struct nfs_fh *		fh;
859 	struct nfs_fattr *	fattr;
860 };
861 
862 struct nfs_readlinkargs {
863 	struct nfs_fh *		fh;
864 	unsigned int		pgbase;
865 	unsigned int		pglen;
866 	struct page **		pages;
867 };
868 
869 struct nfs3_sattrargs {
870 	struct nfs_fh *		fh;
871 	struct iattr *		sattr;
872 	unsigned int		guard;
873 	struct timespec64	guardtime;
874 };
875 
876 struct nfs3_diropargs {
877 	struct nfs_fh *		fh;
878 	const char *		name;
879 	unsigned int		len;
880 };
881 
882 struct nfs3_accessargs {
883 	struct nfs_fh *		fh;
884 	__u32			access;
885 };
886 
887 struct nfs3_createargs {
888 	struct nfs_fh *		fh;
889 	const char *		name;
890 	unsigned int		len;
891 	struct iattr *		sattr;
892 	enum nfs3_createmode	createmode;
893 	__be32			verifier[2];
894 };
895 
896 struct nfs3_mkdirargs {
897 	struct nfs_fh *		fh;
898 	const char *		name;
899 	unsigned int		len;
900 	struct iattr *		sattr;
901 };
902 
903 struct nfs3_symlinkargs {
904 	struct nfs_fh *		fromfh;
905 	const char *		fromname;
906 	unsigned int		fromlen;
907 	struct page **		pages;
908 	unsigned int		pathlen;
909 	struct iattr *		sattr;
910 };
911 
912 struct nfs3_mknodargs {
913 	struct nfs_fh *		fh;
914 	const char *		name;
915 	unsigned int		len;
916 	enum nfs3_ftype		type;
917 	struct iattr *		sattr;
918 	dev_t			rdev;
919 };
920 
921 struct nfs3_linkargs {
922 	struct nfs_fh *		fromfh;
923 	struct nfs_fh *		tofh;
924 	const char *		toname;
925 	unsigned int		tolen;
926 };
927 
928 struct nfs3_readdirargs {
929 	struct nfs_fh *		fh;
930 	__u64			cookie;
931 	__be32			verf[2];
932 	bool			plus;
933 	unsigned int            count;
934 	struct page **		pages;
935 };
936 
937 struct nfs3_diropres {
938 	struct nfs_fattr *	dir_attr;
939 	struct nfs_fh *		fh;
940 	struct nfs_fattr *	fattr;
941 };
942 
943 struct nfs3_accessres {
944 	struct nfs_fattr *	fattr;
945 	__u32			access;
946 };
947 
948 struct nfs3_readlinkargs {
949 	struct nfs_fh *		fh;
950 	unsigned int		pgbase;
951 	unsigned int		pglen;
952 	struct page **		pages;
953 };
954 
955 struct nfs3_linkres {
956 	struct nfs_fattr *	dir_attr;
957 	struct nfs_fattr *	fattr;
958 };
959 
960 struct nfs3_readdirres {
961 	struct nfs_fattr *	dir_attr;
962 	__be32 *		verf;
963 	bool			plus;
964 };
965 
966 struct nfs3_getaclres {
967 	struct nfs_fattr *	fattr;
968 	int			mask;
969 	unsigned int		acl_access_count;
970 	unsigned int		acl_default_count;
971 	struct posix_acl *	acl_access;
972 	struct posix_acl *	acl_default;
973 };
974 
975 #if IS_ENABLED(CONFIG_NFS_V4)
976 
977 typedef u64 clientid4;
978 
979 struct nfs4_accessargs {
980 	struct nfs4_sequence_args	seq_args;
981 	const struct nfs_fh *		fh;
982 	const u32 *			bitmask;
983 	u32				access;
984 };
985 
986 struct nfs4_accessres {
987 	struct nfs4_sequence_res	seq_res;
988 	const struct nfs_server *	server;
989 	struct nfs_fattr *		fattr;
990 	u32				supported;
991 	u32				access;
992 };
993 
994 struct nfs4_create_arg {
995 	struct nfs4_sequence_args 	seq_args;
996 	u32				ftype;
997 	union {
998 		struct {
999 			struct page **	pages;
1000 			unsigned int	len;
1001 		} symlink;   /* NF4LNK */
1002 		struct {
1003 			u32		specdata1;
1004 			u32		specdata2;
1005 		} device;    /* NF4BLK, NF4CHR */
1006 	} u;
1007 	const struct qstr *		name;
1008 	const struct nfs_server *	server;
1009 	const struct iattr *		attrs;
1010 	const struct nfs_fh *		dir_fh;
1011 	const u32 *			bitmask;
1012 	const struct nfs4_label		*label;
1013 	umode_t				umask;
1014 };
1015 
1016 struct nfs4_create_res {
1017 	struct nfs4_sequence_res	seq_res;
1018 	const struct nfs_server *	server;
1019 	struct nfs_fh *			fh;
1020 	struct nfs_fattr *		fattr;
1021 	struct nfs4_label		*label;
1022 	struct nfs4_change_info		dir_cinfo;
1023 };
1024 
1025 struct nfs4_fsinfo_arg {
1026 	struct nfs4_sequence_args	seq_args;
1027 	const struct nfs_fh *		fh;
1028 	const u32 *			bitmask;
1029 };
1030 
1031 struct nfs4_fsinfo_res {
1032 	struct nfs4_sequence_res	seq_res;
1033 	struct nfs_fsinfo	       *fsinfo;
1034 };
1035 
1036 struct nfs4_getattr_arg {
1037 	struct nfs4_sequence_args	seq_args;
1038 	const struct nfs_fh *		fh;
1039 	const u32 *			bitmask;
1040 };
1041 
1042 struct nfs4_getattr_res {
1043 	struct nfs4_sequence_res	seq_res;
1044 	const struct nfs_server *	server;
1045 	struct nfs_fattr *		fattr;
1046 	struct nfs4_label		*label;
1047 };
1048 
1049 struct nfs4_link_arg {
1050 	struct nfs4_sequence_args 	seq_args;
1051 	const struct nfs_fh *		fh;
1052 	const struct nfs_fh *		dir_fh;
1053 	const struct qstr *		name;
1054 	const u32 *			bitmask;
1055 };
1056 
1057 struct nfs4_link_res {
1058 	struct nfs4_sequence_res	seq_res;
1059 	const struct nfs_server *	server;
1060 	struct nfs_fattr *		fattr;
1061 	struct nfs4_label		*label;
1062 	struct nfs4_change_info		cinfo;
1063 	struct nfs_fattr *		dir_attr;
1064 };
1065 
1066 struct nfs4_lookup_arg {
1067 	struct nfs4_sequence_args	seq_args;
1068 	const struct nfs_fh *		dir_fh;
1069 	const struct qstr *		name;
1070 	const u32 *			bitmask;
1071 };
1072 
1073 struct nfs4_lookup_res {
1074 	struct nfs4_sequence_res	seq_res;
1075 	const struct nfs_server *	server;
1076 	struct nfs_fattr *		fattr;
1077 	struct nfs_fh *			fh;
1078 	struct nfs4_label		*label;
1079 };
1080 
1081 struct nfs4_lookupp_arg {
1082 	struct nfs4_sequence_args	seq_args;
1083 	const struct nfs_fh		*fh;
1084 	const u32			*bitmask;
1085 };
1086 
1087 struct nfs4_lookupp_res {
1088 	struct nfs4_sequence_res	seq_res;
1089 	const struct nfs_server		*server;
1090 	struct nfs_fattr		*fattr;
1091 	struct nfs_fh			*fh;
1092 	struct nfs4_label		*label;
1093 };
1094 
1095 struct nfs4_lookup_root_arg {
1096 	struct nfs4_sequence_args	seq_args;
1097 	const u32 *			bitmask;
1098 };
1099 
1100 struct nfs4_pathconf_arg {
1101 	struct nfs4_sequence_args	seq_args;
1102 	const struct nfs_fh *		fh;
1103 	const u32 *			bitmask;
1104 };
1105 
1106 struct nfs4_pathconf_res {
1107 	struct nfs4_sequence_res	seq_res;
1108 	struct nfs_pathconf	       *pathconf;
1109 };
1110 
1111 struct nfs4_readdir_arg {
1112 	struct nfs4_sequence_args	seq_args;
1113 	const struct nfs_fh *		fh;
1114 	u64				cookie;
1115 	nfs4_verifier			verifier;
1116 	u32				count;
1117 	struct page **			pages;	/* zero-copy data */
1118 	unsigned int			pgbase;	/* zero-copy data */
1119 	const u32 *			bitmask;
1120 	bool				plus;
1121 };
1122 
1123 struct nfs4_readdir_res {
1124 	struct nfs4_sequence_res	seq_res;
1125 	nfs4_verifier			verifier;
1126 	unsigned int			pgbase;
1127 };
1128 
1129 struct nfs4_readlink {
1130 	struct nfs4_sequence_args	seq_args;
1131 	const struct nfs_fh *		fh;
1132 	unsigned int			pgbase;
1133 	unsigned int			pglen;   /* zero-copy data */
1134 	struct page **			pages;   /* zero-copy data */
1135 };
1136 
1137 struct nfs4_readlink_res {
1138 	struct nfs4_sequence_res	seq_res;
1139 };
1140 
1141 struct nfs4_setclientid {
1142 	const nfs4_verifier *		sc_verifier;
1143 	u32				sc_prog;
1144 	unsigned int			sc_netid_len;
1145 	char				sc_netid[RPCBIND_MAXNETIDLEN + 1];
1146 	unsigned int			sc_uaddr_len;
1147 	char				sc_uaddr[RPCBIND_MAXUADDRLEN + 1];
1148 	struct nfs_client		*sc_clnt;
1149 	struct rpc_cred			*sc_cred;
1150 };
1151 
1152 struct nfs4_setclientid_res {
1153 	u64				clientid;
1154 	nfs4_verifier			confirm;
1155 };
1156 
1157 struct nfs4_statfs_arg {
1158 	struct nfs4_sequence_args	seq_args;
1159 	const struct nfs_fh *		fh;
1160 	const u32 *			bitmask;
1161 };
1162 
1163 struct nfs4_statfs_res {
1164 	struct nfs4_sequence_res	seq_res;
1165 	struct nfs_fsstat	       *fsstat;
1166 };
1167 
1168 struct nfs4_server_caps_arg {
1169 	struct nfs4_sequence_args	seq_args;
1170 	struct nfs_fh		       *fhandle;
1171 	const u32 *			bitmask;
1172 };
1173 
1174 struct nfs4_server_caps_res {
1175 	struct nfs4_sequence_res	seq_res;
1176 	u32				attr_bitmask[3];
1177 	u32				exclcreat_bitmask[3];
1178 	u32				acl_bitmask;
1179 	u32				has_links;
1180 	u32				has_symlinks;
1181 	u32				fh_expire_type;
1182 };
1183 
1184 #define NFS4_PATHNAME_MAXCOMPONENTS 512
1185 struct nfs4_pathname {
1186 	unsigned int ncomponents;
1187 	struct nfs4_string components[NFS4_PATHNAME_MAXCOMPONENTS];
1188 };
1189 
1190 #define NFS4_FS_LOCATION_MAXSERVERS 10
1191 struct nfs4_fs_location {
1192 	unsigned int nservers;
1193 	struct nfs4_string servers[NFS4_FS_LOCATION_MAXSERVERS];
1194 	struct nfs4_pathname rootpath;
1195 };
1196 
1197 #define NFS4_FS_LOCATIONS_MAXENTRIES 10
1198 struct nfs4_fs_locations {
1199 	struct nfs_fattr fattr;
1200 	const struct nfs_server *server;
1201 	struct nfs4_pathname fs_path;
1202 	int nlocations;
1203 	struct nfs4_fs_location locations[NFS4_FS_LOCATIONS_MAXENTRIES];
1204 };
1205 
1206 struct nfs4_fs_locations_arg {
1207 	struct nfs4_sequence_args	seq_args;
1208 	const struct nfs_fh *dir_fh;
1209 	const struct nfs_fh *fh;
1210 	const struct qstr *name;
1211 	struct page *page;
1212 	const u32 *bitmask;
1213 	clientid4 clientid;
1214 	unsigned char migration:1, renew:1;
1215 };
1216 
1217 struct nfs4_fs_locations_res {
1218 	struct nfs4_sequence_res	seq_res;
1219 	struct nfs4_fs_locations       *fs_locations;
1220 	unsigned char			migration:1, renew:1;
1221 };
1222 
1223 struct nfs4_secinfo4 {
1224 	u32			flavor;
1225 	struct rpcsec_gss_info	flavor_info;
1226 };
1227 
1228 struct nfs4_secinfo_flavors {
1229 	unsigned int		num_flavors;
1230 	struct nfs4_secinfo4	flavors[];
1231 };
1232 
1233 struct nfs4_secinfo_arg {
1234 	struct nfs4_sequence_args	seq_args;
1235 	const struct nfs_fh		*dir_fh;
1236 	const struct qstr		*name;
1237 };
1238 
1239 struct nfs4_secinfo_res {
1240 	struct nfs4_sequence_res	seq_res;
1241 	struct nfs4_secinfo_flavors	*flavors;
1242 };
1243 
1244 struct nfs4_fsid_present_arg {
1245 	struct nfs4_sequence_args	seq_args;
1246 	const struct nfs_fh		*fh;
1247 	clientid4			clientid;
1248 	unsigned char			renew:1;
1249 };
1250 
1251 struct nfs4_fsid_present_res {
1252 	struct nfs4_sequence_res	seq_res;
1253 	struct nfs_fh			*fh;
1254 	unsigned char			renew:1;
1255 };
1256 
1257 #endif /* CONFIG_NFS_V4 */
1258 
1259 struct nfstime4 {
1260 	u64	seconds;
1261 	u32	nseconds;
1262 };
1263 
1264 #ifdef CONFIG_NFS_V4_1
1265 
1266 struct pnfs_commit_bucket {
1267 	struct list_head written;
1268 	struct list_head committing;
1269 	struct pnfs_layout_segment *lseg;
1270 	struct nfs_writeverf direct_verf;
1271 };
1272 
1273 struct pnfs_commit_array {
1274 	struct list_head cinfo_list;
1275 	struct list_head lseg_list;
1276 	struct pnfs_layout_segment *lseg;
1277 	struct rcu_head rcu;
1278 	refcount_t refcount;
1279 	unsigned int nbuckets;
1280 	struct pnfs_commit_bucket buckets[];
1281 };
1282 
1283 struct pnfs_ds_commit_info {
1284 	struct list_head commits;
1285 	unsigned int nwritten;
1286 	unsigned int ncommitting;
1287 	const struct pnfs_commit_ops *ops;
1288 };
1289 
1290 struct nfs41_state_protection {
1291 	u32 how;
1292 	struct nfs4_op_map enforce;
1293 	struct nfs4_op_map allow;
1294 };
1295 
1296 struct nfs41_exchange_id_args {
1297 	struct nfs_client		*client;
1298 	nfs4_verifier			verifier;
1299 	u32				flags;
1300 	struct nfs41_state_protection	state_protect;
1301 };
1302 
1303 struct nfs41_server_owner {
1304 	uint64_t			minor_id;
1305 	uint32_t			major_id_sz;
1306 	char				major_id[NFS4_OPAQUE_LIMIT];
1307 };
1308 
1309 struct nfs41_server_scope {
1310 	uint32_t			server_scope_sz;
1311 	char 				server_scope[NFS4_OPAQUE_LIMIT];
1312 };
1313 
1314 struct nfs41_impl_id {
1315 	char				domain[NFS4_OPAQUE_LIMIT + 1];
1316 	char				name[NFS4_OPAQUE_LIMIT + 1];
1317 	struct nfstime4			date;
1318 };
1319 
1320 #define MAX_BIND_CONN_TO_SESSION_RETRIES 3
1321 struct nfs41_bind_conn_to_session_args {
1322 	struct nfs_client		*client;
1323 	struct nfs4_sessionid		sessionid;
1324 	u32				dir;
1325 	bool				use_conn_in_rdma_mode;
1326 	int				retries;
1327 };
1328 
1329 struct nfs41_bind_conn_to_session_res {
1330 	struct nfs4_sessionid		sessionid;
1331 	u32				dir;
1332 	bool				use_conn_in_rdma_mode;
1333 };
1334 
1335 struct nfs41_exchange_id_res {
1336 	u64				clientid;
1337 	u32				seqid;
1338 	u32				flags;
1339 	struct nfs41_server_owner	*server_owner;
1340 	struct nfs41_server_scope	*server_scope;
1341 	struct nfs41_impl_id		*impl_id;
1342 	struct nfs41_state_protection	state_protect;
1343 };
1344 
1345 struct nfs41_create_session_args {
1346 	struct nfs_client	       *client;
1347 	u64				clientid;
1348 	uint32_t			seqid;
1349 	uint32_t			flags;
1350 	uint32_t			cb_program;
1351 	struct nfs4_channel_attrs	fc_attrs;	/* Fore Channel */
1352 	struct nfs4_channel_attrs	bc_attrs;	/* Back Channel */
1353 };
1354 
1355 struct nfs41_create_session_res {
1356 	struct nfs4_sessionid		sessionid;
1357 	uint32_t			seqid;
1358 	uint32_t			flags;
1359 	struct nfs4_channel_attrs	fc_attrs;	/* Fore Channel */
1360 	struct nfs4_channel_attrs	bc_attrs;	/* Back Channel */
1361 };
1362 
1363 struct nfs41_reclaim_complete_args {
1364 	struct nfs4_sequence_args	seq_args;
1365 	/* In the future extend to include curr_fh for use with migration */
1366 	unsigned char			one_fs:1;
1367 };
1368 
1369 struct nfs41_reclaim_complete_res {
1370 	struct nfs4_sequence_res	seq_res;
1371 };
1372 
1373 #define SECINFO_STYLE_CURRENT_FH 0
1374 #define SECINFO_STYLE_PARENT 1
1375 struct nfs41_secinfo_no_name_args {
1376 	struct nfs4_sequence_args	seq_args;
1377 	int				style;
1378 };
1379 
1380 struct nfs41_test_stateid_args {
1381 	struct nfs4_sequence_args	seq_args;
1382 	nfs4_stateid			*stateid;
1383 };
1384 
1385 struct nfs41_test_stateid_res {
1386 	struct nfs4_sequence_res	seq_res;
1387 	unsigned int			status;
1388 };
1389 
1390 struct nfs41_free_stateid_args {
1391 	struct nfs4_sequence_args	seq_args;
1392 	nfs4_stateid			stateid;
1393 };
1394 
1395 struct nfs41_free_stateid_res {
1396 	struct nfs4_sequence_res	seq_res;
1397 	unsigned int			status;
1398 };
1399 
1400 #else
1401 
1402 struct pnfs_ds_commit_info {
1403 };
1404 
1405 #endif /* CONFIG_NFS_V4_1 */
1406 
1407 #ifdef CONFIG_NFS_V4_2
1408 struct nfs42_falloc_args {
1409 	struct nfs4_sequence_args	seq_args;
1410 
1411 	struct nfs_fh			*falloc_fh;
1412 	nfs4_stateid			 falloc_stateid;
1413 	u64				 falloc_offset;
1414 	u64				 falloc_length;
1415 	const u32			*falloc_bitmask;
1416 };
1417 
1418 struct nfs42_falloc_res {
1419 	struct nfs4_sequence_res	seq_res;
1420 	unsigned int			status;
1421 
1422 	struct nfs_fattr		*falloc_fattr;
1423 	const struct nfs_server		*falloc_server;
1424 };
1425 
1426 struct nfs42_copy_args {
1427 	struct nfs4_sequence_args	seq_args;
1428 
1429 	struct nfs_fh			*src_fh;
1430 	nfs4_stateid			src_stateid;
1431 	u64				src_pos;
1432 
1433 	struct nfs_fh			*dst_fh;
1434 	nfs4_stateid			dst_stateid;
1435 	u64				dst_pos;
1436 
1437 	u64				count;
1438 	bool				sync;
1439 	struct nl4_server		*cp_src;
1440 };
1441 
1442 struct nfs42_write_res {
1443 	nfs4_stateid		stateid;
1444 	u64			count;
1445 	struct nfs_writeverf	verifier;
1446 };
1447 
1448 struct nfs42_copy_res {
1449 	struct nfs4_sequence_res	seq_res;
1450 	struct nfs42_write_res		write_res;
1451 	bool				consecutive;
1452 	bool				synchronous;
1453 	struct nfs_commitres		commit_res;
1454 };
1455 
1456 struct nfs42_offload_status_args {
1457 	struct nfs4_sequence_args	osa_seq_args;
1458 	struct nfs_fh			*osa_src_fh;
1459 	nfs4_stateid			osa_stateid;
1460 };
1461 
1462 struct nfs42_offload_status_res {
1463 	struct nfs4_sequence_res	osr_seq_res;
1464 	uint64_t			osr_count;
1465 	int				osr_status;
1466 };
1467 
1468 struct nfs42_copy_notify_args {
1469 	struct nfs4_sequence_args	cna_seq_args;
1470 
1471 	struct nfs_fh		*cna_src_fh;
1472 	nfs4_stateid		cna_src_stateid;
1473 	struct nl4_server	cna_dst;
1474 };
1475 
1476 struct nfs42_copy_notify_res {
1477 	struct nfs4_sequence_res	cnr_seq_res;
1478 
1479 	struct nfstime4		cnr_lease_time;
1480 	nfs4_stateid		cnr_stateid;
1481 	struct nl4_server	cnr_src;
1482 };
1483 
1484 struct nfs42_seek_args {
1485 	struct nfs4_sequence_args	seq_args;
1486 
1487 	struct nfs_fh			*sa_fh;
1488 	nfs4_stateid			sa_stateid;
1489 	u64				sa_offset;
1490 	u32				sa_what;
1491 };
1492 
1493 struct nfs42_seek_res {
1494 	struct nfs4_sequence_res	seq_res;
1495 	unsigned int			status;
1496 
1497 	u32	sr_eof;
1498 	u64	sr_offset;
1499 };
1500 #endif
1501 
1502 struct nfs_page;
1503 
1504 #define NFS_PAGEVEC_SIZE	(8U)
1505 
1506 struct nfs_page_array {
1507 	struct page		**pagevec;
1508 	unsigned int		npages;		/* Max length of pagevec */
1509 	struct page		*page_array[NFS_PAGEVEC_SIZE];
1510 };
1511 
1512 /* used as flag bits in nfs_pgio_header */
1513 enum {
1514 	NFS_IOHDR_ERROR = 0,
1515 	NFS_IOHDR_EOF,
1516 	NFS_IOHDR_REDO,
1517 	NFS_IOHDR_STAT,
1518 	NFS_IOHDR_RESEND_PNFS,
1519 	NFS_IOHDR_RESEND_MDS,
1520 };
1521 
1522 struct nfs_io_completion;
1523 struct nfs_pgio_header {
1524 	struct inode		*inode;
1525 	const struct cred		*cred;
1526 	struct list_head	pages;
1527 	struct nfs_page		*req;
1528 	struct nfs_writeverf	verf;		/* Used for writes */
1529 	fmode_t			rw_mode;
1530 	struct pnfs_layout_segment *lseg;
1531 	loff_t			io_start;
1532 	const struct rpc_call_ops *mds_ops;
1533 	void (*release) (struct nfs_pgio_header *hdr);
1534 	const struct nfs_pgio_completion_ops *completion_ops;
1535 	const struct nfs_rw_ops	*rw_ops;
1536 	struct nfs_io_completion *io_completion;
1537 	struct nfs_direct_req	*dreq;
1538 
1539 	int			pnfs_error;
1540 	int			error;		/* merge with pnfs_error */
1541 	unsigned int		good_bytes;	/* boundary of good data */
1542 	unsigned long		flags;
1543 
1544 	/*
1545 	 * rpc data
1546 	 */
1547 	struct rpc_task		task;
1548 	struct nfs_fattr	fattr;
1549 	struct nfs_pgio_args	args;		/* argument struct */
1550 	struct nfs_pgio_res	res;		/* result struct */
1551 	unsigned long		timestamp;	/* For lease renewal */
1552 	int (*pgio_done_cb)(struct rpc_task *, struct nfs_pgio_header *);
1553 	__u64			mds_offset;	/* Filelayout dense stripe */
1554 	struct nfs_page_array	page_array;
1555 	struct nfs_client	*ds_clp;	/* pNFS data server */
1556 	int			ds_commit_idx;	/* ds index if ds_clp is set */
1557 	int			pgio_mirror_idx;/* mirror index in pgio layer */
1558 };
1559 
1560 struct nfs_mds_commit_info {
1561 	atomic_t rpcs_out;
1562 	atomic_long_t		ncommit;
1563 	struct list_head	list;
1564 };
1565 
1566 struct nfs_commit_info;
1567 struct nfs_commit_data;
1568 struct nfs_inode;
1569 struct nfs_commit_completion_ops {
1570 	void (*completion) (struct nfs_commit_data *data);
1571 	void (*resched_write) (struct nfs_commit_info *, struct nfs_page *);
1572 };
1573 
1574 struct nfs_commit_info {
1575 	struct inode 			*inode;	/* Needed for inode->i_lock */
1576 	struct nfs_mds_commit_info	*mds;
1577 	struct pnfs_ds_commit_info	*ds;
1578 	struct nfs_direct_req		*dreq;	/* O_DIRECT request */
1579 	const struct nfs_commit_completion_ops *completion_ops;
1580 };
1581 
1582 struct nfs_commit_data {
1583 	struct rpc_task		task;
1584 	struct inode		*inode;
1585 	const struct cred		*cred;
1586 	struct nfs_fattr	fattr;
1587 	struct nfs_writeverf	verf;
1588 	struct list_head	pages;		/* Coalesced requests we wish to flush */
1589 	struct list_head	list;		/* lists of struct nfs_write_data */
1590 	struct nfs_direct_req	*dreq;		/* O_DIRECT request */
1591 	struct nfs_commitargs	args;		/* argument struct */
1592 	struct nfs_commitres	res;		/* result struct */
1593 	struct nfs_open_context *context;
1594 	struct pnfs_layout_segment *lseg;
1595 	struct nfs_client	*ds_clp;	/* pNFS data server */
1596 	int			ds_commit_index;
1597 	loff_t			lwb;
1598 	const struct rpc_call_ops *mds_ops;
1599 	const struct nfs_commit_completion_ops *completion_ops;
1600 	int (*commit_done_cb) (struct rpc_task *task, struct nfs_commit_data *data);
1601 	unsigned long		flags;
1602 };
1603 
1604 struct nfs_pgio_completion_ops {
1605 	void	(*error_cleanup)(struct list_head *head, int);
1606 	void	(*init_hdr)(struct nfs_pgio_header *hdr);
1607 	void	(*completion)(struct nfs_pgio_header *hdr);
1608 	void	(*reschedule_io)(struct nfs_pgio_header *hdr);
1609 };
1610 
1611 struct nfs_unlinkdata {
1612 	struct nfs_removeargs args;
1613 	struct nfs_removeres res;
1614 	struct dentry *dentry;
1615 	wait_queue_head_t wq;
1616 	const struct cred *cred;
1617 	struct nfs_fattr dir_attr;
1618 	long timeout;
1619 };
1620 
1621 struct nfs_renamedata {
1622 	struct nfs_renameargs	args;
1623 	struct nfs_renameres	res;
1624 	const struct cred	*cred;
1625 	struct inode		*old_dir;
1626 	struct dentry		*old_dentry;
1627 	struct nfs_fattr	old_fattr;
1628 	struct inode		*new_dir;
1629 	struct dentry		*new_dentry;
1630 	struct nfs_fattr	new_fattr;
1631 	void (*complete)(struct rpc_task *, struct nfs_renamedata *);
1632 	long timeout;
1633 	bool cancelled;
1634 };
1635 
1636 struct nfs_access_entry;
1637 struct nfs_client;
1638 struct rpc_timeout;
1639 struct nfs_subversion;
1640 struct nfs_mount_info;
1641 struct nfs_client_initdata;
1642 struct nfs_pageio_descriptor;
1643 struct fs_context;
1644 
1645 /*
1646  * RPC procedure vector for NFSv2/NFSv3 demuxing
1647  */
1648 struct nfs_rpc_ops {
1649 	u32	version;		/* Protocol version */
1650 	const struct dentry_operations *dentry_ops;
1651 	const struct inode_operations *dir_inode_ops;
1652 	const struct inode_operations *file_inode_ops;
1653 	const struct file_operations *file_ops;
1654 	const struct nlmclnt_operations *nlmclnt_ops;
1655 
1656 	int	(*getroot) (struct nfs_server *, struct nfs_fh *,
1657 			    struct nfs_fsinfo *);
1658 	int	(*submount) (struct fs_context *, struct nfs_server *);
1659 	int	(*try_get_tree) (struct fs_context *);
1660 	int	(*getattr) (struct nfs_server *, struct nfs_fh *,
1661 			    struct nfs_fattr *, struct nfs4_label *,
1662 			    struct inode *);
1663 	int	(*setattr) (struct dentry *, struct nfs_fattr *,
1664 			    struct iattr *);
1665 	int	(*lookup)  (struct inode *, struct dentry *,
1666 			    struct nfs_fh *, struct nfs_fattr *,
1667 			    struct nfs4_label *);
1668 	int	(*lookupp) (struct inode *, struct nfs_fh *,
1669 			    struct nfs_fattr *, struct nfs4_label *);
1670 	int	(*access)  (struct inode *, struct nfs_access_entry *);
1671 	int	(*readlink)(struct inode *, struct page *, unsigned int,
1672 			    unsigned int);
1673 	int	(*create)  (struct inode *, struct dentry *,
1674 			    struct iattr *, int);
1675 	int	(*remove)  (struct inode *, struct dentry *);
1676 	void	(*unlink_setup)  (struct rpc_message *, struct dentry *, struct inode *);
1677 	void	(*unlink_rpc_prepare) (struct rpc_task *, struct nfs_unlinkdata *);
1678 	int	(*unlink_done) (struct rpc_task *, struct inode *);
1679 	void	(*rename_setup)  (struct rpc_message *msg,
1680 			struct dentry *old_dentry,
1681 			struct dentry *new_dentry);
1682 	void	(*rename_rpc_prepare)(struct rpc_task *task, struct nfs_renamedata *);
1683 	int	(*rename_done) (struct rpc_task *task, struct inode *old_dir, struct inode *new_dir);
1684 	int	(*link)    (struct inode *, struct inode *, const struct qstr *);
1685 	int	(*symlink) (struct inode *, struct dentry *, struct page *,
1686 			    unsigned int, struct iattr *);
1687 	int	(*mkdir)   (struct inode *, struct dentry *, struct iattr *);
1688 	int	(*rmdir)   (struct inode *, const struct qstr *);
1689 	int	(*readdir) (struct dentry *, const struct cred *,
1690 			    u64, struct page **, unsigned int, bool);
1691 	int	(*mknod)   (struct inode *, struct dentry *, struct iattr *,
1692 			    dev_t);
1693 	int	(*statfs)  (struct nfs_server *, struct nfs_fh *,
1694 			    struct nfs_fsstat *);
1695 	int	(*fsinfo)  (struct nfs_server *, struct nfs_fh *,
1696 			    struct nfs_fsinfo *);
1697 	int	(*pathconf) (struct nfs_server *, struct nfs_fh *,
1698 			     struct nfs_pathconf *);
1699 	int	(*set_capabilities)(struct nfs_server *, struct nfs_fh *);
1700 	int	(*decode_dirent)(struct xdr_stream *, struct nfs_entry *, bool);
1701 	int	(*pgio_rpc_prepare)(struct rpc_task *,
1702 				    struct nfs_pgio_header *);
1703 	void	(*read_setup)(struct nfs_pgio_header *, struct rpc_message *);
1704 	int	(*read_done)(struct rpc_task *, struct nfs_pgio_header *);
1705 	void	(*write_setup)(struct nfs_pgio_header *, struct rpc_message *,
1706 				struct rpc_clnt **);
1707 	int	(*write_done)(struct rpc_task *, struct nfs_pgio_header *);
1708 	void	(*commit_setup) (struct nfs_commit_data *, struct rpc_message *,
1709 				struct rpc_clnt **);
1710 	void	(*commit_rpc_prepare)(struct rpc_task *, struct nfs_commit_data *);
1711 	int	(*commit_done) (struct rpc_task *, struct nfs_commit_data *);
1712 	int	(*lock)(struct file *, int, struct file_lock *);
1713 	int	(*lock_check_bounds)(const struct file_lock *);
1714 	void	(*clear_acl_cache)(struct inode *);
1715 	void	(*close_context)(struct nfs_open_context *ctx, int);
1716 	struct inode * (*open_context) (struct inode *dir,
1717 				struct nfs_open_context *ctx,
1718 				int open_flags,
1719 				struct iattr *iattr,
1720 				int *);
1721 	int (*have_delegation)(struct inode *, fmode_t);
1722 	struct nfs_client *(*alloc_client) (const struct nfs_client_initdata *);
1723 	struct nfs_client *(*init_client) (struct nfs_client *,
1724 				const struct nfs_client_initdata *);
1725 	void	(*free_client) (struct nfs_client *);
1726 	struct nfs_server *(*create_server)(struct fs_context *);
1727 	struct nfs_server *(*clone_server)(struct nfs_server *, struct nfs_fh *,
1728 					   struct nfs_fattr *, rpc_authflavor_t);
1729 };
1730 
1731 /*
1732  * 	NFS_CALL(getattr, inode, (fattr));
1733  * into
1734  *	NFS_PROTO(inode)->getattr(fattr);
1735  */
1736 #define NFS_CALL(op, inode, args)	NFS_PROTO(inode)->op args
1737 
1738 /*
1739  * Function vectors etc. for the NFS client
1740  */
1741 extern const struct nfs_rpc_ops	nfs_v2_clientops;
1742 extern const struct nfs_rpc_ops	nfs_v3_clientops;
1743 extern const struct nfs_rpc_ops	nfs_v4_clientops;
1744 extern const struct rpc_version nfs_version2;
1745 extern const struct rpc_version nfs_version3;
1746 extern const struct rpc_version nfs_version4;
1747 
1748 extern const struct rpc_version nfsacl_version3;
1749 extern const struct rpc_program nfsacl_program;
1750 
1751 #endif
1752