blob: b99295e07cdfe17a977d4b531dd909e0f125fe7f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_NFS_XDR_H
2#define _LINUX_NFS_XDR_H
3
Andreas Gruenbacherb7fa0552005-06-22 17:16:27 +00004#include <linux/nfsacl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
Chuck Lever40859d72005-11-30 18:09:02 -05006/*
7 * To change the maximum rsize and wsize supported by the NFS client, adjust
8 * NFS_MAX_FILE_IO_SIZE. 64KB is a typical maximum, but some servers can
9 * support a megabyte or more. The default is left at 4096 bytes, which is
10 * reasonable for NFS over UDP.
11 */
12#define NFS_MAX_FILE_IO_SIZE (1048576U)
13#define NFS_DEF_FILE_IO_SIZE (4096U)
14#define NFS_MIN_FILE_IO_SIZE (1024U)
15
Trond Myklebust8b4bdcf2006-06-09 09:34:19 -040016struct nfs_fsid {
17 uint64_t major;
18 uint64_t minor;
Linus Torvalds1da177e2005-04-16 15:20:36 -070019};
20
Trond Myklebust8b4bdcf2006-06-09 09:34:19 -040021/*
22 * Helper for checking equality between 2 fsids.
23 */
24static inline int nfs_fsid_equal(const struct nfs_fsid *a, const struct nfs_fsid *b)
25{
26 return a->major == b->major && a->minor == b->minor;
27}
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029struct nfs_fattr {
Trond Myklebust9e6e70f2009-03-11 14:10:24 -040030 unsigned int valid; /* which fields are valid */
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 __u64 pre_size; /* pre_op_attr.size */
32 struct timespec pre_mtime; /* pre_op_attr.mtime */
33 struct timespec pre_ctime; /* pre_op_attr.ctime */
34 enum nfs_ftype type; /* always use NFSv2 types */
35 __u32 mode;
36 __u32 nlink;
37 __u32 uid;
38 __u32 gid;
Richard Kennedy9fa8d662008-08-26 16:23:20 +010039 dev_t rdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 __u64 size;
41 union {
42 struct {
43 __u32 blocksize;
44 __u32 blocks;
45 } nfs2;
46 struct {
47 __u64 used;
48 } nfs3;
49 } du;
Trond Myklebust8b4bdcf2006-06-09 09:34:19 -040050 struct nfs_fsid fsid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 __u64 fileid;
52 struct timespec atime;
53 struct timespec mtime;
54 struct timespec ctime;
55 __u32 bitmap[2]; /* NFSv4 returned attribute bitmap */
56 __u64 change_attr; /* NFSv4 change attribute */
57 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
Trond Myklebust33801142005-10-27 22:12:39 -040058 unsigned long time_start;
Trond Myklebust4704f0e2008-10-14 19:16:07 -040059 unsigned long gencount;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060};
61
Trond Myklebust9e6e70f2009-03-11 14:10:24 -040062#define NFS_ATTR_FATTR_TYPE (1U << 0)
63#define NFS_ATTR_FATTR_MODE (1U << 1)
64#define NFS_ATTR_FATTR_NLINK (1U << 2)
65#define NFS_ATTR_FATTR_OWNER (1U << 3)
66#define NFS_ATTR_FATTR_GROUP (1U << 4)
67#define NFS_ATTR_FATTR_RDEV (1U << 5)
68#define NFS_ATTR_FATTR_SIZE (1U << 6)
69#define NFS_ATTR_FATTR_PRESIZE (1U << 7)
70#define NFS_ATTR_FATTR_BLOCKS_USED (1U << 8)
71#define NFS_ATTR_FATTR_SPACE_USED (1U << 9)
72#define NFS_ATTR_FATTR_FSID (1U << 10)
73#define NFS_ATTR_FATTR_FILEID (1U << 11)
74#define NFS_ATTR_FATTR_ATIME (1U << 12)
75#define NFS_ATTR_FATTR_MTIME (1U << 13)
76#define NFS_ATTR_FATTR_CTIME (1U << 14)
77#define NFS_ATTR_FATTR_PREMTIME (1U << 15)
78#define NFS_ATTR_FATTR_PRECTIME (1U << 16)
79#define NFS_ATTR_FATTR_CHANGE (1U << 17)
80#define NFS_ATTR_FATTR_PRECHANGE (1U << 18)
81#define NFS_ATTR_FATTR_V4_REFERRAL (1U << 19) /* NFSv4 referral */
82
83#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \
84 | NFS_ATTR_FATTR_MODE \
85 | NFS_ATTR_FATTR_NLINK \
86 | NFS_ATTR_FATTR_OWNER \
87 | NFS_ATTR_FATTR_GROUP \
88 | NFS_ATTR_FATTR_RDEV \
89 | NFS_ATTR_FATTR_SIZE \
90 | NFS_ATTR_FATTR_FSID \
91 | NFS_ATTR_FATTR_FILEID \
92 | NFS_ATTR_FATTR_ATIME \
93 | NFS_ATTR_FATTR_MTIME \
94 | NFS_ATTR_FATTR_CTIME)
95#define NFS_ATTR_FATTR_V2 (NFS_ATTR_FATTR \
96 | NFS_ATTR_FATTR_BLOCKS_USED)
97#define NFS_ATTR_FATTR_V3 (NFS_ATTR_FATTR \
98 | NFS_ATTR_FATTR_SPACE_USED)
99#define NFS_ATTR_FATTR_V4 (NFS_ATTR_FATTR \
100 | NFS_ATTR_FATTR_SPACE_USED \
101 | NFS_ATTR_FATTR_CHANGE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
103/*
104 * Info on the file system
105 */
106struct nfs_fsinfo {
107 struct nfs_fattr *fattr; /* Post-op attributes */
108 __u32 rtmax; /* max. read transfer size */
109 __u32 rtpref; /* pref. read transfer size */
110 __u32 rtmult; /* reads should be multiple of this */
111 __u32 wtmax; /* max. write transfer size */
112 __u32 wtpref; /* pref. write transfer size */
113 __u32 wtmult; /* writes should be multiple of this */
114 __u32 dtpref; /* pref. readdir transfer size */
115 __u64 maxfilesize;
116 __u32 lease_time; /* in seconds */
117};
118
119struct nfs_fsstat {
120 struct nfs_fattr *fattr; /* Post-op attributes */
121 __u64 tbytes; /* total size in bytes */
122 __u64 fbytes; /* # of free bytes */
123 __u64 abytes; /* # of bytes available to user */
124 __u64 tfiles; /* # of files */
125 __u64 ffiles; /* # of free files */
126 __u64 afiles; /* # of files available to user */
127};
128
129struct nfs2_fsstat {
130 __u32 tsize; /* Server transfer size */
131 __u32 bsize; /* Filesystem block size */
132 __u32 blocks; /* No. of "bsize" blocks on filesystem */
133 __u32 bfree; /* No. of free "bsize" blocks */
134 __u32 bavail; /* No. of available "bsize" blocks */
135};
136
137struct nfs_pathconf {
138 struct nfs_fattr *fattr; /* Post-op attributes */
139 __u32 max_link; /* max # of hard links */
140 __u32 max_namelen; /* max name length */
141};
142
143struct nfs4_change_info {
144 u32 atomic;
145 u64 before;
146 u64 after;
147};
148
Trond Myklebustcee54fc2005-10-18 14:20:12 -0700149struct nfs_seqid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150/*
151 * Arguments to the open call.
152 */
153struct nfs_openargs {
154 const struct nfs_fh * fh;
Trond Myklebustcee54fc2005-10-18 14:20:12 -0700155 struct nfs_seqid * seqid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 int open_flags;
Trond Myklebustdc0b0272008-12-23 15:21:56 -0500157 fmode_t fmode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 __u64 clientid;
Trond Myklebust9f958ab2007-07-02 13:58:33 -0400159 __u64 id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 union {
161 struct iattr * attrs; /* UNCHECKED, GUARDED */
162 nfs4_verifier verifier; /* EXCLUSIVE */
163 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
Trond Myklebustbd7bf9d2008-12-23 15:21:53 -0500164 fmode_t delegation_type; /* CLAIM_PREVIOUS */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 } u;
166 const struct qstr * name;
167 const struct nfs_server *server; /* Needed for ID mapping */
168 const u32 * bitmask;
169 __u32 claim;
170};
171
172struct nfs_openres {
173 nfs4_stateid stateid;
174 struct nfs_fh fh;
175 struct nfs4_change_info cinfo;
176 __u32 rflags;
177 struct nfs_fattr * f_attr;
Trond Myklebust56ae19f2005-10-27 22:12:40 -0400178 struct nfs_fattr * dir_attr;
Trond Myklebustc1d51932008-04-07 13:20:54 -0400179 struct nfs_seqid * seqid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 const struct nfs_server *server;
Trond Myklebustbd7bf9d2008-12-23 15:21:53 -0500181 fmode_t delegation_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 nfs4_stateid delegation;
183 __u32 do_recall;
184 __u64 maxsize;
Jeff Laytonaa53ed52007-06-05 14:49:03 -0400185 __u32 attrset[NFS4_BITMAP_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186};
187
188/*
189 * Arguments to the open_confirm call.
190 */
191struct nfs_open_confirmargs {
192 const struct nfs_fh * fh;
Trond Myklebustcdd4e682006-01-03 09:55:12 +0100193 nfs4_stateid * stateid;
Trond Myklebustcee54fc2005-10-18 14:20:12 -0700194 struct nfs_seqid * seqid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195};
196
197struct nfs_open_confirmres {
198 nfs4_stateid stateid;
Trond Myklebustc1d51932008-04-07 13:20:54 -0400199 struct nfs_seqid * seqid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200};
201
202/*
203 * Arguments to the close call.
204 */
205struct nfs_closeargs {
206 struct nfs_fh * fh;
Trond Myklebust95121352005-10-18 14:20:12 -0700207 nfs4_stateid * stateid;
Trond Myklebustcee54fc2005-10-18 14:20:12 -0700208 struct nfs_seqid * seqid;
Trond Myklebustdc0b0272008-12-23 15:21:56 -0500209 fmode_t fmode;
Trond Myklebust516a6af2005-10-27 22:12:41 -0400210 const u32 * bitmask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211};
212
213struct nfs_closeres {
214 nfs4_stateid stateid;
Trond Myklebust516a6af2005-10-27 22:12:41 -0400215 struct nfs_fattr * fattr;
Trond Myklebustc1d51932008-04-07 13:20:54 -0400216 struct nfs_seqid * seqid;
Trond Myklebust516a6af2005-10-27 22:12:41 -0400217 const struct nfs_server *server;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218};
219/*
220 * * Arguments to the lock,lockt, and locku call.
221 * */
222struct nfs_lowner {
Trond Myklebust911d1aa2006-01-03 09:55:16 +0100223 __u64 clientid;
Trond Myklebust9f958ab2007-07-02 13:58:33 -0400224 __u64 id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225};
226
Trond Myklebust911d1aa2006-01-03 09:55:16 +0100227struct nfs_lock_args {
228 struct nfs_fh * fh;
229 struct file_lock * fl;
Trond Myklebust06735b32005-10-18 14:20:15 -0700230 struct nfs_seqid * lock_seqid;
231 nfs4_stateid * lock_stateid;
232 struct nfs_seqid * open_seqid;
233 nfs4_stateid * open_stateid;
Trond Myklebust911d1aa2006-01-03 09:55:16 +0100234 struct nfs_lowner lock_owner;
235 unsigned char block : 1;
236 unsigned char reclaim : 1;
237 unsigned char new_lock_owner : 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238};
239
Trond Myklebust911d1aa2006-01-03 09:55:16 +0100240struct nfs_lock_res {
Trond Myklebustc1d51932008-04-07 13:20:54 -0400241 nfs4_stateid stateid;
242 struct nfs_seqid * lock_seqid;
243 struct nfs_seqid * open_seqid;
Trond Myklebust911d1aa2006-01-03 09:55:16 +0100244};
245
246struct nfs_locku_args {
247 struct nfs_fh * fh;
248 struct file_lock * fl;
Trond Myklebustcee54fc2005-10-18 14:20:12 -0700249 struct nfs_seqid * seqid;
Trond Myklebustfaf5f492005-10-18 14:20:15 -0700250 nfs4_stateid * stateid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251};
252
Trond Myklebust911d1aa2006-01-03 09:55:16 +0100253struct nfs_locku_res {
Trond Myklebustc1d51932008-04-07 13:20:54 -0400254 nfs4_stateid stateid;
255 struct nfs_seqid * seqid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256};
257
Trond Myklebust911d1aa2006-01-03 09:55:16 +0100258struct nfs_lockt_args {
259 struct nfs_fh * fh;
260 struct file_lock * fl;
261 struct nfs_lowner lock_owner;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262};
263
Trond Myklebust911d1aa2006-01-03 09:55:16 +0100264struct nfs_lockt_res {
265 struct file_lock * denied; /* LOCK, LOCKT failed */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266};
267
268struct nfs4_delegreturnargs {
269 const struct nfs_fh *fhandle;
270 const nfs4_stateid *stateid;
Trond Myklebustfa178f22006-01-03 09:55:38 +0100271 const u32 * bitmask;
272};
273
274struct nfs4_delegreturnres {
275 struct nfs_fattr * fattr;
276 const struct nfs_server *server;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277};
278
279/*
280 * Arguments to the read call.
281 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282struct nfs_readargs {
283 struct nfs_fh * fh;
284 struct nfs_open_context *context;
285 __u64 offset;
286 __u32 count;
287 unsigned int pgbase;
288 struct page ** pages;
289};
290
291struct nfs_readres {
292 struct nfs_fattr * fattr;
293 __u32 count;
294 int eof;
295};
296
297/*
298 * Arguments to the write call.
299 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300struct nfs_writeargs {
301 struct nfs_fh * fh;
302 struct nfs_open_context *context;
303 __u64 offset;
304 __u32 count;
305 enum nfs3_stable_how stable;
306 unsigned int pgbase;
307 struct page ** pages;
Trond Myklebust4f9838c2005-10-27 22:12:44 -0400308 const u32 * bitmask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309};
310
311struct nfs_writeverf {
312 enum nfs3_stable_how committed;
Al Virobc4785c2006-10-19 23:28:51 -0700313 __be32 verifier[2];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314};
315
316struct nfs_writeres {
317 struct nfs_fattr * fattr;
318 struct nfs_writeverf * verf;
319 __u32 count;
Trond Myklebust4f9838c2005-10-27 22:12:44 -0400320 const struct nfs_server *server;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321};
322
323/*
Trond Myklebust4fdc17b2007-07-14 15:39:57 -0400324 * Common arguments to the unlink call
325 */
326struct nfs_removeargs {
327 const struct nfs_fh *fh;
328 struct qstr name;
329 const u32 * bitmask;
330};
331
332struct nfs_removeres {
333 const struct nfs_server *server;
334 struct nfs4_change_info cinfo;
335 struct nfs_fattr dir_attr;
336};
337
338/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 * Argument struct for decode_entry function
340 */
341struct nfs_entry {
342 __u64 ino;
343 __u64 cookie,
344 prev_cookie;
345 const char * name;
346 unsigned int len;
347 int eof;
348 struct nfs_fh * fh;
349 struct nfs_fattr * fattr;
350};
351
352/*
353 * The following types are for NFSv2 only.
354 */
355struct nfs_sattrargs {
356 struct nfs_fh * fh;
357 struct iattr * sattr;
358};
359
360struct nfs_diropargs {
361 struct nfs_fh * fh;
362 const char * name;
363 unsigned int len;
364};
365
366struct nfs_createargs {
367 struct nfs_fh * fh;
368 const char * name;
369 unsigned int len;
370 struct iattr * sattr;
371};
372
373struct nfs_renameargs {
374 struct nfs_fh * fromfh;
375 const char * fromname;
376 unsigned int fromlen;
377 struct nfs_fh * tofh;
378 const char * toname;
379 unsigned int tolen;
380};
381
382struct nfs_setattrargs {
383 struct nfs_fh * fh;
384 nfs4_stateid stateid;
385 struct iattr * iap;
386 const struct nfs_server * server; /* Needed for name mapping */
387 const u32 * bitmask;
388};
389
J. Bruce Fields23ec6962005-06-22 17:16:22 +0000390struct nfs_setaclargs {
391 struct nfs_fh * fh;
392 size_t acl_len;
393 unsigned int acl_pgbase;
394 struct page ** acl_pages;
395};
396
J. Bruce Fields029d1052005-06-22 17:16:22 +0000397struct nfs_getaclargs {
398 struct nfs_fh * fh;
399 size_t acl_len;
400 unsigned int acl_pgbase;
401 struct page ** acl_pages;
402};
403
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404struct nfs_setattrres {
405 struct nfs_fattr * fattr;
406 const struct nfs_server * server;
407};
408
409struct nfs_linkargs {
410 struct nfs_fh * fromfh;
411 struct nfs_fh * tofh;
412 const char * toname;
413 unsigned int tolen;
414};
415
416struct nfs_symlinkargs {
417 struct nfs_fh * fromfh;
418 const char * fromname;
419 unsigned int fromlen;
Chuck Lever94a6d752006-08-22 20:06:23 -0400420 struct page ** pages;
421 unsigned int pathlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 struct iattr * sattr;
423};
424
425struct nfs_readdirargs {
426 struct nfs_fh * fh;
427 __u32 cookie;
428 unsigned int count;
429 struct page ** pages;
430};
431
Andreas Gruenbacherb7fa0552005-06-22 17:16:27 +0000432struct nfs3_getaclargs {
433 struct nfs_fh * fh;
434 int mask;
435 struct page ** pages;
436};
437
438struct nfs3_setaclargs {
439 struct inode * inode;
440 int mask;
441 struct posix_acl * acl_access;
442 struct posix_acl * acl_default;
Trond Myklebustae461412009-03-10 20:33:18 -0400443 size_t len;
444 unsigned int npages;
Andreas Gruenbacherb7fa0552005-06-22 17:16:27 +0000445 struct page ** pages;
446};
447
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448struct nfs_diropok {
449 struct nfs_fh * fh;
450 struct nfs_fattr * fattr;
451};
452
453struct nfs_readlinkargs {
454 struct nfs_fh * fh;
455 unsigned int pgbase;
456 unsigned int pglen;
457 struct page ** pages;
458};
459
460struct nfs3_sattrargs {
461 struct nfs_fh * fh;
462 struct iattr * sattr;
463 unsigned int guard;
464 struct timespec guardtime;
465};
466
467struct nfs3_diropargs {
468 struct nfs_fh * fh;
469 const char * name;
470 unsigned int len;
471};
472
473struct nfs3_accessargs {
474 struct nfs_fh * fh;
475 __u32 access;
476};
477
478struct nfs3_createargs {
479 struct nfs_fh * fh;
480 const char * name;
481 unsigned int len;
482 struct iattr * sattr;
483 enum nfs3_createmode createmode;
Al Virobc4785c2006-10-19 23:28:51 -0700484 __be32 verifier[2];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485};
486
487struct nfs3_mkdirargs {
488 struct nfs_fh * fh;
489 const char * name;
490 unsigned int len;
491 struct iattr * sattr;
492};
493
494struct nfs3_symlinkargs {
495 struct nfs_fh * fromfh;
496 const char * fromname;
497 unsigned int fromlen;
Chuck Lever94a6d752006-08-22 20:06:23 -0400498 struct page ** pages;
499 unsigned int pathlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 struct iattr * sattr;
501};
502
503struct nfs3_mknodargs {
504 struct nfs_fh * fh;
505 const char * name;
506 unsigned int len;
507 enum nfs3_ftype type;
508 struct iattr * sattr;
509 dev_t rdev;
510};
511
512struct nfs3_renameargs {
513 struct nfs_fh * fromfh;
514 const char * fromname;
515 unsigned int fromlen;
516 struct nfs_fh * tofh;
517 const char * toname;
518 unsigned int tolen;
519};
520
521struct nfs3_linkargs {
522 struct nfs_fh * fromfh;
523 struct nfs_fh * tofh;
524 const char * toname;
525 unsigned int tolen;
526};
527
528struct nfs3_readdirargs {
529 struct nfs_fh * fh;
530 __u64 cookie;
Al Virobc4785c2006-10-19 23:28:51 -0700531 __be32 verf[2];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 int plus;
533 unsigned int count;
534 struct page ** pages;
535};
536
537struct nfs3_diropres {
538 struct nfs_fattr * dir_attr;
539 struct nfs_fh * fh;
540 struct nfs_fattr * fattr;
541};
542
543struct nfs3_accessres {
544 struct nfs_fattr * fattr;
545 __u32 access;
546};
547
548struct nfs3_readlinkargs {
549 struct nfs_fh * fh;
550 unsigned int pgbase;
551 unsigned int pglen;
552 struct page ** pages;
553};
554
555struct nfs3_renameres {
556 struct nfs_fattr * fromattr;
557 struct nfs_fattr * toattr;
558};
559
560struct nfs3_linkres {
561 struct nfs_fattr * dir_attr;
562 struct nfs_fattr * fattr;
563};
564
565struct nfs3_readdirres {
566 struct nfs_fattr * dir_attr;
Al Virobc4785c2006-10-19 23:28:51 -0700567 __be32 * verf;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 int plus;
569};
570
Andreas Gruenbacherb7fa0552005-06-22 17:16:27 +0000571struct nfs3_getaclres {
572 struct nfs_fattr * fattr;
573 int mask;
574 unsigned int acl_access_count;
575 unsigned int acl_default_count;
576 struct posix_acl * acl_access;
577 struct posix_acl * acl_default;
578};
579
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580#ifdef CONFIG_NFS_V4
581
582typedef u64 clientid4;
583
584struct nfs4_accessargs {
585 const struct nfs_fh * fh;
Trond Myklebust76b32992007-08-10 17:45:11 -0400586 const u32 * bitmask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 u32 access;
588};
589
590struct nfs4_accessres {
Trond Myklebust76b32992007-08-10 17:45:11 -0400591 const struct nfs_server * server;
592 struct nfs_fattr * fattr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 u32 supported;
594 u32 access;
595};
596
597struct nfs4_create_arg {
598 u32 ftype;
599 union {
Chuck Lever94a6d752006-08-22 20:06:23 -0400600 struct {
601 struct page ** pages;
602 unsigned int len;
603 } symlink; /* NF4LNK */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 struct {
605 u32 specdata1;
606 u32 specdata2;
607 } device; /* NF4BLK, NF4CHR */
608 } u;
609 const struct qstr * name;
610 const struct nfs_server * server;
611 const struct iattr * attrs;
612 const struct nfs_fh * dir_fh;
613 const u32 * bitmask;
614};
615
616struct nfs4_create_res {
617 const struct nfs_server * server;
618 struct nfs_fh * fh;
619 struct nfs_fattr * fattr;
620 struct nfs4_change_info dir_cinfo;
Trond Myklebust56ae19f2005-10-27 22:12:40 -0400621 struct nfs_fattr * dir_fattr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622};
623
624struct nfs4_fsinfo_arg {
625 const struct nfs_fh * fh;
626 const u32 * bitmask;
627};
628
629struct nfs4_getattr_arg {
630 const struct nfs_fh * fh;
631 const u32 * bitmask;
632};
633
634struct nfs4_getattr_res {
635 const struct nfs_server * server;
636 struct nfs_fattr * fattr;
637};
638
639struct nfs4_link_arg {
640 const struct nfs_fh * fh;
641 const struct nfs_fh * dir_fh;
642 const struct qstr * name;
Trond Myklebust91ba2ee2005-10-27 22:12:42 -0400643 const u32 * bitmask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644};
645
Trond Myklebust91ba2ee2005-10-27 22:12:42 -0400646struct nfs4_link_res {
647 const struct nfs_server * server;
648 struct nfs_fattr * fattr;
649 struct nfs4_change_info cinfo;
650 struct nfs_fattr * dir_attr;
651};
652
653
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654struct nfs4_lookup_arg {
655 const struct nfs_fh * dir_fh;
656 const struct qstr * name;
657 const u32 * bitmask;
658};
659
660struct nfs4_lookup_res {
661 const struct nfs_server * server;
662 struct nfs_fattr * fattr;
663 struct nfs_fh * fh;
664};
665
666struct nfs4_lookup_root_arg {
667 const u32 * bitmask;
668};
669
670struct nfs4_pathconf_arg {
671 const struct nfs_fh * fh;
672 const u32 * bitmask;
673};
674
675struct nfs4_readdir_arg {
676 const struct nfs_fh * fh;
677 u64 cookie;
678 nfs4_verifier verifier;
679 u32 count;
680 struct page ** pages; /* zero-copy data */
681 unsigned int pgbase; /* zero-copy data */
682 const u32 * bitmask;
683};
684
685struct nfs4_readdir_res {
686 nfs4_verifier verifier;
687 unsigned int pgbase;
688};
689
690struct nfs4_readlink {
691 const struct nfs_fh * fh;
692 unsigned int pgbase;
693 unsigned int pglen; /* zero-copy data */
694 struct page ** pages; /* zero-copy data */
695};
696
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697struct nfs4_rename_arg {
698 const struct nfs_fh * old_dir;
699 const struct nfs_fh * new_dir;
700 const struct qstr * old_name;
701 const struct qstr * new_name;
Trond Myklebust6caf2c82005-10-27 22:12:43 -0400702 const u32 * bitmask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703};
704
705struct nfs4_rename_res {
Trond Myklebust6caf2c82005-10-27 22:12:43 -0400706 const struct nfs_server * server;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 struct nfs4_change_info old_cinfo;
Trond Myklebust6caf2c82005-10-27 22:12:43 -0400708 struct nfs_fattr * old_fattr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 struct nfs4_change_info new_cinfo;
Trond Myklebust6caf2c82005-10-27 22:12:43 -0400710 struct nfs_fattr * new_fattr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711};
712
Trond Myklebust19d771f2008-10-08 13:54:52 -0400713#define NFS4_SETCLIENTID_NAMELEN (127)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714struct nfs4_setclientid {
Chuck Levercc38bac2007-12-10 14:56:54 -0500715 const nfs4_verifier * sc_verifier;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 unsigned int sc_name_len;
Chuck Leverd1ce02e2008-09-25 11:57:12 -0400717 char sc_name[NFS4_SETCLIENTID_NAMELEN + 1];
Chuck Levercc38bac2007-12-10 14:56:54 -0500718 u32 sc_prog;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 unsigned int sc_netid_len;
Chuck Leverd1ce02e2008-09-25 11:57:12 -0400720 char sc_netid[RPCBIND_MAXNETIDLEN + 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 unsigned int sc_uaddr_len;
Chuck Leverd1ce02e2008-09-25 11:57:12 -0400722 char sc_uaddr[RPCBIND_MAXUADDRLEN + 1];
Chuck Levercc38bac2007-12-10 14:56:54 -0500723 u32 sc_cb_ident;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724};
725
726struct nfs4_statfs_arg {
727 const struct nfs_fh * fh;
728 const u32 * bitmask;
729};
730
731struct nfs4_server_caps_res {
732 u32 attr_bitmask[2];
733 u32 acl_bitmask;
734 u32 has_links;
735 u32 has_symlinks;
736};
737
Manoj Naik7aaa0b32006-06-09 09:34:23 -0400738struct nfs4_string {
739 unsigned int len;
740 char *data;
Trond Myklebust683b57b2006-06-09 09:34:22 -0400741};
742
Manoj Naik7aaa0b32006-06-09 09:34:23 -0400743#define NFS4_PATHNAME_MAXCOMPONENTS 512
744struct nfs4_pathname {
745 unsigned int ncomponents;
746 struct nfs4_string components[NFS4_PATHNAME_MAXCOMPONENTS];
747};
748
749#define NFS4_FS_LOCATION_MAXSERVERS 10
750struct nfs4_fs_location {
751 unsigned int nservers;
752 struct nfs4_string servers[NFS4_FS_LOCATION_MAXSERVERS];
753 struct nfs4_pathname rootpath;
754};
755
756#define NFS4_FS_LOCATIONS_MAXENTRIES 10
757struct nfs4_fs_locations {
Trond Myklebust683b57b2006-06-09 09:34:22 -0400758 struct nfs_fattr fattr;
759 const struct nfs_server *server;
Manoj Naik7aaa0b32006-06-09 09:34:23 -0400760 struct nfs4_pathname fs_path;
Trond Myklebust683b57b2006-06-09 09:34:22 -0400761 int nlocations;
Manoj Naik7aaa0b32006-06-09 09:34:23 -0400762 struct nfs4_fs_location locations[NFS4_FS_LOCATIONS_MAXENTRIES];
Trond Myklebust683b57b2006-06-09 09:34:22 -0400763};
764
765struct nfs4_fs_locations_arg {
766 const struct nfs_fh *dir_fh;
767 const struct qstr *name;
768 struct page *page;
769 const u32 *bitmask;
770};
771
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772#endif /* CONFIG_NFS_V4 */
773
774struct nfs_page;
775
Chuck Lever40859d72005-11-30 18:09:02 -0500776#define NFS_PAGEVEC_SIZE (8U)
777
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778struct nfs_read_data {
779 int flags;
780 struct rpc_task task;
781 struct inode *inode;
782 struct rpc_cred *cred;
783 struct nfs_fattr fattr; /* fattr storage */
784 struct list_head pages; /* Coalesced read requests */
785 struct nfs_page *req; /* multi ops per nfs_page */
Chuck Lever40859d72005-11-30 18:09:02 -0500786 struct page **pagevec;
Trond Myklebuste9f7bee2006-09-08 09:48:54 -0700787 unsigned int npages; /* Max length of pagevec */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 struct nfs_readargs args;
789 struct nfs_readres res;
790#ifdef CONFIG_NFS_V4
791 unsigned long timestamp; /* For lease renewal */
792#endif
Chuck Lever0d0b5cb2006-05-25 01:40:53 -0400793 struct page *page_array[NFS_PAGEVEC_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794};
795
796struct nfs_write_data {
797 int flags;
798 struct rpc_task task;
799 struct inode *inode;
800 struct rpc_cred *cred;
801 struct nfs_fattr fattr;
802 struct nfs_writeverf verf;
803 struct list_head pages; /* Coalesced requests we wish to flush */
804 struct nfs_page *req; /* multi ops per nfs_page */
Chuck Lever40859d72005-11-30 18:09:02 -0500805 struct page **pagevec;
Trond Myklebuste9f7bee2006-09-08 09:48:54 -0700806 unsigned int npages; /* Max length of pagevec */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 struct nfs_writeargs args; /* argument struct */
808 struct nfs_writeres res; /* result struct */
809#ifdef CONFIG_NFS_V4
810 unsigned long timestamp; /* For lease renewal */
811#endif
Chuck Lever0d0b5cb2006-05-25 01:40:53 -0400812 struct page *page_array[NFS_PAGEVEC_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813};
814
815struct nfs_access_entry;
816
817/*
818 * RPC procedure vector for NFSv2/NFSv3 demuxing
819 */
820struct nfs_rpc_ops {
Chuck Leverc0e07cb2008-01-14 12:32:05 -0500821 u32 version; /* Protocol version */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 struct dentry_operations *dentry_ops;
Arjan van de Venc5ef1c42007-02-12 00:55:40 -0800823 const struct inode_operations *dir_inode_ops;
824 const struct inode_operations *file_inode_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825
826 int (*getroot) (struct nfs_server *, struct nfs_fh *,
827 struct nfs_fsinfo *);
David Howells2b3de442006-08-22 20:06:09 -0400828 int (*lookupfh)(struct nfs_server *, struct nfs_fh *,
829 struct qstr *, struct nfs_fh *,
830 struct nfs_fattr *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 int (*getattr) (struct nfs_server *, struct nfs_fh *,
832 struct nfs_fattr *);
833 int (*setattr) (struct dentry *, struct nfs_fattr *,
834 struct iattr *);
835 int (*lookup) (struct inode *, struct qstr *,
836 struct nfs_fh *, struct nfs_fattr *);
837 int (*access) (struct inode *, struct nfs_access_entry *);
838 int (*readlink)(struct inode *, struct page *, unsigned int,
839 unsigned int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840 int (*create) (struct inode *, struct dentry *,
Trond Myklebust02a913a2005-10-18 14:20:17 -0700841 struct iattr *, int, struct nameidata *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 int (*remove) (struct inode *, struct qstr *);
Trond Myklebuste4eff1a2007-07-14 15:39:58 -0400843 void (*unlink_setup) (struct rpc_message *, struct inode *dir);
844 int (*unlink_done) (struct rpc_task *, struct inode *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 int (*rename) (struct inode *, struct qstr *,
846 struct inode *, struct qstr *);
847 int (*link) (struct inode *, struct inode *, struct qstr *);
Chuck Lever94a6d752006-08-22 20:06:23 -0400848 int (*symlink) (struct inode *, struct dentry *, struct page *,
849 unsigned int, struct iattr *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
851 int (*rmdir) (struct inode *, struct qstr *);
852 int (*readdir) (struct dentry *, struct rpc_cred *,
853 u64, struct page *, unsigned int, int);
854 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
855 dev_t);
856 int (*statfs) (struct nfs_server *, struct nfs_fh *,
857 struct nfs_fsstat *);
858 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
859 struct nfs_fsinfo *);
860 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
861 struct nfs_pathconf *);
David Howellse9326dc2006-08-22 20:06:10 -0400862 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
Al Viro0dbb4c62006-10-19 23:28:49 -0700863 __be32 *(*decode_dirent)(__be32 *, struct nfs_entry *, int plus);
Trond Myklebustbdc7f022007-07-14 15:40:00 -0400864 void (*read_setup) (struct nfs_read_data *, struct rpc_message *);
Trond Myklebustec06c092006-03-20 13:44:27 -0500865 int (*read_done) (struct rpc_task *, struct nfs_read_data *);
Trond Myklebustbdc7f022007-07-14 15:40:00 -0400866 void (*write_setup) (struct nfs_write_data *, struct rpc_message *);
Trond Myklebust788e7a82006-03-20 13:44:27 -0500867 int (*write_done) (struct rpc_task *, struct nfs_write_data *);
Trond Myklebustbdc7f022007-07-14 15:40:00 -0400868 void (*commit_setup) (struct nfs_write_data *, struct rpc_message *);
Trond Myklebust788e7a82006-03-20 13:44:27 -0500869 int (*commit_done) (struct rpc_task *, struct nfs_write_data *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 int (*lock)(struct file *, int, struct file_lock *);
Trond Myklebust21162712008-05-20 19:34:39 -0400871 int (*lock_check_bounds)(const struct file_lock *);
Trond Myklebustada70d92005-06-22 17:16:22 +0000872 void (*clear_acl_cache)(struct inode *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873};
874
875/*
876 * NFS_CALL(getattr, inode, (fattr));
877 * into
878 * NFS_PROTO(inode)->getattr(fattr);
879 */
880#define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
881
882/*
883 * Function vectors etc. for the NFS client
884 */
David Howells509de812006-08-22 20:06:11 -0400885extern const struct nfs_rpc_ops nfs_v2_clientops;
886extern const struct nfs_rpc_ops nfs_v3_clientops;
887extern const struct nfs_rpc_ops nfs_v4_clientops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888extern struct rpc_version nfs_version2;
889extern struct rpc_version nfs_version3;
890extern struct rpc_version nfs_version4;
891
Andreas Gruenbacherb7fa0552005-06-22 17:16:27 +0000892extern struct rpc_version nfsacl_version3;
893extern struct rpc_program nfsacl_program;
894
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895#endif