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