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