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