Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[pandora-kernel.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         struct page **pages;
199         __u32 pglen;
200         __u32 len;
201 };
202
203 struct pnfs_layout_range {
204         u32 iomode;
205         u64 offset;
206         u64 length;
207 };
208
209 struct nfs4_layoutget_args {
210         __u32 type;
211         struct pnfs_layout_range range;
212         __u64 minlength;
213         __u32 maxcount;
214         struct inode *inode;
215         struct nfs_open_context *ctx;
216         struct nfs4_sequence_args seq_args;
217         nfs4_stateid stateid;
218         struct nfs4_layoutdriver_data layout;
219 };
220
221 struct nfs4_layoutget_res {
222         __u32 return_on_close;
223         struct pnfs_layout_range range;
224         __u32 type;
225         nfs4_stateid stateid;
226         struct nfs4_sequence_res seq_res;
227         struct nfs4_layoutdriver_data *layoutp;
228 };
229
230 struct nfs4_layoutget {
231         struct nfs4_layoutget_args args;
232         struct nfs4_layoutget_res res;
233         struct pnfs_layout_segment **lsegpp;
234 };
235
236 struct nfs4_getdeviceinfo_args {
237         struct pnfs_device *pdev;
238         struct nfs4_sequence_args seq_args;
239 };
240
241 struct nfs4_getdeviceinfo_res {
242         struct pnfs_device *pdev;
243         struct nfs4_sequence_res seq_res;
244 };
245
246 struct nfs4_layoutcommit_args {
247         nfs4_stateid stateid;
248         __u64 lastbytewritten;
249         struct inode *inode;
250         const u32 *bitmask;
251         struct nfs4_sequence_args seq_args;
252 };
253
254 struct nfs4_layoutcommit_res {
255         struct nfs_fattr *fattr;
256         const struct nfs_server *server;
257         struct nfs4_sequence_res seq_res;
258 };
259
260 struct nfs4_layoutcommit_data {
261         struct rpc_task task;
262         struct nfs_fattr fattr;
263         struct pnfs_layout_segment *lseg;
264         struct rpc_cred *cred;
265         struct nfs4_layoutcommit_args args;
266         struct nfs4_layoutcommit_res res;
267 };
268
269 /*
270  * Arguments to the open call.
271  */
272 struct nfs_openargs {
273         const struct nfs_fh *   fh;
274         struct nfs_seqid *      seqid;
275         int                     open_flags;
276         fmode_t                 fmode;
277         __u64                   clientid;
278         __u64                   id;
279         union {
280                 struct {
281                         struct iattr *  attrs;    /* UNCHECKED, GUARDED */
282                         nfs4_verifier   verifier; /* EXCLUSIVE */
283                 };
284                 nfs4_stateid    delegation;             /* CLAIM_DELEGATE_CUR */
285                 fmode_t         delegation_type;        /* CLAIM_PREVIOUS */
286         } u;
287         const struct qstr *     name;
288         const struct nfs_server *server;         /* Needed for ID mapping */
289         const u32 *             bitmask;
290         __u32                   claim;
291         struct nfs4_sequence_args       seq_args;
292 };
293
294 struct nfs_openres {
295         nfs4_stateid            stateid;
296         struct nfs_fh           fh;
297         struct nfs4_change_info cinfo;
298         __u32                   rflags;
299         struct nfs_fattr *      f_attr;
300         struct nfs_fattr *      dir_attr;
301         struct nfs_seqid *      seqid;
302         const struct nfs_server *server;
303         fmode_t                 delegation_type;
304         nfs4_stateid            delegation;
305         __u32                   do_recall;
306         __u64                   maxsize;
307         __u32                   attrset[NFS4_BITMAP_SIZE];
308         struct nfs4_sequence_res        seq_res;
309 };
310
311 /*
312  * Arguments to the open_confirm call.
313  */
314 struct nfs_open_confirmargs {
315         const struct nfs_fh *   fh;
316         nfs4_stateid *          stateid;
317         struct nfs_seqid *      seqid;
318 };
319
320 struct nfs_open_confirmres {
321         nfs4_stateid            stateid;
322         struct nfs_seqid *      seqid;
323 };
324
325 /*
326  * Arguments to the close call.
327  */
328 struct nfs_closeargs {
329         struct nfs_fh *         fh;
330         nfs4_stateid *          stateid;
331         struct nfs_seqid *      seqid;
332         fmode_t                 fmode;
333         const u32 *             bitmask;
334         struct nfs4_sequence_args       seq_args;
335 };
336
337 struct nfs_closeres {
338         nfs4_stateid            stateid;
339         struct nfs_fattr *      fattr;
340         struct nfs_seqid *      seqid;
341         const struct nfs_server *server;
342         struct nfs4_sequence_res        seq_res;
343 };
344 /*
345  *  * Arguments to the lock,lockt, and locku call.
346  *   */
347 struct nfs_lowner {
348         __u64                   clientid;
349         __u64                   id;
350         dev_t                   s_dev;
351 };
352
353 struct nfs_lock_args {
354         struct nfs_fh *         fh;
355         struct file_lock *      fl;
356         struct nfs_seqid *      lock_seqid;
357         nfs4_stateid *          lock_stateid;
358         struct nfs_seqid *      open_seqid;
359         nfs4_stateid *          open_stateid;
360         struct nfs_lowner       lock_owner;
361         unsigned char           block : 1;
362         unsigned char           reclaim : 1;
363         unsigned char           new_lock_owner : 1;
364         struct nfs4_sequence_args       seq_args;
365 };
366
367 struct nfs_lock_res {
368         nfs4_stateid            stateid;
369         struct nfs_seqid *      lock_seqid;
370         struct nfs_seqid *      open_seqid;
371         struct nfs4_sequence_res        seq_res;
372 };
373
374 struct nfs_locku_args {
375         struct nfs_fh *         fh;
376         struct file_lock *      fl;
377         struct nfs_seqid *      seqid;
378         nfs4_stateid *          stateid;
379         struct nfs4_sequence_args       seq_args;
380 };
381
382 struct nfs_locku_res {
383         nfs4_stateid            stateid;
384         struct nfs_seqid *      seqid;
385         struct nfs4_sequence_res        seq_res;
386 };
387
388 struct nfs_lockt_args {
389         struct nfs_fh *         fh;
390         struct file_lock *      fl;
391         struct nfs_lowner       lock_owner;
392         struct nfs4_sequence_args       seq_args;
393 };
394
395 struct nfs_lockt_res {
396         struct file_lock *      denied; /* LOCK, LOCKT failed */
397         struct nfs4_sequence_res        seq_res;
398 };
399
400 struct nfs_release_lockowner_args {
401         struct nfs_lowner       lock_owner;
402 };
403
404 struct nfs4_delegreturnargs {
405         const struct nfs_fh *fhandle;
406         const nfs4_stateid *stateid;
407         const u32 * bitmask;
408         struct nfs4_sequence_args       seq_args;
409 };
410
411 struct nfs4_delegreturnres {
412         struct nfs_fattr * fattr;
413         const struct nfs_server *server;
414         struct nfs4_sequence_res        seq_res;
415 };
416
417 /*
418  * Arguments to the read call.
419  */
420 struct nfs_readargs {
421         struct nfs_fh *         fh;
422         struct nfs_open_context *context;
423         struct nfs_lock_context *lock_context;
424         __u64                   offset;
425         __u32                   count;
426         unsigned int            pgbase;
427         struct page **          pages;
428         struct nfs4_sequence_args       seq_args;
429 };
430
431 struct nfs_readres {
432         struct nfs_fattr *      fattr;
433         __u32                   count;
434         int                     eof;
435         struct nfs4_sequence_res        seq_res;
436 };
437
438 /*
439  * Arguments to the write call.
440  */
441 struct nfs_writeargs {
442         struct nfs_fh *         fh;
443         struct nfs_open_context *context;
444         struct nfs_lock_context *lock_context;
445         __u64                   offset;
446         __u32                   count;
447         enum nfs3_stable_how    stable;
448         unsigned int            pgbase;
449         struct page **          pages;
450         const u32 *             bitmask;
451         struct nfs4_sequence_args       seq_args;
452 };
453
454 struct nfs_writeverf {
455         enum nfs3_stable_how    committed;
456         __be32                  verifier[2];
457 };
458
459 struct nfs_writeres {
460         struct nfs_fattr *      fattr;
461         struct nfs_writeverf *  verf;
462         __u32                   count;
463         const struct nfs_server *server;
464         struct nfs4_sequence_res        seq_res;
465 };
466
467 /*
468  * Common arguments to the unlink call
469  */
470 struct nfs_removeargs {
471         const struct nfs_fh     *fh;
472         struct qstr             name;
473         const u32 *             bitmask;
474         struct nfs4_sequence_args       seq_args;
475 };
476
477 struct nfs_removeres {
478         const struct nfs_server *server;
479         struct nfs_fattr        *dir_attr;
480         struct nfs4_change_info cinfo;
481         struct nfs4_sequence_res        seq_res;
482 };
483
484 /*
485  * Common arguments to the rename call
486  */
487 struct nfs_renameargs {
488         const struct nfs_fh             *old_dir;
489         const struct nfs_fh             *new_dir;
490         const struct qstr               *old_name;
491         const struct qstr               *new_name;
492         const u32                       *bitmask;
493         struct nfs4_sequence_args       seq_args;
494 };
495
496 struct nfs_renameres {
497         const struct nfs_server         *server;
498         struct nfs4_change_info         old_cinfo;
499         struct nfs_fattr                *old_fattr;
500         struct nfs4_change_info         new_cinfo;
501         struct nfs_fattr                *new_fattr;
502         struct nfs4_sequence_res        seq_res;
503 };
504
505 /*
506  * Argument struct for decode_entry function
507  */
508 struct nfs_entry {
509         __u64                   ino;
510         __u64                   cookie,
511                                 prev_cookie;
512         const char *            name;
513         unsigned int            len;
514         int                     eof;
515         struct nfs_fh *         fh;
516         struct nfs_fattr *      fattr;
517         unsigned char           d_type;
518         struct nfs_server *     server;
519 };
520
521 /*
522  * The following types are for NFSv2 only.
523  */
524 struct nfs_sattrargs {
525         struct nfs_fh *         fh;
526         struct iattr *          sattr;
527 };
528
529 struct nfs_diropargs {
530         struct nfs_fh *         fh;
531         const char *            name;
532         unsigned int            len;
533 };
534
535 struct nfs_createargs {
536         struct nfs_fh *         fh;
537         const char *            name;
538         unsigned int            len;
539         struct iattr *          sattr;
540 };
541
542 struct nfs_setattrargs {
543         struct nfs_fh *                 fh;
544         nfs4_stateid                    stateid;
545         struct iattr *                  iap;
546         const struct nfs_server *       server; /* Needed for name mapping */
547         const u32 *                     bitmask;
548         struct nfs4_sequence_args       seq_args;
549 };
550
551 struct nfs_setaclargs {
552         struct nfs_fh *                 fh;
553         size_t                          acl_len;
554         unsigned int                    acl_pgbase;
555         struct page **                  acl_pages;
556         struct nfs4_sequence_args       seq_args;
557 };
558
559 struct nfs_setaclres {
560         struct nfs4_sequence_res        seq_res;
561 };
562
563 struct nfs_getaclargs {
564         struct nfs_fh *                 fh;
565         size_t                          acl_len;
566         unsigned int                    acl_pgbase;
567         struct page **                  acl_pages;
568         struct nfs4_sequence_args       seq_args;
569 };
570
571 struct nfs_getaclres {
572         size_t                          acl_len;
573         struct nfs4_sequence_res        seq_res;
574 };
575
576 struct nfs_setattrres {
577         struct nfs_fattr *              fattr;
578         const struct nfs_server *       server;
579         struct nfs4_sequence_res        seq_res;
580 };
581
582 struct nfs_linkargs {
583         struct nfs_fh *         fromfh;
584         struct nfs_fh *         tofh;
585         const char *            toname;
586         unsigned int            tolen;
587 };
588
589 struct nfs_symlinkargs {
590         struct nfs_fh *         fromfh;
591         const char *            fromname;
592         unsigned int            fromlen;
593         struct page **          pages;
594         unsigned int            pathlen;
595         struct iattr *          sattr;
596 };
597
598 struct nfs_readdirargs {
599         struct nfs_fh *         fh;
600         __u32                   cookie;
601         unsigned int            count;
602         struct page **          pages;
603 };
604
605 struct nfs3_getaclargs {
606         struct nfs_fh *         fh;
607         int                     mask;
608         struct page **          pages;
609 };
610
611 struct nfs3_setaclargs {
612         struct inode *          inode;
613         int                     mask;
614         struct posix_acl *      acl_access;
615         struct posix_acl *      acl_default;
616         size_t                  len;
617         unsigned int            npages;
618         struct page **          pages;
619 };
620
621 struct nfs_diropok {
622         struct nfs_fh *         fh;
623         struct nfs_fattr *      fattr;
624 };
625
626 struct nfs_readlinkargs {
627         struct nfs_fh *         fh;
628         unsigned int            pgbase;
629         unsigned int            pglen;
630         struct page **          pages;
631 };
632
633 struct nfs3_sattrargs {
634         struct nfs_fh *         fh;
635         struct iattr *          sattr;
636         unsigned int            guard;
637         struct timespec         guardtime;
638 };
639
640 struct nfs3_diropargs {
641         struct nfs_fh *         fh;
642         const char *            name;
643         unsigned int            len;
644 };
645
646 struct nfs3_accessargs {
647         struct nfs_fh *         fh;
648         __u32                   access;
649 };
650
651 struct nfs3_createargs {
652         struct nfs_fh *         fh;
653         const char *            name;
654         unsigned int            len;
655         struct iattr *          sattr;
656         enum nfs3_createmode    createmode;
657         __be32                  verifier[2];
658 };
659
660 struct nfs3_mkdirargs {
661         struct nfs_fh *         fh;
662         const char *            name;
663         unsigned int            len;
664         struct iattr *          sattr;
665 };
666
667 struct nfs3_symlinkargs {
668         struct nfs_fh *         fromfh;
669         const char *            fromname;
670         unsigned int            fromlen;
671         struct page **          pages;
672         unsigned int            pathlen;
673         struct iattr *          sattr;
674 };
675
676 struct nfs3_mknodargs {
677         struct nfs_fh *         fh;
678         const char *            name;
679         unsigned int            len;
680         enum nfs3_ftype         type;
681         struct iattr *          sattr;
682         dev_t                   rdev;
683 };
684
685 struct nfs3_linkargs {
686         struct nfs_fh *         fromfh;
687         struct nfs_fh *         tofh;
688         const char *            toname;
689         unsigned int            tolen;
690 };
691
692 struct nfs3_readdirargs {
693         struct nfs_fh *         fh;
694         __u64                   cookie;
695         __be32                  verf[2];
696         int                     plus;
697         unsigned int            count;
698         struct page **          pages;
699 };
700
701 struct nfs3_diropres {
702         struct nfs_fattr *      dir_attr;
703         struct nfs_fh *         fh;
704         struct nfs_fattr *      fattr;
705 };
706
707 struct nfs3_accessres {
708         struct nfs_fattr *      fattr;
709         __u32                   access;
710 };
711
712 struct nfs3_readlinkargs {
713         struct nfs_fh *         fh;
714         unsigned int            pgbase;
715         unsigned int            pglen;
716         struct page **          pages;
717 };
718
719 struct nfs3_linkres {
720         struct nfs_fattr *      dir_attr;
721         struct nfs_fattr *      fattr;
722 };
723
724 struct nfs3_readdirres {
725         struct nfs_fattr *      dir_attr;
726         __be32 *                verf;
727         int                     plus;
728 };
729
730 struct nfs3_getaclres {
731         struct nfs_fattr *      fattr;
732         int                     mask;
733         unsigned int            acl_access_count;
734         unsigned int            acl_default_count;
735         struct posix_acl *      acl_access;
736         struct posix_acl *      acl_default;
737 };
738
739 #ifdef CONFIG_NFS_V4
740
741 typedef u64 clientid4;
742
743 struct nfs4_accessargs {
744         const struct nfs_fh *           fh;
745         const u32 *                     bitmask;
746         u32                             access;
747         struct nfs4_sequence_args       seq_args;
748 };
749
750 struct nfs4_accessres {
751         const struct nfs_server *       server;
752         struct nfs_fattr *              fattr;
753         u32                             supported;
754         u32                             access;
755         struct nfs4_sequence_res        seq_res;
756 };
757
758 struct nfs4_create_arg {
759         u32                             ftype;
760         union {
761                 struct {
762                         struct page **  pages;
763                         unsigned int    len;
764                 } symlink;   /* NF4LNK */
765                 struct {
766                         u32             specdata1;
767                         u32             specdata2;
768                 } device;    /* NF4BLK, NF4CHR */
769         } u;
770         const struct qstr *             name;
771         const struct nfs_server *       server;
772         const struct iattr *            attrs;
773         const struct nfs_fh *           dir_fh;
774         const u32 *                     bitmask;
775         struct nfs4_sequence_args       seq_args;
776 };
777
778 struct nfs4_create_res {
779         const struct nfs_server *       server;
780         struct nfs_fh *                 fh;
781         struct nfs_fattr *              fattr;
782         struct nfs4_change_info         dir_cinfo;
783         struct nfs_fattr *              dir_fattr;
784         struct nfs4_sequence_res        seq_res;
785 };
786
787 struct nfs4_fsinfo_arg {
788         const struct nfs_fh *           fh;
789         const u32 *                     bitmask;
790         struct nfs4_sequence_args       seq_args;
791 };
792
793 struct nfs4_fsinfo_res {
794         struct nfs_fsinfo              *fsinfo;
795         struct nfs4_sequence_res        seq_res;
796 };
797
798 struct nfs4_getattr_arg {
799         const struct nfs_fh *           fh;
800         const u32 *                     bitmask;
801         struct nfs4_sequence_args       seq_args;
802 };
803
804 struct nfs4_getattr_res {
805         const struct nfs_server *       server;
806         struct nfs_fattr *              fattr;
807         struct nfs4_sequence_res        seq_res;
808 };
809
810 struct nfs4_link_arg {
811         const struct nfs_fh *           fh;
812         const struct nfs_fh *           dir_fh;
813         const struct qstr *             name;
814         const u32 *                     bitmask;
815         struct nfs4_sequence_args       seq_args;
816 };
817
818 struct nfs4_link_res {
819         const struct nfs_server *       server;
820         struct nfs_fattr *              fattr;
821         struct nfs4_change_info         cinfo;
822         struct nfs_fattr *              dir_attr;
823         struct nfs4_sequence_res        seq_res;
824 };
825
826
827 struct nfs4_lookup_arg {
828         const struct nfs_fh *           dir_fh;
829         const struct qstr *             name;
830         const u32 *                     bitmask;
831         struct nfs4_sequence_args       seq_args;
832 };
833
834 struct nfs4_lookup_res {
835         const struct nfs_server *       server;
836         struct nfs_fattr *              fattr;
837         struct nfs_fh *                 fh;
838         struct nfs4_sequence_res        seq_res;
839 };
840
841 struct nfs4_lookup_root_arg {
842         const u32 *                     bitmask;
843         struct nfs4_sequence_args       seq_args;
844 };
845
846 struct nfs4_pathconf_arg {
847         const struct nfs_fh *           fh;
848         const u32 *                     bitmask;
849         struct nfs4_sequence_args       seq_args;
850 };
851
852 struct nfs4_pathconf_res {
853         struct nfs_pathconf            *pathconf;
854         struct nfs4_sequence_res        seq_res;
855 };
856
857 struct nfs4_readdir_arg {
858         const struct nfs_fh *           fh;
859         u64                             cookie;
860         nfs4_verifier                   verifier;
861         u32                             count;
862         struct page **                  pages;  /* zero-copy data */
863         unsigned int                    pgbase; /* zero-copy data */
864         const u32 *                     bitmask;
865         int                             plus;
866         struct nfs4_sequence_args       seq_args;
867 };
868
869 struct nfs4_readdir_res {
870         nfs4_verifier                   verifier;
871         unsigned int                    pgbase;
872         struct nfs4_sequence_res        seq_res;
873 };
874
875 struct nfs4_readlink {
876         const struct nfs_fh *           fh;
877         unsigned int                    pgbase;
878         unsigned int                    pglen;   /* zero-copy data */
879         struct page **                  pages;   /* zero-copy data */
880         struct nfs4_sequence_args       seq_args;
881 };
882
883 struct nfs4_readlink_res {
884         struct nfs4_sequence_res        seq_res;
885 };
886
887 #define NFS4_SETCLIENTID_NAMELEN        (127)
888 struct nfs4_setclientid {
889         const nfs4_verifier *           sc_verifier;
890         unsigned int                    sc_name_len;
891         char                            sc_name[NFS4_SETCLIENTID_NAMELEN + 1];
892         u32                             sc_prog;
893         unsigned int                    sc_netid_len;
894         char                            sc_netid[RPCBIND_MAXNETIDLEN + 1];
895         unsigned int                    sc_uaddr_len;
896         char                            sc_uaddr[RPCBIND_MAXUADDRLEN + 1];
897         u32                             sc_cb_ident;
898 };
899
900 struct nfs4_setclientid_res {
901         u64                             clientid;
902         nfs4_verifier                   confirm;
903 };
904
905 struct nfs4_statfs_arg {
906         const struct nfs_fh *           fh;
907         const u32 *                     bitmask;
908         struct nfs4_sequence_args       seq_args;
909 };
910
911 struct nfs4_statfs_res {
912         struct nfs_fsstat              *fsstat;
913         struct nfs4_sequence_res        seq_res;
914 };
915
916 struct nfs4_server_caps_arg {
917         struct nfs_fh                  *fhandle;
918         struct nfs4_sequence_args       seq_args;
919 };
920
921 struct nfs4_server_caps_res {
922         u32                             attr_bitmask[2];
923         u32                             acl_bitmask;
924         u32                             has_links;
925         u32                             has_symlinks;
926         struct nfs4_sequence_res        seq_res;
927 };
928
929 struct nfs4_string {
930         unsigned int len;
931         char *data;
932 };
933
934 #define NFS4_PATHNAME_MAXCOMPONENTS 512
935 struct nfs4_pathname {
936         unsigned int ncomponents;
937         struct nfs4_string components[NFS4_PATHNAME_MAXCOMPONENTS];
938 };
939
940 #define NFS4_FS_LOCATION_MAXSERVERS 10
941 struct nfs4_fs_location {
942         unsigned int nservers;
943         struct nfs4_string servers[NFS4_FS_LOCATION_MAXSERVERS];
944         struct nfs4_pathname rootpath;
945 };
946
947 #define NFS4_FS_LOCATIONS_MAXENTRIES 10
948 struct nfs4_fs_locations {
949         struct nfs_fattr fattr;
950         const struct nfs_server *server;
951         struct nfs4_pathname fs_path;
952         int nlocations;
953         struct nfs4_fs_location locations[NFS4_FS_LOCATIONS_MAXENTRIES];
954 };
955
956 struct nfs4_fs_locations_arg {
957         const struct nfs_fh *dir_fh;
958         const struct qstr *name;
959         struct page *page;
960         const u32 *bitmask;
961         struct nfs4_sequence_args       seq_args;
962 };
963
964 struct nfs4_fs_locations_res {
965         struct nfs4_fs_locations       *fs_locations;
966         struct nfs4_sequence_res        seq_res;
967 };
968
969 struct nfs4_secinfo_oid {
970         unsigned int len;
971         char data[GSS_OID_MAX_LEN];
972 };
973
974 struct nfs4_secinfo_gss {
975         struct nfs4_secinfo_oid sec_oid4;
976         unsigned int qop4;
977         unsigned int service;
978 };
979
980 struct nfs4_secinfo_flavor {
981         unsigned int            flavor;
982         struct nfs4_secinfo_gss gss;
983 };
984
985 struct nfs4_secinfo_flavors {
986         unsigned int num_flavors;
987         struct nfs4_secinfo_flavor flavors[0];
988 };
989
990 struct nfs4_secinfo_arg {
991         const struct nfs_fh             *dir_fh;
992         const struct qstr               *name;
993         struct nfs4_sequence_args       seq_args;
994 };
995
996 struct nfs4_secinfo_res {
997         struct nfs4_secinfo_flavors     *flavors;
998         struct nfs4_sequence_res        seq_res;
999 };
1000
1001 #endif /* CONFIG_NFS_V4 */
1002
1003 struct nfstime4 {
1004         u64     seconds;
1005         u32     nseconds;
1006 };
1007
1008 #ifdef CONFIG_NFS_V4_1
1009 struct nfs_impl_id4 {
1010         u32             domain_len;
1011         char            *domain;
1012         u32             name_len;
1013         char            *name;
1014         struct nfstime4 date;
1015 };
1016
1017 #define NFS4_EXCHANGE_ID_LEN    (48)
1018 struct nfs41_exchange_id_args {
1019         struct nfs_client               *client;
1020         nfs4_verifier                   *verifier;
1021         unsigned int                    id_len;
1022         char                            id[NFS4_EXCHANGE_ID_LEN];
1023         u32                             flags;
1024 };
1025
1026 struct server_owner {
1027         uint64_t                        minor_id;
1028         uint32_t                        major_id_sz;
1029         char                            major_id[NFS4_OPAQUE_LIMIT];
1030 };
1031
1032 struct server_scope {
1033         uint32_t                        server_scope_sz;
1034         char                            server_scope[NFS4_OPAQUE_LIMIT];
1035 };
1036
1037 struct nfs41_exchange_id_res {
1038         struct nfs_client               *client;
1039         u32                             flags;
1040 };
1041
1042 struct nfs41_create_session_args {
1043         struct nfs_client              *client;
1044         uint32_t                        flags;
1045         uint32_t                        cb_program;
1046         struct nfs4_channel_attrs       fc_attrs;       /* Fore Channel */
1047         struct nfs4_channel_attrs       bc_attrs;       /* Back Channel */
1048 };
1049
1050 struct nfs41_create_session_res {
1051         struct nfs_client              *client;
1052 };
1053
1054 struct nfs41_reclaim_complete_args {
1055         /* In the future extend to include curr_fh for use with migration */
1056         unsigned char                   one_fs:1;
1057         struct nfs4_sequence_args       seq_args;
1058 };
1059
1060 struct nfs41_reclaim_complete_res {
1061         struct nfs4_sequence_res        seq_res;
1062 };
1063 #endif /* CONFIG_NFS_V4_1 */
1064
1065 struct nfs_page;
1066
1067 #define NFS_PAGEVEC_SIZE        (8U)
1068
1069 struct nfs_read_data {
1070         int                     flags;
1071         struct rpc_task         task;
1072         struct inode            *inode;
1073         struct rpc_cred         *cred;
1074         struct nfs_fattr        fattr;  /* fattr storage */
1075         struct list_head        pages;  /* Coalesced read requests */
1076         struct nfs_page         *req;   /* multi ops per nfs_page */
1077         struct page             **pagevec;
1078         unsigned int            npages; /* Max length of pagevec */
1079         struct nfs_readargs args;
1080         struct nfs_readres  res;
1081         unsigned long           timestamp;      /* For lease renewal */
1082         struct pnfs_layout_segment *lseg;
1083         struct nfs_client       *ds_clp;        /* pNFS data server */
1084         const struct rpc_call_ops *mds_ops;
1085         int (*read_done_cb) (struct rpc_task *task, struct nfs_read_data *data);
1086         __u64                   mds_offset;
1087         struct page             *page_array[NFS_PAGEVEC_SIZE];
1088 };
1089
1090 struct nfs_write_data {
1091         int                     flags;
1092         struct rpc_task         task;
1093         struct inode            *inode;
1094         struct rpc_cred         *cred;
1095         struct nfs_fattr        fattr;
1096         struct nfs_writeverf    verf;
1097         struct list_head        pages;          /* Coalesced requests we wish to flush */
1098         struct nfs_page         *req;           /* multi ops per nfs_page */
1099         struct page             **pagevec;
1100         unsigned int            npages;         /* Max length of pagevec */
1101         struct nfs_writeargs    args;           /* argument struct */
1102         struct nfs_writeres     res;            /* result struct */
1103         struct pnfs_layout_segment *lseg;
1104         struct nfs_client       *ds_clp;        /* pNFS data server */
1105         int                     ds_commit_index;
1106         const struct rpc_call_ops *mds_ops;
1107         int (*write_done_cb) (struct rpc_task *task, struct nfs_write_data *data);
1108 #ifdef CONFIG_NFS_V4
1109         unsigned long           timestamp;      /* For lease renewal */
1110 #endif
1111         __u64                   mds_offset;     /* Filelayout dense stripe */
1112         struct page             *page_array[NFS_PAGEVEC_SIZE];
1113 };
1114
1115 struct nfs_access_entry;
1116 struct nfs_client;
1117 struct rpc_timeout;
1118
1119 /*
1120  * RPC procedure vector for NFSv2/NFSv3 demuxing
1121  */
1122 struct nfs_rpc_ops {
1123         u32     version;                /* Protocol version */
1124         const struct dentry_operations *dentry_ops;
1125         const struct inode_operations *dir_inode_ops;
1126         const struct inode_operations *file_inode_ops;
1127
1128         int     (*getroot) (struct nfs_server *, struct nfs_fh *,
1129                             struct nfs_fsinfo *);
1130         int     (*lookupfh)(struct nfs_server *, struct nfs_fh *,
1131                             struct qstr *, struct nfs_fh *,
1132                             struct nfs_fattr *);
1133         int     (*getattr) (struct nfs_server *, struct nfs_fh *,
1134                             struct nfs_fattr *);
1135         int     (*setattr) (struct dentry *, struct nfs_fattr *,
1136                             struct iattr *);
1137         int     (*lookup)  (struct rpc_clnt *clnt, struct inode *, struct qstr *,
1138                             struct nfs_fh *, struct nfs_fattr *);
1139         int     (*access)  (struct inode *, struct nfs_access_entry *);
1140         int     (*readlink)(struct inode *, struct page *, unsigned int,
1141                             unsigned int);
1142         int     (*create)  (struct inode *, struct dentry *,
1143                             struct iattr *, int, struct nfs_open_context *);
1144         int     (*remove)  (struct inode *, struct qstr *);
1145         void    (*unlink_setup)  (struct rpc_message *, struct inode *dir);
1146         int     (*unlink_done) (struct rpc_task *, struct inode *);
1147         int     (*rename)  (struct inode *, struct qstr *,
1148                             struct inode *, struct qstr *);
1149         void    (*rename_setup)  (struct rpc_message *msg, struct inode *dir);
1150         int     (*rename_done) (struct rpc_task *task, struct inode *old_dir, struct inode *new_dir);
1151         int     (*link)    (struct inode *, struct inode *, struct qstr *);
1152         int     (*symlink) (struct inode *, struct dentry *, struct page *,
1153                             unsigned int, struct iattr *);
1154         int     (*mkdir)   (struct inode *, struct dentry *, struct iattr *);
1155         int     (*rmdir)   (struct inode *, struct qstr *);
1156         int     (*readdir) (struct dentry *, struct rpc_cred *,
1157                             u64, struct page **, unsigned int, int);
1158         int     (*mknod)   (struct inode *, struct dentry *, struct iattr *,
1159                             dev_t);
1160         int     (*statfs)  (struct nfs_server *, struct nfs_fh *,
1161                             struct nfs_fsstat *);
1162         int     (*fsinfo)  (struct nfs_server *, struct nfs_fh *,
1163                             struct nfs_fsinfo *);
1164         int     (*pathconf) (struct nfs_server *, struct nfs_fh *,
1165                              struct nfs_pathconf *);
1166         int     (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
1167         int     (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int);
1168         void    (*read_setup)   (struct nfs_read_data *, struct rpc_message *);
1169         int     (*read_done)  (struct rpc_task *, struct nfs_read_data *);
1170         void    (*write_setup)  (struct nfs_write_data *, struct rpc_message *);
1171         int     (*write_done)  (struct rpc_task *, struct nfs_write_data *);
1172         void    (*commit_setup) (struct nfs_write_data *, struct rpc_message *);
1173         int     (*commit_done) (struct rpc_task *, struct nfs_write_data *);
1174         int     (*lock)(struct file *, int, struct file_lock *);
1175         int     (*lock_check_bounds)(const struct file_lock *);
1176         void    (*clear_acl_cache)(struct inode *);
1177         void    (*close_context)(struct nfs_open_context *ctx, int);
1178         struct inode * (*open_context) (struct inode *dir,
1179                                 struct nfs_open_context *ctx,
1180                                 int open_flags,
1181                                 struct iattr *iattr);
1182         int     (*init_client) (struct nfs_client *, const struct rpc_timeout *,
1183                                 const char *, rpc_authflavor_t, int);
1184         int     (*secinfo)(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
1185 };
1186
1187 /*
1188  *      NFS_CALL(getattr, inode, (fattr));
1189  * into
1190  *      NFS_PROTO(inode)->getattr(fattr);
1191  */
1192 #define NFS_CALL(op, inode, args)       NFS_PROTO(inode)->op args
1193
1194 /*
1195  * Function vectors etc. for the NFS client
1196  */
1197 extern const struct nfs_rpc_ops nfs_v2_clientops;
1198 extern const struct nfs_rpc_ops nfs_v3_clientops;
1199 extern const struct nfs_rpc_ops nfs_v4_clientops;
1200 extern struct rpc_version       nfs_version2;
1201 extern struct rpc_version       nfs_version3;
1202 extern struct rpc_version       nfs_version4;
1203
1204 extern struct rpc_version       nfsacl_version3;
1205 extern struct rpc_program       nfsacl_program;
1206
1207 #endif