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