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