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