Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
[deliverable/linux.git] / include / linux / nfs_xdr.h
1 #ifndef _LINUX_NFS_XDR_H
2 #define _LINUX_NFS_XDR_H
3
4 #include <linux/sunrpc/xprt.h>
5 #include <linux/nfsacl.h>
6
7 /*
8 * To change the maximum rsize and wsize supported by the NFS client, adjust
9 * NFS_MAX_FILE_IO_SIZE. 64KB is a typical maximum, but some servers can
10 * support a megabyte or more. The default is left at 4096 bytes, which is
11 * reasonable for NFS over UDP.
12 */
13 #define NFS_MAX_FILE_IO_SIZE (1048576U)
14 #define NFS_DEF_FILE_IO_SIZE (4096U)
15 #define NFS_MIN_FILE_IO_SIZE (1024U)
16
17 struct nfs4_fsid {
18 __u64 major;
19 __u64 minor;
20 };
21
22 struct nfs_fattr {
23 unsigned short valid; /* which fields are valid */
24 __u64 pre_size; /* pre_op_attr.size */
25 struct timespec pre_mtime; /* pre_op_attr.mtime */
26 struct timespec pre_ctime; /* pre_op_attr.ctime */
27 enum nfs_ftype type; /* always use NFSv2 types */
28 __u32 mode;
29 __u32 nlink;
30 __u32 uid;
31 __u32 gid;
32 __u64 size;
33 union {
34 struct {
35 __u32 blocksize;
36 __u32 blocks;
37 } nfs2;
38 struct {
39 __u64 used;
40 } nfs3;
41 } du;
42 dev_t rdev;
43 union {
44 __u64 nfs3; /* also nfs2 */
45 struct nfs4_fsid nfs4;
46 } fsid_u;
47 __u64 fileid;
48 struct timespec atime;
49 struct timespec mtime;
50 struct timespec ctime;
51 __u32 bitmap[2]; /* NFSv4 returned attribute bitmap */
52 __u64 change_attr; /* NFSv4 change attribute */
53 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
54 unsigned long time_start;
55 };
56
57 #define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */
58 #define NFS_ATTR_FATTR 0x0002 /* post-op attributes */
59 #define NFS_ATTR_FATTR_V3 0x0004 /* NFSv3 attributes */
60 #define NFS_ATTR_FATTR_V4 0x0008
61 #define NFS_ATTR_PRE_CHANGE 0x0010
62
63 /*
64 * Info on the file system
65 */
66 struct nfs_fsinfo {
67 struct nfs_fattr *fattr; /* Post-op attributes */
68 __u32 rtmax; /* max. read transfer size */
69 __u32 rtpref; /* pref. read transfer size */
70 __u32 rtmult; /* reads should be multiple of this */
71 __u32 wtmax; /* max. write transfer size */
72 __u32 wtpref; /* pref. write transfer size */
73 __u32 wtmult; /* writes should be multiple of this */
74 __u32 dtpref; /* pref. readdir transfer size */
75 __u64 maxfilesize;
76 __u32 lease_time; /* in seconds */
77 };
78
79 struct nfs_fsstat {
80 struct nfs_fattr *fattr; /* Post-op attributes */
81 __u64 tbytes; /* total size in bytes */
82 __u64 fbytes; /* # of free bytes */
83 __u64 abytes; /* # of bytes available to user */
84 __u64 tfiles; /* # of files */
85 __u64 ffiles; /* # of free files */
86 __u64 afiles; /* # of files available to user */
87 };
88
89 struct nfs2_fsstat {
90 __u32 tsize; /* Server transfer size */
91 __u32 bsize; /* Filesystem block size */
92 __u32 blocks; /* No. of "bsize" blocks on filesystem */
93 __u32 bfree; /* No. of free "bsize" blocks */
94 __u32 bavail; /* No. of available "bsize" blocks */
95 };
96
97 struct nfs_pathconf {
98 struct nfs_fattr *fattr; /* Post-op attributes */
99 __u32 max_link; /* max # of hard links */
100 __u32 max_namelen; /* max name length */
101 };
102
103 struct nfs4_change_info {
104 u32 atomic;
105 u64 before;
106 u64 after;
107 };
108
109 struct nfs_seqid;
110 /*
111 * Arguments to the open call.
112 */
113 struct nfs_openargs {
114 const struct nfs_fh * fh;
115 struct nfs_seqid * seqid;
116 int open_flags;
117 __u64 clientid;
118 __u32 id;
119 union {
120 struct iattr * attrs; /* UNCHECKED, GUARDED */
121 nfs4_verifier verifier; /* EXCLUSIVE */
122 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
123 int delegation_type; /* CLAIM_PREVIOUS */
124 } u;
125 const struct qstr * name;
126 const struct nfs_server *server; /* Needed for ID mapping */
127 const u32 * bitmask;
128 __u32 claim;
129 };
130
131 struct nfs_openres {
132 nfs4_stateid stateid;
133 struct nfs_fh fh;
134 struct nfs4_change_info cinfo;
135 __u32 rflags;
136 struct nfs_fattr * f_attr;
137 struct nfs_fattr * dir_attr;
138 const struct nfs_server *server;
139 int delegation_type;
140 nfs4_stateid delegation;
141 __u32 do_recall;
142 __u64 maxsize;
143 };
144
145 /*
146 * Arguments to the open_confirm call.
147 */
148 struct nfs_open_confirmargs {
149 const struct nfs_fh * fh;
150 nfs4_stateid * stateid;
151 struct nfs_seqid * seqid;
152 };
153
154 struct nfs_open_confirmres {
155 nfs4_stateid stateid;
156 };
157
158 /*
159 * Arguments to the close call.
160 */
161 struct nfs_closeargs {
162 struct nfs_fh * fh;
163 nfs4_stateid * stateid;
164 struct nfs_seqid * seqid;
165 int open_flags;
166 const u32 * bitmask;
167 };
168
169 struct nfs_closeres {
170 nfs4_stateid stateid;
171 struct nfs_fattr * fattr;
172 const struct nfs_server *server;
173 };
174 /*
175 * * Arguments to the lock,lockt, and locku call.
176 * */
177 struct nfs_lowner {
178 __u64 clientid;
179 u32 id;
180 };
181
182 struct nfs_lock_args {
183 struct nfs_fh * fh;
184 struct file_lock * fl;
185 struct nfs_seqid * lock_seqid;
186 nfs4_stateid * lock_stateid;
187 struct nfs_seqid * open_seqid;
188 nfs4_stateid * open_stateid;
189 struct nfs_lowner lock_owner;
190 unsigned char block : 1;
191 unsigned char reclaim : 1;
192 unsigned char new_lock_owner : 1;
193 };
194
195 struct nfs_lock_res {
196 nfs4_stateid stateid;
197 };
198
199 struct nfs_locku_args {
200 struct nfs_fh * fh;
201 struct file_lock * fl;
202 struct nfs_seqid * seqid;
203 nfs4_stateid * stateid;
204 };
205
206 struct nfs_locku_res {
207 nfs4_stateid stateid;
208 };
209
210 struct nfs_lockt_args {
211 struct nfs_fh * fh;
212 struct file_lock * fl;
213 struct nfs_lowner lock_owner;
214 };
215
216 struct nfs_lockt_res {
217 struct file_lock * denied; /* LOCK, LOCKT failed */
218 };
219
220 struct nfs4_delegreturnargs {
221 const struct nfs_fh *fhandle;
222 const nfs4_stateid *stateid;
223 const u32 * bitmask;
224 };
225
226 struct nfs4_delegreturnres {
227 struct nfs_fattr * fattr;
228 const struct nfs_server *server;
229 };
230
231 /*
232 * Arguments to the read call.
233 */
234 struct nfs_readargs {
235 struct nfs_fh * fh;
236 struct nfs_open_context *context;
237 __u64 offset;
238 __u32 count;
239 unsigned int pgbase;
240 struct page ** pages;
241 };
242
243 struct nfs_readres {
244 struct nfs_fattr * fattr;
245 __u32 count;
246 int eof;
247 };
248
249 /*
250 * Arguments to the write call.
251 */
252 struct nfs_writeargs {
253 struct nfs_fh * fh;
254 struct nfs_open_context *context;
255 __u64 offset;
256 __u32 count;
257 enum nfs3_stable_how stable;
258 unsigned int pgbase;
259 struct page ** pages;
260 const u32 * bitmask;
261 };
262
263 struct nfs_writeverf {
264 enum nfs3_stable_how committed;
265 __u32 verifier[2];
266 };
267
268 struct nfs_writeres {
269 struct nfs_fattr * fattr;
270 struct nfs_writeverf * verf;
271 __u32 count;
272 const struct nfs_server *server;
273 };
274
275 /*
276 * Argument struct for decode_entry function
277 */
278 struct nfs_entry {
279 __u64 ino;
280 __u64 cookie,
281 prev_cookie;
282 const char * name;
283 unsigned int len;
284 int eof;
285 struct nfs_fh * fh;
286 struct nfs_fattr * fattr;
287 };
288
289 /*
290 * The following types are for NFSv2 only.
291 */
292 struct nfs_sattrargs {
293 struct nfs_fh * fh;
294 struct iattr * sattr;
295 };
296
297 struct nfs_diropargs {
298 struct nfs_fh * fh;
299 const char * name;
300 unsigned int len;
301 };
302
303 struct nfs_createargs {
304 struct nfs_fh * fh;
305 const char * name;
306 unsigned int len;
307 struct iattr * sattr;
308 };
309
310 struct nfs_renameargs {
311 struct nfs_fh * fromfh;
312 const char * fromname;
313 unsigned int fromlen;
314 struct nfs_fh * tofh;
315 const char * toname;
316 unsigned int tolen;
317 };
318
319 struct nfs_setattrargs {
320 struct nfs_fh * fh;
321 nfs4_stateid stateid;
322 struct iattr * iap;
323 const struct nfs_server * server; /* Needed for name mapping */
324 const u32 * bitmask;
325 };
326
327 struct nfs_setaclargs {
328 struct nfs_fh * fh;
329 size_t acl_len;
330 unsigned int acl_pgbase;
331 struct page ** acl_pages;
332 };
333
334 struct nfs_getaclargs {
335 struct nfs_fh * fh;
336 size_t acl_len;
337 unsigned int acl_pgbase;
338 struct page ** acl_pages;
339 };
340
341 struct nfs_setattrres {
342 struct nfs_fattr * fattr;
343 const struct nfs_server * server;
344 };
345
346 struct nfs_linkargs {
347 struct nfs_fh * fromfh;
348 struct nfs_fh * tofh;
349 const char * toname;
350 unsigned int tolen;
351 };
352
353 struct nfs_symlinkargs {
354 struct nfs_fh * fromfh;
355 const char * fromname;
356 unsigned int fromlen;
357 const char * topath;
358 unsigned int tolen;
359 struct iattr * sattr;
360 };
361
362 struct nfs_readdirargs {
363 struct nfs_fh * fh;
364 __u32 cookie;
365 unsigned int count;
366 struct page ** pages;
367 };
368
369 struct nfs3_getaclargs {
370 struct nfs_fh * fh;
371 int mask;
372 struct page ** pages;
373 };
374
375 struct nfs3_setaclargs {
376 struct inode * inode;
377 int mask;
378 struct posix_acl * acl_access;
379 struct posix_acl * acl_default;
380 struct page ** pages;
381 };
382
383 struct nfs_diropok {
384 struct nfs_fh * fh;
385 struct nfs_fattr * fattr;
386 };
387
388 struct nfs_readlinkargs {
389 struct nfs_fh * fh;
390 unsigned int pgbase;
391 unsigned int pglen;
392 struct page ** pages;
393 };
394
395 struct nfs3_sattrargs {
396 struct nfs_fh * fh;
397 struct iattr * sattr;
398 unsigned int guard;
399 struct timespec guardtime;
400 };
401
402 struct nfs3_diropargs {
403 struct nfs_fh * fh;
404 const char * name;
405 unsigned int len;
406 };
407
408 struct nfs3_accessargs {
409 struct nfs_fh * fh;
410 __u32 access;
411 };
412
413 struct nfs3_createargs {
414 struct nfs_fh * fh;
415 const char * name;
416 unsigned int len;
417 struct iattr * sattr;
418 enum nfs3_createmode createmode;
419 __u32 verifier[2];
420 };
421
422 struct nfs3_mkdirargs {
423 struct nfs_fh * fh;
424 const char * name;
425 unsigned int len;
426 struct iattr * sattr;
427 };
428
429 struct nfs3_symlinkargs {
430 struct nfs_fh * fromfh;
431 const char * fromname;
432 unsigned int fromlen;
433 const char * topath;
434 unsigned int tolen;
435 struct iattr * sattr;
436 };
437
438 struct nfs3_mknodargs {
439 struct nfs_fh * fh;
440 const char * name;
441 unsigned int len;
442 enum nfs3_ftype type;
443 struct iattr * sattr;
444 dev_t rdev;
445 };
446
447 struct nfs3_renameargs {
448 struct nfs_fh * fromfh;
449 const char * fromname;
450 unsigned int fromlen;
451 struct nfs_fh * tofh;
452 const char * toname;
453 unsigned int tolen;
454 };
455
456 struct nfs3_linkargs {
457 struct nfs_fh * fromfh;
458 struct nfs_fh * tofh;
459 const char * toname;
460 unsigned int tolen;
461 };
462
463 struct nfs3_readdirargs {
464 struct nfs_fh * fh;
465 __u64 cookie;
466 __u32 verf[2];
467 int plus;
468 unsigned int count;
469 struct page ** pages;
470 };
471
472 struct nfs3_diropres {
473 struct nfs_fattr * dir_attr;
474 struct nfs_fh * fh;
475 struct nfs_fattr * fattr;
476 };
477
478 struct nfs3_accessres {
479 struct nfs_fattr * fattr;
480 __u32 access;
481 };
482
483 struct nfs3_readlinkargs {
484 struct nfs_fh * fh;
485 unsigned int pgbase;
486 unsigned int pglen;
487 struct page ** pages;
488 };
489
490 struct nfs3_renameres {
491 struct nfs_fattr * fromattr;
492 struct nfs_fattr * toattr;
493 };
494
495 struct nfs3_linkres {
496 struct nfs_fattr * dir_attr;
497 struct nfs_fattr * fattr;
498 };
499
500 struct nfs3_readdirres {
501 struct nfs_fattr * dir_attr;
502 __u32 * verf;
503 int plus;
504 };
505
506 struct nfs3_getaclres {
507 struct nfs_fattr * fattr;
508 int mask;
509 unsigned int acl_access_count;
510 unsigned int acl_default_count;
511 struct posix_acl * acl_access;
512 struct posix_acl * acl_default;
513 };
514
515 #ifdef CONFIG_NFS_V4
516
517 typedef u64 clientid4;
518
519 struct nfs4_accessargs {
520 const struct nfs_fh * fh;
521 u32 access;
522 };
523
524 struct nfs4_accessres {
525 u32 supported;
526 u32 access;
527 };
528
529 struct nfs4_create_arg {
530 u32 ftype;
531 union {
532 struct qstr * symlink; /* NF4LNK */
533 struct {
534 u32 specdata1;
535 u32 specdata2;
536 } device; /* NF4BLK, NF4CHR */
537 } u;
538 const struct qstr * name;
539 const struct nfs_server * server;
540 const struct iattr * attrs;
541 const struct nfs_fh * dir_fh;
542 const u32 * bitmask;
543 };
544
545 struct nfs4_create_res {
546 const struct nfs_server * server;
547 struct nfs_fh * fh;
548 struct nfs_fattr * fattr;
549 struct nfs4_change_info dir_cinfo;
550 struct nfs_fattr * dir_fattr;
551 };
552
553 struct nfs4_fsinfo_arg {
554 const struct nfs_fh * fh;
555 const u32 * bitmask;
556 };
557
558 struct nfs4_getattr_arg {
559 const struct nfs_fh * fh;
560 const u32 * bitmask;
561 };
562
563 struct nfs4_getattr_res {
564 const struct nfs_server * server;
565 struct nfs_fattr * fattr;
566 };
567
568 struct nfs4_link_arg {
569 const struct nfs_fh * fh;
570 const struct nfs_fh * dir_fh;
571 const struct qstr * name;
572 const u32 * bitmask;
573 };
574
575 struct nfs4_link_res {
576 const struct nfs_server * server;
577 struct nfs_fattr * fattr;
578 struct nfs4_change_info cinfo;
579 struct nfs_fattr * dir_attr;
580 };
581
582
583 struct nfs4_lookup_arg {
584 const struct nfs_fh * dir_fh;
585 const struct qstr * name;
586 const u32 * bitmask;
587 };
588
589 struct nfs4_lookup_res {
590 const struct nfs_server * server;
591 struct nfs_fattr * fattr;
592 struct nfs_fh * fh;
593 };
594
595 struct nfs4_lookup_root_arg {
596 const u32 * bitmask;
597 };
598
599 struct nfs4_pathconf_arg {
600 const struct nfs_fh * fh;
601 const u32 * bitmask;
602 };
603
604 struct nfs4_readdir_arg {
605 const struct nfs_fh * fh;
606 u64 cookie;
607 nfs4_verifier verifier;
608 u32 count;
609 struct page ** pages; /* zero-copy data */
610 unsigned int pgbase; /* zero-copy data */
611 const u32 * bitmask;
612 };
613
614 struct nfs4_readdir_res {
615 nfs4_verifier verifier;
616 unsigned int pgbase;
617 };
618
619 struct nfs4_readlink {
620 const struct nfs_fh * fh;
621 unsigned int pgbase;
622 unsigned int pglen; /* zero-copy data */
623 struct page ** pages; /* zero-copy data */
624 };
625
626 struct nfs4_remove_arg {
627 const struct nfs_fh * fh;
628 const struct qstr * name;
629 const u32 * bitmask;
630 };
631
632 struct nfs4_remove_res {
633 const struct nfs_server * server;
634 struct nfs4_change_info cinfo;
635 struct nfs_fattr * dir_attr;
636 };
637
638 struct nfs4_rename_arg {
639 const struct nfs_fh * old_dir;
640 const struct nfs_fh * new_dir;
641 const struct qstr * old_name;
642 const struct qstr * new_name;
643 const u32 * bitmask;
644 };
645
646 struct nfs4_rename_res {
647 const struct nfs_server * server;
648 struct nfs4_change_info old_cinfo;
649 struct nfs_fattr * old_fattr;
650 struct nfs4_change_info new_cinfo;
651 struct nfs_fattr * new_fattr;
652 };
653
654 struct nfs4_setclientid {
655 const nfs4_verifier * sc_verifier; /* request */
656 unsigned int sc_name_len;
657 char sc_name[32]; /* request */
658 u32 sc_prog; /* request */
659 unsigned int sc_netid_len;
660 char sc_netid[4]; /* request */
661 unsigned int sc_uaddr_len;
662 char sc_uaddr[24]; /* request */
663 u32 sc_cb_ident; /* request */
664 };
665
666 struct nfs4_statfs_arg {
667 const struct nfs_fh * fh;
668 const u32 * bitmask;
669 };
670
671 struct nfs4_server_caps_res {
672 u32 attr_bitmask[2];
673 u32 acl_bitmask;
674 u32 has_links;
675 u32 has_symlinks;
676 };
677
678 #endif /* CONFIG_NFS_V4 */
679
680 struct nfs_page;
681
682 #define NFS_PAGEVEC_SIZE (8U)
683
684 struct nfs_read_data {
685 int flags;
686 struct rpc_task task;
687 struct inode *inode;
688 struct rpc_cred *cred;
689 struct nfs_fattr fattr; /* fattr storage */
690 struct list_head pages; /* Coalesced read requests */
691 struct nfs_page *req; /* multi ops per nfs_page */
692 struct page **pagevec;
693 struct nfs_readargs args;
694 struct nfs_readres res;
695 #ifdef CONFIG_NFS_V4
696 unsigned long timestamp; /* For lease renewal */
697 #endif
698 void (*complete) (struct nfs_read_data *, int);
699 struct page *page_array[NFS_PAGEVEC_SIZE + 1];
700 };
701
702 struct nfs_write_data {
703 int flags;
704 struct rpc_task task;
705 struct inode *inode;
706 struct rpc_cred *cred;
707 struct nfs_fattr fattr;
708 struct nfs_writeverf verf;
709 struct list_head pages; /* Coalesced requests we wish to flush */
710 struct nfs_page *req; /* multi ops per nfs_page */
711 struct page **pagevec;
712 struct nfs_writeargs args; /* argument struct */
713 struct nfs_writeres res; /* result struct */
714 #ifdef CONFIG_NFS_V4
715 unsigned long timestamp; /* For lease renewal */
716 #endif
717 void (*complete) (struct nfs_write_data *, int);
718 struct page *page_array[NFS_PAGEVEC_SIZE + 1];
719 };
720
721 struct nfs_access_entry;
722
723 /*
724 * RPC procedure vector for NFSv2/NFSv3 demuxing
725 */
726 struct nfs_rpc_ops {
727 int version; /* Protocol version */
728 struct dentry_operations *dentry_ops;
729 struct inode_operations *dir_inode_ops;
730 struct inode_operations *file_inode_ops;
731
732 int (*getroot) (struct nfs_server *, struct nfs_fh *,
733 struct nfs_fsinfo *);
734 int (*getattr) (struct nfs_server *, struct nfs_fh *,
735 struct nfs_fattr *);
736 int (*setattr) (struct dentry *, struct nfs_fattr *,
737 struct iattr *);
738 int (*lookup) (struct inode *, struct qstr *,
739 struct nfs_fh *, struct nfs_fattr *);
740 int (*access) (struct inode *, struct nfs_access_entry *);
741 int (*readlink)(struct inode *, struct page *, unsigned int,
742 unsigned int);
743 int (*read) (struct nfs_read_data *);
744 int (*write) (struct nfs_write_data *);
745 int (*commit) (struct nfs_write_data *);
746 int (*create) (struct inode *, struct dentry *,
747 struct iattr *, int, struct nameidata *);
748 int (*remove) (struct inode *, struct qstr *);
749 int (*unlink_setup) (struct rpc_message *,
750 struct dentry *, struct qstr *);
751 int (*unlink_done) (struct dentry *, struct rpc_task *);
752 int (*rename) (struct inode *, struct qstr *,
753 struct inode *, struct qstr *);
754 int (*link) (struct inode *, struct inode *, struct qstr *);
755 int (*symlink) (struct inode *, struct qstr *, struct qstr *,
756 struct iattr *, struct nfs_fh *,
757 struct nfs_fattr *);
758 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
759 int (*rmdir) (struct inode *, struct qstr *);
760 int (*readdir) (struct dentry *, struct rpc_cred *,
761 u64, struct page *, unsigned int, int);
762 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
763 dev_t);
764 int (*statfs) (struct nfs_server *, struct nfs_fh *,
765 struct nfs_fsstat *);
766 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
767 struct nfs_fsinfo *);
768 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
769 struct nfs_pathconf *);
770 u32 * (*decode_dirent)(u32 *, struct nfs_entry *, int plus);
771 void (*read_setup) (struct nfs_read_data *);
772 void (*write_setup) (struct nfs_write_data *, int how);
773 void (*commit_setup) (struct nfs_write_data *, int how);
774 int (*file_open) (struct inode *, struct file *);
775 int (*file_release) (struct inode *, struct file *);
776 int (*lock)(struct file *, int, struct file_lock *);
777 void (*clear_acl_cache)(struct inode *);
778 };
779
780 /*
781 * NFS_CALL(getattr, inode, (fattr));
782 * into
783 * NFS_PROTO(inode)->getattr(fattr);
784 */
785 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
786
787 /*
788 * Function vectors etc. for the NFS client
789 */
790 extern struct nfs_rpc_ops nfs_v2_clientops;
791 extern struct nfs_rpc_ops nfs_v3_clientops;
792 extern struct nfs_rpc_ops nfs_v4_clientops;
793 extern struct rpc_version nfs_version2;
794 extern struct rpc_version nfs_version3;
795 extern struct rpc_version nfs_version4;
796
797 extern struct rpc_version nfsacl_version3;
798 extern struct rpc_program nfsacl_program;
799
800 #endif
This page took 0.064899 seconds and 5 git commands to generate.