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