Cleanup XDR parsing for LAYOUTGET, GETDEVICEINFO
[platform/kernel/linux-arm64.git] / include / linux / nfs_xdr.h
1 #ifndef _LINUX_NFS_XDR_H
2 #define _LINUX_NFS_XDR_H
3
4 #include <linux/nfsacl.h>
5 #include <linux/nfs3.h>
6
7 /*
8  * To change the maximum rsize and wsize supported by the NFS client, adjust
9  * NFS_MAX_FILE_IO_SIZE.  64KB is a typical maximum, but some servers can
10  * support a megabyte or more.  The default is left at 4096 bytes, which is
11  * reasonable for NFS over UDP.
12  */
13 #define NFS_MAX_FILE_IO_SIZE    (1048576U)
14 #define NFS_DEF_FILE_IO_SIZE    (4096U)
15 #define NFS_MIN_FILE_IO_SIZE    (1024U)
16
17 struct nfs_fsid {
18         uint64_t                major;
19         uint64_t                minor;
20 };
21
22 /*
23  * Helper for checking equality between 2 fsids.
24  */
25 static inline int nfs_fsid_equal(const struct nfs_fsid *a, const struct nfs_fsid *b)
26 {
27         return a->major == b->major && a->minor == b->minor;
28 }
29
30 struct nfs_fattr {
31         unsigned int            valid;          /* which fields are valid */
32         umode_t                 mode;
33         __u32                   nlink;
34         __u32                   uid;
35         __u32                   gid;
36         dev_t                   rdev;
37         __u64                   size;
38         union {
39                 struct {
40                         __u32   blocksize;
41                         __u32   blocks;
42                 } nfs2;
43                 struct {
44                         __u64   used;
45                 } nfs3;
46         } du;
47         struct nfs_fsid         fsid;
48         __u64                   fileid;
49         struct timespec         atime;
50         struct timespec         mtime;
51         struct timespec         ctime;
52         __u64                   change_attr;    /* NFSv4 change attribute */
53         __u64                   pre_change_attr;/* pre-op NFSv4 change attribute */
54         __u64                   pre_size;       /* pre_op_attr.size       */
55         struct timespec         pre_mtime;      /* pre_op_attr.mtime      */
56         struct timespec         pre_ctime;      /* pre_op_attr.ctime      */
57         unsigned long           time_start;
58         unsigned long           gencount;
59 };
60
61 #define NFS_ATTR_FATTR_TYPE             (1U << 0)
62 #define NFS_ATTR_FATTR_MODE             (1U << 1)
63 #define NFS_ATTR_FATTR_NLINK            (1U << 2)
64 #define NFS_ATTR_FATTR_OWNER            (1U << 3)
65 #define NFS_ATTR_FATTR_GROUP            (1U << 4)
66 #define NFS_ATTR_FATTR_RDEV             (1U << 5)
67 #define NFS_ATTR_FATTR_SIZE             (1U << 6)
68 #define NFS_ATTR_FATTR_PRESIZE          (1U << 7)
69 #define NFS_ATTR_FATTR_BLOCKS_USED      (1U << 8)
70 #define NFS_ATTR_FATTR_SPACE_USED       (1U << 9)
71 #define NFS_ATTR_FATTR_FSID             (1U << 10)
72 #define NFS_ATTR_FATTR_FILEID           (1U << 11)
73 #define NFS_ATTR_FATTR_ATIME            (1U << 12)
74 #define NFS_ATTR_FATTR_MTIME            (1U << 13)
75 #define NFS_ATTR_FATTR_CTIME            (1U << 14)
76 #define NFS_ATTR_FATTR_PREMTIME         (1U << 15)
77 #define NFS_ATTR_FATTR_PRECTIME         (1U << 16)
78 #define NFS_ATTR_FATTR_CHANGE           (1U << 17)
79 #define NFS_ATTR_FATTR_PRECHANGE        (1U << 18)
80 #define NFS_ATTR_FATTR_V4_REFERRAL      (1U << 19)      /* NFSv4 referral */
81
82 #define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \
83                 | NFS_ATTR_FATTR_MODE \
84                 | NFS_ATTR_FATTR_NLINK \
85                 | NFS_ATTR_FATTR_OWNER \
86                 | NFS_ATTR_FATTR_GROUP \
87                 | NFS_ATTR_FATTR_RDEV \
88                 | NFS_ATTR_FATTR_SIZE \
89                 | NFS_ATTR_FATTR_FSID \
90                 | NFS_ATTR_FATTR_FILEID \
91                 | NFS_ATTR_FATTR_ATIME \
92                 | NFS_ATTR_FATTR_MTIME \
93                 | NFS_ATTR_FATTR_CTIME)
94 #define NFS_ATTR_FATTR_V2 (NFS_ATTR_FATTR \
95                 | NFS_ATTR_FATTR_BLOCKS_USED)
96 #define NFS_ATTR_FATTR_V3 (NFS_ATTR_FATTR \
97                 | NFS_ATTR_FATTR_SPACE_USED)
98 #define NFS_ATTR_FATTR_V4 (NFS_ATTR_FATTR \
99                 | NFS_ATTR_FATTR_SPACE_USED \
100                 | NFS_ATTR_FATTR_CHANGE)
101
102 /*
103  * Info on the file system
104  */
105 struct nfs_fsinfo {
106         struct nfs_fattr        *fattr; /* Post-op attributes */
107         __u32                   rtmax;  /* max.  read transfer size */
108         __u32                   rtpref; /* pref. read transfer size */
109         __u32                   rtmult; /* reads should be multiple of this */
110         __u32                   wtmax;  /* max.  write transfer size */
111         __u32                   wtpref; /* pref. write transfer size */
112         __u32                   wtmult; /* writes should be multiple of this */
113         __u32                   dtpref; /* pref. readdir transfer size */
114         __u64                   maxfilesize;
115         struct timespec         time_delta; /* server time granularity */
116         __u32                   lease_time; /* in seconds */
117         __u32                   layouttype; /* supported pnfs layout driver */
118 };
119
120 struct nfs_fsstat {
121         struct nfs_fattr        *fattr; /* Post-op attributes */
122         __u64                   tbytes; /* total size in bytes */
123         __u64                   fbytes; /* # of free bytes */
124         __u64                   abytes; /* # of bytes available to user */
125         __u64                   tfiles; /* # of files */
126         __u64                   ffiles; /* # of free files */
127         __u64                   afiles; /* # of files available to user */
128 };
129
130 struct nfs2_fsstat {
131         __u32                   tsize;  /* Server transfer size */
132         __u32                   bsize;  /* Filesystem block size */
133         __u32                   blocks; /* No. of "bsize" blocks on filesystem */
134         __u32                   bfree;  /* No. of free "bsize" blocks */
135         __u32                   bavail; /* No. of available "bsize" blocks */
136 };
137
138 struct nfs_pathconf {
139         struct nfs_fattr        *fattr; /* Post-op attributes */
140         __u32                   max_link; /* max # of hard links */
141         __u32                   max_namelen; /* max name length */
142 };
143
144 struct nfs4_change_info {
145         u32                     atomic;
146         u64                     before;
147         u64                     after;
148 };
149
150 struct nfs_seqid;
151
152 /* nfs41 sessions channel attributes */
153 struct nfs4_channel_attrs {
154         u32                     headerpadsz;
155         u32                     max_rqst_sz;
156         u32                     max_resp_sz;
157         u32                     max_resp_sz_cached;
158         u32                     max_ops;
159         u32                     max_reqs;
160 };
161
162 /* nfs41 sessions slot seqid */
163 struct nfs4_slot {
164         u32                     seq_nr;
165 };
166
167 struct nfs4_sequence_args {
168         struct nfs4_session     *sa_session;
169         u8                      sa_slotid;
170         u8                      sa_cache_this;
171 };
172
173 struct nfs4_sequence_res {
174         struct nfs4_session     *sr_session;
175         struct nfs4_slot        *sr_slot;       /* slot used to send request */
176         int                     sr_status;      /* sequence operation status */
177         unsigned long           sr_renewal_time;
178         u32                     sr_status_flags;
179 };
180
181 struct nfs4_get_lease_time_args {
182         struct nfs4_sequence_args       la_seq_args;
183 };
184
185 struct nfs4_get_lease_time_res {
186         struct nfs_fsinfo              *lr_fsinfo;
187         struct nfs4_sequence_res        lr_seq_res;
188 };
189
190 #define PNFS_LAYOUT_MAXSIZE 4096
191
192 struct nfs4_layoutdriver_data {
193         struct page **pages;
194         __u32 pglen;
195         __u32 len;
196 };
197
198 struct pnfs_layout_range {
199         u32 iomode;
200         u64 offset;
201         u64 length;
202 };
203
204 struct nfs4_layoutget_args {
205         __u32 type;
206         struct pnfs_layout_range range;
207         __u64 minlength;
208         __u32 maxcount;
209         struct inode *inode;
210         struct nfs_open_context *ctx;
211         struct nfs4_sequence_args seq_args;
212         nfs4_stateid stateid;
213         struct nfs4_layoutdriver_data layout;
214 };
215
216 struct nfs4_layoutget_res {
217         __u32 return_on_close;
218         struct pnfs_layout_range range;
219         __u32 type;
220         nfs4_stateid stateid;
221         struct nfs4_sequence_res seq_res;
222         struct nfs4_layoutdriver_data *layoutp;
223 };
224
225 struct nfs4_layoutget {
226         struct nfs4_layoutget_args args;
227         struct nfs4_layoutget_res res;
228         struct pnfs_layout_segment **lsegpp;
229 };
230
231 struct nfs4_getdeviceinfo_args {
232         struct pnfs_device *pdev;
233         struct nfs4_sequence_args seq_args;
234 };
235
236 struct nfs4_getdeviceinfo_res {
237         struct pnfs_device *pdev;
238         struct nfs4_sequence_res seq_res;
239 };
240
241 struct nfs4_layoutcommit_args {
242         nfs4_stateid stateid;
243         __u64 lastbytewritten;
244         struct inode *inode;
245         const u32 *bitmask;
246         struct nfs4_sequence_args seq_args;
247 };
248
249 struct nfs4_layoutcommit_res {
250         struct nfs_fattr *fattr;
251         const struct nfs_server *server;
252         struct nfs4_sequence_res seq_res;
253 };
254
255 struct nfs4_layoutcommit_data {
256         struct rpc_task task;
257         struct nfs_fattr fattr;
258         struct pnfs_layout_segment *lseg;
259         struct rpc_cred *cred;
260         struct nfs4_layoutcommit_args args;
261         struct nfs4_layoutcommit_res res;
262 };
263
264 /*
265  * Arguments to the open call.
266  */
267 struct nfs_openargs {
268         const struct nfs_fh *   fh;
269         struct nfs_seqid *      seqid;
270         int                     open_flags;
271         fmode_t                 fmode;
272         __u64                   clientid;
273         __u64                   id;
274         union {
275                 struct {
276                         struct iattr *  attrs;    /* UNCHECKED, GUARDED */
277                         nfs4_verifier   verifier; /* EXCLUSIVE */
278                 };
279                 nfs4_stateid    delegation;             /* CLAIM_DELEGATE_CUR */
280                 fmode_t         delegation_type;        /* CLAIM_PREVIOUS */
281         } u;
282         const struct qstr *     name;
283         const struct nfs_server *server;         /* Needed for ID mapping */
284         const u32 *             bitmask;
285         __u32                   claim;
286         struct nfs4_sequence_args       seq_args;
287 };
288
289 struct nfs_openres {
290         nfs4_stateid            stateid;
291         struct nfs_fh           fh;
292         struct nfs4_change_info cinfo;
293         __u32                   rflags;
294         struct nfs_fattr *      f_attr;
295         struct nfs_fattr *      dir_attr;
296         struct nfs_seqid *      seqid;
297         const struct nfs_server *server;
298         fmode_t                 delegation_type;
299         nfs4_stateid            delegation;
300         __u32                   do_recall;
301         __u64                   maxsize;
302         __u32                   attrset[NFS4_BITMAP_SIZE];
303         struct nfs4_sequence_res        seq_res;
304 };
305
306 /*
307  * Arguments to the open_confirm call.
308  */
309 struct nfs_open_confirmargs {
310         const struct nfs_fh *   fh;
311         nfs4_stateid *          stateid;
312         struct nfs_seqid *      seqid;
313 };
314
315 struct nfs_open_confirmres {
316         nfs4_stateid            stateid;
317         struct nfs_seqid *      seqid;
318 };
319
320 /*
321  * Arguments to the close call.
322  */
323 struct nfs_closeargs {
324         struct nfs_fh *         fh;
325         nfs4_stateid *          stateid;
326         struct nfs_seqid *      seqid;
327         fmode_t                 fmode;
328         const u32 *             bitmask;
329         struct nfs4_sequence_args       seq_args;
330 };
331
332 struct nfs_closeres {
333         nfs4_stateid            stateid;
334         struct nfs_fattr *      fattr;
335         struct nfs_seqid *      seqid;
336         const struct nfs_server *server;
337         struct nfs4_sequence_res        seq_res;
338 };
339 /*
340  *  * Arguments to the lock,lockt, and locku call.
341  *   */
342 struct nfs_lowner {
343         __u64                   clientid;
344         __u64                   id;
345         dev_t                   s_dev;
346 };
347
348 struct nfs_lock_args {
349         struct nfs_fh *         fh;
350         struct file_lock *      fl;
351         struct nfs_seqid *      lock_seqid;
352         nfs4_stateid *          lock_stateid;
353         struct nfs_seqid *      open_seqid;
354         nfs4_stateid *          open_stateid;
355         struct nfs_lowner       lock_owner;
356         unsigned char           block : 1;
357         unsigned char           reclaim : 1;
358         unsigned char           new_lock_owner : 1;
359         struct nfs4_sequence_args       seq_args;
360 };
361
362 struct nfs_lock_res {
363         nfs4_stateid            stateid;
364         struct nfs_seqid *      lock_seqid;
365         struct nfs_seqid *      open_seqid;
366         struct nfs4_sequence_res        seq_res;
367 };
368
369 struct nfs_locku_args {
370         struct nfs_fh *         fh;
371         struct file_lock *      fl;
372         struct nfs_seqid *      seqid;
373         nfs4_stateid *          stateid;
374         struct nfs4_sequence_args       seq_args;
375 };
376
377 struct nfs_locku_res {
378         nfs4_stateid            stateid;
379         struct nfs_seqid *      seqid;
380         struct nfs4_sequence_res        seq_res;
381 };
382
383 struct nfs_lockt_args {
384         struct nfs_fh *         fh;
385         struct file_lock *      fl;
386         struct nfs_lowner       lock_owner;
387         struct nfs4_sequence_args       seq_args;
388 };
389
390 struct nfs_lockt_res {
391         struct file_lock *      denied; /* LOCK, LOCKT failed */
392         struct nfs4_sequence_res        seq_res;
393 };
394
395 struct nfs_release_lockowner_args {
396         struct nfs_lowner       lock_owner;
397 };
398
399 struct nfs4_delegreturnargs {
400         const struct nfs_fh *fhandle;
401         const nfs4_stateid *stateid;
402         const u32 * bitmask;
403         struct nfs4_sequence_args       seq_args;
404 };
405
406 struct nfs4_delegreturnres {
407         struct nfs_fattr * fattr;
408         const struct nfs_server *server;
409         struct nfs4_sequence_res        seq_res;
410 };
411
412 /*
413  * Arguments to the read call.
414  */
415 struct nfs_readargs {
416         struct nfs_fh *         fh;
417         struct nfs_open_context *context;
418         struct nfs_lock_context *lock_context;
419         __u64                   offset;
420         __u32                   count;
421         unsigned int            pgbase;
422         struct page **          pages;
423         struct nfs4_sequence_args       seq_args;
424 };
425
426 struct nfs_readres {
427         struct nfs_fattr *      fattr;
428         __u32                   count;
429         int                     eof;
430         struct nfs4_sequence_res        seq_res;
431 };
432
433 /*
434  * Arguments to the write call.
435  */
436 struct nfs_writeargs {
437         struct nfs_fh *         fh;
438         struct nfs_open_context *context;
439         struct nfs_lock_context *lock_context;
440         __u64                   offset;
441         __u32                   count;
442         enum nfs3_stable_how    stable;
443         unsigned int            pgbase;
444         struct page **          pages;
445         const u32 *             bitmask;
446         struct nfs4_sequence_args       seq_args;
447 };
448
449 struct nfs_writeverf {
450         enum nfs3_stable_how    committed;
451         __be32                  verifier[2];
452 };
453
454 struct nfs_writeres {
455         struct nfs_fattr *      fattr;
456         struct nfs_writeverf *  verf;
457         __u32                   count;
458         const struct nfs_server *server;
459         struct nfs4_sequence_res        seq_res;
460 };
461
462 /*
463  * Common arguments to the unlink call
464  */
465 struct nfs_removeargs {
466         const struct nfs_fh     *fh;
467         struct qstr             name;
468         const u32 *             bitmask;
469         struct nfs4_sequence_args       seq_args;
470 };
471
472 struct nfs_removeres {
473         const struct nfs_server *server;
474         struct nfs_fattr        *dir_attr;
475         struct nfs4_change_info cinfo;
476         struct nfs4_sequence_res        seq_res;
477 };
478
479 /*
480  * Common arguments to the rename call
481  */
482 struct nfs_renameargs {
483         const struct nfs_fh             *old_dir;
484         const struct nfs_fh             *new_dir;
485         const struct qstr               *old_name;
486         const struct qstr               *new_name;
487         const u32                       *bitmask;
488         struct nfs4_sequence_args       seq_args;
489 };
490
491 struct nfs_renameres {
492         const struct nfs_server         *server;
493         struct nfs4_change_info         old_cinfo;
494         struct nfs_fattr                *old_fattr;
495         struct nfs4_change_info         new_cinfo;
496         struct nfs_fattr                *new_fattr;
497         struct nfs4_sequence_res        seq_res;
498 };
499
500 /*
501  * Argument struct for decode_entry function
502  */
503 struct nfs_entry {
504         __u64                   ino;
505         __u64                   cookie,
506                                 prev_cookie;
507         const char *            name;
508         unsigned int            len;
509         int                     eof;
510         struct nfs_fh *         fh;
511         struct nfs_fattr *      fattr;
512         unsigned char           d_type;
513         struct nfs_server *     server;
514 };
515
516 /*
517  * The following types are for NFSv2 only.
518  */
519 struct nfs_sattrargs {
520         struct nfs_fh *         fh;
521         struct iattr *          sattr;
522 };
523
524 struct nfs_diropargs {
525         struct nfs_fh *         fh;
526         const char *            name;
527         unsigned int            len;
528 };
529
530 struct nfs_createargs {
531         struct nfs_fh *         fh;
532         const char *            name;
533         unsigned int            len;
534         struct iattr *          sattr;
535 };
536
537 struct nfs_setattrargs {
538         struct nfs_fh *                 fh;
539         nfs4_stateid                    stateid;
540         struct iattr *                  iap;
541         const struct nfs_server *       server; /* Needed for name mapping */
542         const u32 *                     bitmask;
543         struct nfs4_sequence_args       seq_args;
544 };
545
546 struct nfs_setaclargs {
547         struct nfs_fh *                 fh;
548         size_t                          acl_len;
549         unsigned int                    acl_pgbase;
550         struct page **                  acl_pages;
551         struct nfs4_sequence_args       seq_args;
552 };
553
554 struct nfs_setaclres {
555         struct nfs4_sequence_res        seq_res;
556 };
557
558 struct nfs_getaclargs {
559         struct nfs_fh *                 fh;
560         size_t                          acl_len;
561         unsigned int                    acl_pgbase;
562         struct page **                  acl_pages;
563         struct nfs4_sequence_args       seq_args;
564 };
565
566 struct nfs_getaclres {
567         size_t                          acl_len;
568         struct nfs4_sequence_res        seq_res;
569 };
570
571 struct nfs_setattrres {
572         struct nfs_fattr *              fattr;
573         const struct nfs_server *       server;
574         struct nfs4_sequence_res        seq_res;
575 };
576
577 struct nfs_linkargs {
578         struct nfs_fh *         fromfh;
579         struct nfs_fh *         tofh;
580         const char *            toname;
581         unsigned int            tolen;
582 };
583
584 struct nfs_symlinkargs {
585         struct nfs_fh *         fromfh;
586         const char *            fromname;
587         unsigned int            fromlen;
588         struct page **          pages;
589         unsigned int            pathlen;
590         struct iattr *          sattr;
591 };
592
593 struct nfs_readdirargs {
594         struct nfs_fh *         fh;
595         __u32                   cookie;
596         unsigned int            count;
597         struct page **          pages;
598 };
599
600 struct nfs3_getaclargs {
601         struct nfs_fh *         fh;
602         int                     mask;
603         struct page **          pages;
604 };
605
606 struct nfs3_setaclargs {
607         struct inode *          inode;
608         int                     mask;
609         struct posix_acl *      acl_access;
610         struct posix_acl *      acl_default;
611         size_t                  len;
612         unsigned int            npages;
613         struct page **          pages;
614 };
615
616 struct nfs_diropok {
617         struct nfs_fh *         fh;
618         struct nfs_fattr *      fattr;
619 };
620
621 struct nfs_readlinkargs {
622         struct nfs_fh *         fh;
623         unsigned int            pgbase;
624         unsigned int            pglen;
625         struct page **          pages;
626 };
627
628 struct nfs3_sattrargs {
629         struct nfs_fh *         fh;
630         struct iattr *          sattr;
631         unsigned int            guard;
632         struct timespec         guardtime;
633 };
634
635 struct nfs3_diropargs {
636         struct nfs_fh *         fh;
637         const char *            name;
638         unsigned int            len;
639 };
640
641 struct nfs3_accessargs {
642         struct nfs_fh *         fh;
643         __u32                   access;
644 };
645
646 struct nfs3_createargs {
647         struct nfs_fh *         fh;
648         const char *            name;
649         unsigned int            len;
650         struct iattr *          sattr;
651         enum nfs3_createmode    createmode;
652         __be32                  verifier[2];
653 };
654
655 struct nfs3_mkdirargs {
656         struct nfs_fh *         fh;
657         const char *            name;
658         unsigned int            len;
659         struct iattr *          sattr;
660 };
661
662 struct nfs3_symlinkargs {
663         struct nfs_fh *         fromfh;
664         const char *            fromname;
665         unsigned int            fromlen;
666         struct page **          pages;
667         unsigned int            pathlen;
668         struct iattr *          sattr;
669 };
670
671 struct nfs3_mknodargs {
672         struct nfs_fh *         fh;
673         const char *            name;
674         unsigned int            len;
675         enum nfs3_ftype         type;
676         struct iattr *          sattr;
677         dev_t                   rdev;
678 };
679
680 struct nfs3_linkargs {
681         struct nfs_fh *         fromfh;
682         struct nfs_fh *         tofh;
683         const char *            toname;
684         unsigned int            tolen;
685 };
686
687 struct nfs3_readdirargs {
688         struct nfs_fh *         fh;
689         __u64                   cookie;
690         __be32                  verf[2];
691         int                     plus;
692         unsigned int            count;
693         struct page **          pages;
694 };
695
696 struct nfs3_diropres {
697         struct nfs_fattr *      dir_attr;
698         struct nfs_fh *         fh;
699         struct nfs_fattr *      fattr;
700 };
701
702 struct nfs3_accessres {
703         struct nfs_fattr *      fattr;
704         __u32                   access;
705 };
706
707 struct nfs3_readlinkargs {
708         struct nfs_fh *         fh;
709         unsigned int            pgbase;
710         unsigned int            pglen;
711         struct page **          pages;
712 };
713
714 struct nfs3_linkres {
715         struct nfs_fattr *      dir_attr;
716         struct nfs_fattr *      fattr;
717 };
718
719 struct nfs3_readdirres {
720         struct nfs_fattr *      dir_attr;
721         __be32 *                verf;
722         int                     plus;
723 };
724
725 struct nfs3_getaclres {
726         struct nfs_fattr *      fattr;
727         int                     mask;
728         unsigned int            acl_access_count;
729         unsigned int            acl_default_count;
730         struct posix_acl *      acl_access;
731         struct posix_acl *      acl_default;
732 };
733
734 #ifdef CONFIG_NFS_V4
735
736 typedef u64 clientid4;
737
738 struct nfs4_accessargs {
739         const struct nfs_fh *           fh;
740         const u32 *                     bitmask;
741         u32                             access;
742         struct nfs4_sequence_args       seq_args;
743 };
744
745 struct nfs4_accessres {
746         const struct nfs_server *       server;
747         struct nfs_fattr *              fattr;
748         u32                             supported;
749         u32                             access;
750         struct nfs4_sequence_res        seq_res;
751 };
752
753 struct nfs4_create_arg {
754         u32                             ftype;
755         union {
756                 struct {
757                         struct page **  pages;
758                         unsigned int    len;
759                 } symlink;   /* NF4LNK */
760                 struct {
761                         u32             specdata1;
762                         u32             specdata2;
763                 } device;    /* NF4BLK, NF4CHR */
764         } u;
765         const struct qstr *             name;
766         const struct nfs_server *       server;
767         const struct iattr *            attrs;
768         const struct nfs_fh *           dir_fh;
769         const u32 *                     bitmask;
770         struct nfs4_sequence_args       seq_args;
771 };
772
773 struct nfs4_create_res {
774         const struct nfs_server *       server;
775         struct nfs_fh *                 fh;
776         struct nfs_fattr *              fattr;
777         struct nfs4_change_info         dir_cinfo;
778         struct nfs_fattr *              dir_fattr;
779         struct nfs4_sequence_res        seq_res;
780 };
781
782 struct nfs4_fsinfo_arg {
783         const struct nfs_fh *           fh;
784         const u32 *                     bitmask;
785         struct nfs4_sequence_args       seq_args;
786 };
787
788 struct nfs4_fsinfo_res {
789         struct nfs_fsinfo              *fsinfo;
790         struct nfs4_sequence_res        seq_res;
791 };
792
793 struct nfs4_getattr_arg {
794         const struct nfs_fh *           fh;
795         const u32 *                     bitmask;
796         struct nfs4_sequence_args       seq_args;
797 };
798
799 struct nfs4_getattr_res {
800         const struct nfs_server *       server;
801         struct nfs_fattr *              fattr;
802         struct nfs4_sequence_res        seq_res;
803 };
804
805 struct nfs4_link_arg {
806         const struct nfs_fh *           fh;
807         const struct nfs_fh *           dir_fh;
808         const struct qstr *             name;
809         const u32 *                     bitmask;
810         struct nfs4_sequence_args       seq_args;
811 };
812
813 struct nfs4_link_res {
814         const struct nfs_server *       server;
815         struct nfs_fattr *              fattr;
816         struct nfs4_change_info         cinfo;
817         struct nfs_fattr *              dir_attr;
818         struct nfs4_sequence_res        seq_res;
819 };
820
821
822 struct nfs4_lookup_arg {
823         const struct nfs_fh *           dir_fh;
824         const struct qstr *             name;
825         const u32 *                     bitmask;
826         struct nfs4_sequence_args       seq_args;
827 };
828
829 struct nfs4_lookup_res {
830         const struct nfs_server *       server;
831         struct nfs_fattr *              fattr;
832         struct nfs_fh *                 fh;
833         struct nfs4_sequence_res        seq_res;
834 };
835
836 struct nfs4_lookup_root_arg {
837         const u32 *                     bitmask;
838         struct nfs4_sequence_args       seq_args;
839 };
840
841 struct nfs4_pathconf_arg {
842         const struct nfs_fh *           fh;
843         const u32 *                     bitmask;
844         struct nfs4_sequence_args       seq_args;
845 };
846
847 struct nfs4_pathconf_res {
848         struct nfs_pathconf            *pathconf;
849         struct nfs4_sequence_res        seq_res;
850 };
851
852 struct nfs4_readdir_arg {
853         const struct nfs_fh *           fh;
854         u64                             cookie;
855         nfs4_verifier                   verifier;
856         u32                             count;
857         struct page **                  pages;  /* zero-copy data */
858         unsigned int                    pgbase; /* zero-copy data */
859         const u32 *                     bitmask;
860         int                             plus;
861         struct nfs4_sequence_args       seq_args;
862 };
863
864 struct nfs4_readdir_res {
865         nfs4_verifier                   verifier;
866         unsigned int                    pgbase;
867         struct nfs4_sequence_res        seq_res;
868 };
869
870 struct nfs4_readlink {
871         const struct nfs_fh *           fh;
872         unsigned int                    pgbase;
873         unsigned int                    pglen;   /* zero-copy data */
874         struct page **                  pages;   /* zero-copy data */
875         struct nfs4_sequence_args       seq_args;
876 };
877
878 struct nfs4_readlink_res {
879         struct nfs4_sequence_res        seq_res;
880 };
881
882 #define NFS4_SETCLIENTID_NAMELEN        (127)
883 struct nfs4_setclientid {
884         const nfs4_verifier *           sc_verifier;
885         unsigned int                    sc_name_len;
886         char                            sc_name[NFS4_SETCLIENTID_NAMELEN + 1];
887         u32                             sc_prog;
888         unsigned int                    sc_netid_len;
889         char                            sc_netid[RPCBIND_MAXNETIDLEN + 1];
890         unsigned int                    sc_uaddr_len;
891         char                            sc_uaddr[RPCBIND_MAXUADDRLEN + 1];
892         u32                             sc_cb_ident;
893 };
894
895 struct nfs4_setclientid_res {
896         u64                             clientid;
897         nfs4_verifier                   confirm;
898 };
899
900 struct nfs4_statfs_arg {
901         const struct nfs_fh *           fh;
902         const u32 *                     bitmask;
903         struct nfs4_sequence_args       seq_args;
904 };
905
906 struct nfs4_statfs_res {
907         struct nfs_fsstat              *fsstat;
908         struct nfs4_sequence_res        seq_res;
909 };
910
911 struct nfs4_server_caps_arg {
912         struct nfs_fh                  *fhandle;
913         struct nfs4_sequence_args       seq_args;
914 };
915
916 struct nfs4_server_caps_res {
917         u32                             attr_bitmask[2];
918         u32                             acl_bitmask;
919         u32                             has_links;
920         u32                             has_symlinks;
921         struct nfs4_sequence_res        seq_res;
922 };
923
924 struct nfs4_string {
925         unsigned int len;
926         char *data;
927 };
928
929 #define NFS4_PATHNAME_MAXCOMPONENTS 512
930 struct nfs4_pathname {
931         unsigned int ncomponents;
932         struct nfs4_string components[NFS4_PATHNAME_MAXCOMPONENTS];
933 };
934
935 #define NFS4_FS_LOCATION_MAXSERVERS 10
936 struct nfs4_fs_location {
937         unsigned int nservers;
938         struct nfs4_string servers[NFS4_FS_LOCATION_MAXSERVERS];
939         struct nfs4_pathname rootpath;
940 };
941
942 #define NFS4_FS_LOCATIONS_MAXENTRIES 10
943 struct nfs4_fs_locations {
944         struct nfs_fattr fattr;
945         const struct nfs_server *server;
946         struct nfs4_pathname fs_path;
947         int nlocations;
948         struct nfs4_fs_location locations[NFS4_FS_LOCATIONS_MAXENTRIES];
949 };
950
951 struct nfs4_fs_locations_arg {
952         const struct nfs_fh *dir_fh;
953         const struct qstr *name;
954         struct page *page;
955         const u32 *bitmask;
956         struct nfs4_sequence_args       seq_args;
957 };
958
959 struct nfs4_fs_locations_res {
960         struct nfs4_fs_locations       *fs_locations;
961         struct nfs4_sequence_res        seq_res;
962 };
963
964 #endif /* CONFIG_NFS_V4 */
965
966 struct nfstime4 {
967         u64     seconds;
968         u32     nseconds;
969 };
970
971 #ifdef CONFIG_NFS_V4_1
972 struct nfs_impl_id4 {
973         u32             domain_len;
974         char            *domain;
975         u32             name_len;
976         char            *name;
977         struct nfstime4 date;
978 };
979
980 #define NFS4_EXCHANGE_ID_LEN    (48)
981 struct nfs41_exchange_id_args {
982         struct nfs_client               *client;
983         nfs4_verifier                   *verifier;
984         unsigned int                    id_len;
985         char                            id[NFS4_EXCHANGE_ID_LEN];
986         u32                             flags;
987 };
988
989 struct server_owner {
990         uint64_t                        minor_id;
991         uint32_t                        major_id_sz;
992         char                            major_id[NFS4_OPAQUE_LIMIT];
993 };
994
995 struct server_scope {
996         uint32_t                        server_scope_sz;
997         char                            server_scope[NFS4_OPAQUE_LIMIT];
998 };
999
1000 struct nfs41_exchange_id_res {
1001         struct nfs_client               *client;
1002         u32                             flags;
1003 };
1004
1005 struct nfs41_create_session_args {
1006         struct nfs_client              *client;
1007         uint32_t                        flags;
1008         uint32_t                        cb_program;
1009         struct nfs4_channel_attrs       fc_attrs;       /* Fore Channel */
1010         struct nfs4_channel_attrs       bc_attrs;       /* Back Channel */
1011 };
1012
1013 struct nfs41_create_session_res {
1014         struct nfs_client              *client;
1015 };
1016
1017 struct nfs41_reclaim_complete_args {
1018         /* In the future extend to include curr_fh for use with migration */
1019         unsigned char                   one_fs:1;
1020         struct nfs4_sequence_args       seq_args;
1021 };
1022
1023 struct nfs41_reclaim_complete_res {
1024         struct nfs4_sequence_res        seq_res;
1025 };
1026 #endif /* CONFIG_NFS_V4_1 */
1027
1028 struct nfs_page;
1029
1030 #define NFS_PAGEVEC_SIZE        (8U)
1031
1032 struct nfs_read_data {
1033         int                     flags;
1034         struct rpc_task         task;
1035         struct inode            *inode;
1036         struct rpc_cred         *cred;
1037         struct nfs_fattr        fattr;  /* fattr storage */
1038         struct list_head        pages;  /* Coalesced read requests */
1039         struct nfs_page         *req;   /* multi ops per nfs_page */
1040         struct page             **pagevec;
1041         unsigned int            npages; /* Max length of pagevec */
1042         struct nfs_readargs args;
1043         struct nfs_readres  res;
1044         unsigned long           timestamp;      /* For lease renewal */
1045         struct pnfs_layout_segment *lseg;
1046         struct nfs_client       *ds_clp;        /* pNFS data server */
1047         const struct rpc_call_ops *mds_ops;
1048         int (*read_done_cb) (struct rpc_task *task, struct nfs_read_data *data);
1049         __u64                   mds_offset;
1050         struct page             *page_array[NFS_PAGEVEC_SIZE];
1051 };
1052
1053 struct nfs_write_data {
1054         int                     flags;
1055         struct rpc_task         task;
1056         struct inode            *inode;
1057         struct rpc_cred         *cred;
1058         struct nfs_fattr        fattr;
1059         struct nfs_writeverf    verf;
1060         struct list_head        pages;          /* Coalesced requests we wish to flush */
1061         struct nfs_page         *req;           /* multi ops per nfs_page */
1062         struct page             **pagevec;
1063         unsigned int            npages;         /* Max length of pagevec */
1064         struct nfs_writeargs    args;           /* argument struct */
1065         struct nfs_writeres     res;            /* result struct */
1066         struct pnfs_layout_segment *lseg;
1067         struct nfs_client       *ds_clp;        /* pNFS data server */
1068         int                     ds_commit_index;
1069         const struct rpc_call_ops *mds_ops;
1070         int (*write_done_cb) (struct rpc_task *task, struct nfs_write_data *data);
1071 #ifdef CONFIG_NFS_V4
1072         unsigned long           timestamp;      /* For lease renewal */
1073 #endif
1074         __u64                   mds_offset;     /* Filelayout dense stripe */
1075         struct page             *page_array[NFS_PAGEVEC_SIZE];
1076 };
1077
1078 struct nfs_access_entry;
1079 struct nfs_client;
1080 struct rpc_timeout;
1081
1082 /*
1083  * RPC procedure vector for NFSv2/NFSv3 demuxing
1084  */
1085 struct nfs_rpc_ops {
1086         u32     version;                /* Protocol version */
1087         const struct dentry_operations *dentry_ops;
1088         const struct inode_operations *dir_inode_ops;
1089         const struct inode_operations *file_inode_ops;
1090
1091         int     (*getroot) (struct nfs_server *, struct nfs_fh *,
1092                             struct nfs_fsinfo *);
1093         int     (*lookupfh)(struct nfs_server *, struct nfs_fh *,
1094                             struct qstr *, struct nfs_fh *,
1095                             struct nfs_fattr *);
1096         int     (*getattr) (struct nfs_server *, struct nfs_fh *,
1097                             struct nfs_fattr *);
1098         int     (*setattr) (struct dentry *, struct nfs_fattr *,
1099                             struct iattr *);
1100         int     (*lookup)  (struct inode *, struct qstr *,
1101                             struct nfs_fh *, struct nfs_fattr *);
1102         int     (*access)  (struct inode *, struct nfs_access_entry *);
1103         int     (*readlink)(struct inode *, struct page *, unsigned int,
1104                             unsigned int);
1105         int     (*create)  (struct inode *, struct dentry *,
1106                             struct iattr *, int, struct nfs_open_context *);
1107         int     (*remove)  (struct inode *, struct qstr *);
1108         void    (*unlink_setup)  (struct rpc_message *, struct inode *dir);
1109         int     (*unlink_done) (struct rpc_task *, struct inode *);
1110         int     (*rename)  (struct inode *, struct qstr *,
1111                             struct inode *, struct qstr *);
1112         void    (*rename_setup)  (struct rpc_message *msg, struct inode *dir);
1113         int     (*rename_done) (struct rpc_task *task, struct inode *old_dir, struct inode *new_dir);
1114         int     (*link)    (struct inode *, struct inode *, struct qstr *);
1115         int     (*symlink) (struct inode *, struct dentry *, struct page *,
1116                             unsigned int, struct iattr *);
1117         int     (*mkdir)   (struct inode *, struct dentry *, struct iattr *);
1118         int     (*rmdir)   (struct inode *, struct qstr *);
1119         int     (*readdir) (struct dentry *, struct rpc_cred *,
1120                             u64, struct page **, unsigned int, int);
1121         int     (*mknod)   (struct inode *, struct dentry *, struct iattr *,
1122                             dev_t);
1123         int     (*statfs)  (struct nfs_server *, struct nfs_fh *,
1124                             struct nfs_fsstat *);
1125         int     (*fsinfo)  (struct nfs_server *, struct nfs_fh *,
1126                             struct nfs_fsinfo *);
1127         int     (*pathconf) (struct nfs_server *, struct nfs_fh *,
1128                              struct nfs_pathconf *);
1129         int     (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
1130         int     (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int);
1131         void    (*read_setup)   (struct nfs_read_data *, struct rpc_message *);
1132         int     (*read_done)  (struct rpc_task *, struct nfs_read_data *);
1133         void    (*write_setup)  (struct nfs_write_data *, struct rpc_message *);
1134         int     (*write_done)  (struct rpc_task *, struct nfs_write_data *);
1135         void    (*commit_setup) (struct nfs_write_data *, struct rpc_message *);
1136         int     (*commit_done) (struct rpc_task *, struct nfs_write_data *);
1137         int     (*lock)(struct file *, int, struct file_lock *);
1138         int     (*lock_check_bounds)(const struct file_lock *);
1139         void    (*clear_acl_cache)(struct inode *);
1140         void    (*close_context)(struct nfs_open_context *ctx, int);
1141         struct inode * (*open_context) (struct inode *dir,
1142                                 struct nfs_open_context *ctx,
1143                                 int open_flags,
1144                                 struct iattr *iattr);
1145         int     (*init_client) (struct nfs_client *, const struct rpc_timeout *,
1146                                 const char *, rpc_authflavor_t, int);
1147 };
1148
1149 /*
1150  *      NFS_CALL(getattr, inode, (fattr));
1151  * into
1152  *      NFS_PROTO(inode)->getattr(fattr);
1153  */
1154 #define NFS_CALL(op, inode, args)       NFS_PROTO(inode)->op args
1155
1156 /*
1157  * Function vectors etc. for the NFS client
1158  */
1159 extern const struct nfs_rpc_ops nfs_v2_clientops;
1160 extern const struct nfs_rpc_ops nfs_v3_clientops;
1161 extern const struct nfs_rpc_ops nfs_v4_clientops;
1162 extern struct rpc_version       nfs_version2;
1163 extern struct rpc_version       nfs_version3;
1164 extern struct rpc_version       nfs_version4;
1165
1166 extern struct rpc_version       nfsacl_version3;
1167 extern struct rpc_program       nfsacl_program;
1168
1169 #endif