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