NFSv4: locking XDR cleanup
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / nfs_xdr.h
blobb8b0eed98ec9f43146c33f8f78ff98a11fe148b1
1 #ifndef _LINUX_NFS_XDR_H
2 #define _LINUX_NFS_XDR_H
4 #include <linux/sunrpc/xprt.h>
5 #include <linux/nfsacl.h>
7 struct nfs4_fsid {
8 __u64 major;
9 __u64 minor;
12 struct nfs_fattr {
13 unsigned short valid; /* which fields are valid */
14 __u64 pre_size; /* pre_op_attr.size */
15 struct timespec pre_mtime; /* pre_op_attr.mtime */
16 struct timespec pre_ctime; /* pre_op_attr.ctime */
17 enum nfs_ftype type; /* always use NFSv2 types */
18 __u32 mode;
19 __u32 nlink;
20 __u32 uid;
21 __u32 gid;
22 __u64 size;
23 union {
24 struct {
25 __u32 blocksize;
26 __u32 blocks;
27 } nfs2;
28 struct {
29 __u64 used;
30 } nfs3;
31 } du;
32 dev_t rdev;
33 union {
34 __u64 nfs3; /* also nfs2 */
35 struct nfs4_fsid nfs4;
36 } fsid_u;
37 __u64 fileid;
38 struct timespec atime;
39 struct timespec mtime;
40 struct timespec ctime;
41 __u32 bitmap[2]; /* NFSv4 returned attribute bitmap */
42 __u64 change_attr; /* NFSv4 change attribute */
43 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
44 unsigned long time_start;
47 #define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */
48 #define NFS_ATTR_FATTR 0x0002 /* post-op attributes */
49 #define NFS_ATTR_FATTR_V3 0x0004 /* NFSv3 attributes */
50 #define NFS_ATTR_FATTR_V4 0x0008
51 #define NFS_ATTR_PRE_CHANGE 0x0010
54 * Info on the file system
56 struct nfs_fsinfo {
57 struct nfs_fattr *fattr; /* Post-op attributes */
58 __u32 rtmax; /* max. read transfer size */
59 __u32 rtpref; /* pref. read transfer size */
60 __u32 rtmult; /* reads should be multiple of this */
61 __u32 wtmax; /* max. write transfer size */
62 __u32 wtpref; /* pref. write transfer size */
63 __u32 wtmult; /* writes should be multiple of this */
64 __u32 dtpref; /* pref. readdir transfer size */
65 __u64 maxfilesize;
66 __u32 lease_time; /* in seconds */
69 struct nfs_fsstat {
70 struct nfs_fattr *fattr; /* Post-op attributes */
71 __u64 tbytes; /* total size in bytes */
72 __u64 fbytes; /* # of free bytes */
73 __u64 abytes; /* # of bytes available to user */
74 __u64 tfiles; /* # of files */
75 __u64 ffiles; /* # of free files */
76 __u64 afiles; /* # of files available to user */
79 struct nfs2_fsstat {
80 __u32 tsize; /* Server transfer size */
81 __u32 bsize; /* Filesystem block size */
82 __u32 blocks; /* No. of "bsize" blocks on filesystem */
83 __u32 bfree; /* No. of free "bsize" blocks */
84 __u32 bavail; /* No. of available "bsize" blocks */
87 struct nfs_pathconf {
88 struct nfs_fattr *fattr; /* Post-op attributes */
89 __u32 max_link; /* max # of hard links */
90 __u32 max_namelen; /* max name length */
93 struct nfs4_change_info {
94 u32 atomic;
95 u64 before;
96 u64 after;
99 struct nfs_seqid;
101 * Arguments to the open call.
103 struct nfs_openargs {
104 const struct nfs_fh * fh;
105 struct nfs_seqid * seqid;
106 int open_flags;
107 __u64 clientid;
108 __u32 id;
109 union {
110 struct iattr * attrs; /* UNCHECKED, GUARDED */
111 nfs4_verifier verifier; /* EXCLUSIVE */
112 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
113 int delegation_type; /* CLAIM_PREVIOUS */
114 } u;
115 const struct qstr * name;
116 const struct nfs_server *server; /* Needed for ID mapping */
117 const u32 * bitmask;
118 __u32 claim;
121 struct nfs_openres {
122 nfs4_stateid stateid;
123 struct nfs_fh fh;
124 struct nfs4_change_info cinfo;
125 __u32 rflags;
126 struct nfs_fattr * f_attr;
127 struct nfs_fattr * dir_attr;
128 const struct nfs_server *server;
129 int delegation_type;
130 nfs4_stateid delegation;
131 __u32 do_recall;
132 __u64 maxsize;
136 * Arguments to the open_confirm call.
138 struct nfs_open_confirmargs {
139 const struct nfs_fh * fh;
140 nfs4_stateid * stateid;
141 struct nfs_seqid * seqid;
144 struct nfs_open_confirmres {
145 nfs4_stateid stateid;
149 * Arguments to the close call.
151 struct nfs_closeargs {
152 struct nfs_fh * fh;
153 nfs4_stateid * stateid;
154 struct nfs_seqid * seqid;
155 int open_flags;
156 const u32 * bitmask;
159 struct nfs_closeres {
160 nfs4_stateid stateid;
161 struct nfs_fattr * fattr;
162 const struct nfs_server *server;
165 * * Arguments to the lock,lockt, and locku call.
166 * */
167 struct nfs_lowner {
168 __u64 clientid;
169 u32 id;
172 struct nfs_lock_args {
173 struct nfs_fh * fh;
174 struct file_lock * fl;
175 struct nfs_seqid * lock_seqid;
176 nfs4_stateid * lock_stateid;
177 struct nfs_seqid * open_seqid;
178 nfs4_stateid * open_stateid;
179 struct nfs_lowner lock_owner;
180 unsigned char block : 1;
181 unsigned char reclaim : 1;
182 unsigned char new_lock_owner : 1;
185 struct nfs_lock_res {
186 nfs4_stateid stateid;
189 struct nfs_locku_args {
190 struct nfs_fh * fh;
191 struct file_lock * fl;
192 struct nfs_seqid * seqid;
193 nfs4_stateid * stateid;
196 struct nfs_locku_res {
197 nfs4_stateid stateid;
200 struct nfs_lockt_args {
201 struct nfs_fh * fh;
202 struct file_lock * fl;
203 struct nfs_lowner lock_owner;
206 struct nfs_lockt_res {
207 struct file_lock * denied; /* LOCK, LOCKT failed */
210 struct nfs4_delegreturnargs {
211 const struct nfs_fh *fhandle;
212 const nfs4_stateid *stateid;
216 * Arguments to the read call.
219 #define NFS_READ_MAXIOV (9U)
220 #if (NFS_READ_MAXIOV > (MAX_IOVEC -2))
221 #error "NFS_READ_MAXIOV is too large"
222 #endif
224 struct nfs_readargs {
225 struct nfs_fh * fh;
226 struct nfs_open_context *context;
227 __u64 offset;
228 __u32 count;
229 unsigned int pgbase;
230 struct page ** pages;
233 struct nfs_readres {
234 struct nfs_fattr * fattr;
235 __u32 count;
236 int eof;
240 * Arguments to the write call.
242 #define NFS_WRITE_MAXIOV (9U)
243 #if (NFS_WRITE_MAXIOV > (MAX_IOVEC -2))
244 #error "NFS_WRITE_MAXIOV is too large"
245 #endif
247 struct nfs_writeargs {
248 struct nfs_fh * fh;
249 struct nfs_open_context *context;
250 __u64 offset;
251 __u32 count;
252 enum nfs3_stable_how stable;
253 unsigned int pgbase;
254 struct page ** pages;
255 const u32 * bitmask;
258 struct nfs_writeverf {
259 enum nfs3_stable_how committed;
260 __u32 verifier[2];
263 struct nfs_writeres {
264 struct nfs_fattr * fattr;
265 struct nfs_writeverf * verf;
266 __u32 count;
267 const struct nfs_server *server;
271 * Argument struct for decode_entry function
273 struct nfs_entry {
274 __u64 ino;
275 __u64 cookie,
276 prev_cookie;
277 const char * name;
278 unsigned int len;
279 int eof;
280 struct nfs_fh * fh;
281 struct nfs_fattr * fattr;
285 * The following types are for NFSv2 only.
287 struct nfs_sattrargs {
288 struct nfs_fh * fh;
289 struct iattr * sattr;
292 struct nfs_diropargs {
293 struct nfs_fh * fh;
294 const char * name;
295 unsigned int len;
298 struct nfs_createargs {
299 struct nfs_fh * fh;
300 const char * name;
301 unsigned int len;
302 struct iattr * sattr;
305 struct nfs_renameargs {
306 struct nfs_fh * fromfh;
307 const char * fromname;
308 unsigned int fromlen;
309 struct nfs_fh * tofh;
310 const char * toname;
311 unsigned int tolen;
314 struct nfs_setattrargs {
315 struct nfs_fh * fh;
316 nfs4_stateid stateid;
317 struct iattr * iap;
318 const struct nfs_server * server; /* Needed for name mapping */
319 const u32 * bitmask;
322 struct nfs_setaclargs {
323 struct nfs_fh * fh;
324 size_t acl_len;
325 unsigned int acl_pgbase;
326 struct page ** acl_pages;
329 struct nfs_getaclargs {
330 struct nfs_fh * fh;
331 size_t acl_len;
332 unsigned int acl_pgbase;
333 struct page ** acl_pages;
336 struct nfs_setattrres {
337 struct nfs_fattr * fattr;
338 const struct nfs_server * server;
341 struct nfs_linkargs {
342 struct nfs_fh * fromfh;
343 struct nfs_fh * tofh;
344 const char * toname;
345 unsigned int tolen;
348 struct nfs_symlinkargs {
349 struct nfs_fh * fromfh;
350 const char * fromname;
351 unsigned int fromlen;
352 const char * topath;
353 unsigned int tolen;
354 struct iattr * sattr;
357 struct nfs_readdirargs {
358 struct nfs_fh * fh;
359 __u32 cookie;
360 unsigned int count;
361 struct page ** pages;
364 struct nfs3_getaclargs {
365 struct nfs_fh * fh;
366 int mask;
367 struct page ** pages;
370 struct nfs3_setaclargs {
371 struct inode * inode;
372 int mask;
373 struct posix_acl * acl_access;
374 struct posix_acl * acl_default;
375 struct page ** pages;
378 struct nfs_diropok {
379 struct nfs_fh * fh;
380 struct nfs_fattr * fattr;
383 struct nfs_readlinkargs {
384 struct nfs_fh * fh;
385 unsigned int pgbase;
386 unsigned int pglen;
387 struct page ** pages;
390 struct nfs3_sattrargs {
391 struct nfs_fh * fh;
392 struct iattr * sattr;
393 unsigned int guard;
394 struct timespec guardtime;
397 struct nfs3_diropargs {
398 struct nfs_fh * fh;
399 const char * name;
400 unsigned int len;
403 struct nfs3_accessargs {
404 struct nfs_fh * fh;
405 __u32 access;
408 struct nfs3_createargs {
409 struct nfs_fh * fh;
410 const char * name;
411 unsigned int len;
412 struct iattr * sattr;
413 enum nfs3_createmode createmode;
414 __u32 verifier[2];
417 struct nfs3_mkdirargs {
418 struct nfs_fh * fh;
419 const char * name;
420 unsigned int len;
421 struct iattr * sattr;
424 struct nfs3_symlinkargs {
425 struct nfs_fh * fromfh;
426 const char * fromname;
427 unsigned int fromlen;
428 const char * topath;
429 unsigned int tolen;
430 struct iattr * sattr;
433 struct nfs3_mknodargs {
434 struct nfs_fh * fh;
435 const char * name;
436 unsigned int len;
437 enum nfs3_ftype type;
438 struct iattr * sattr;
439 dev_t rdev;
442 struct nfs3_renameargs {
443 struct nfs_fh * fromfh;
444 const char * fromname;
445 unsigned int fromlen;
446 struct nfs_fh * tofh;
447 const char * toname;
448 unsigned int tolen;
451 struct nfs3_linkargs {
452 struct nfs_fh * fromfh;
453 struct nfs_fh * tofh;
454 const char * toname;
455 unsigned int tolen;
458 struct nfs3_readdirargs {
459 struct nfs_fh * fh;
460 __u64 cookie;
461 __u32 verf[2];
462 int plus;
463 unsigned int count;
464 struct page ** pages;
467 struct nfs3_diropres {
468 struct nfs_fattr * dir_attr;
469 struct nfs_fh * fh;
470 struct nfs_fattr * fattr;
473 struct nfs3_accessres {
474 struct nfs_fattr * fattr;
475 __u32 access;
478 struct nfs3_readlinkargs {
479 struct nfs_fh * fh;
480 unsigned int pgbase;
481 unsigned int pglen;
482 struct page ** pages;
485 struct nfs3_renameres {
486 struct nfs_fattr * fromattr;
487 struct nfs_fattr * toattr;
490 struct nfs3_linkres {
491 struct nfs_fattr * dir_attr;
492 struct nfs_fattr * fattr;
495 struct nfs3_readdirres {
496 struct nfs_fattr * dir_attr;
497 __u32 * verf;
498 int plus;
501 struct nfs3_getaclres {
502 struct nfs_fattr * fattr;
503 int mask;
504 unsigned int acl_access_count;
505 unsigned int acl_default_count;
506 struct posix_acl * acl_access;
507 struct posix_acl * acl_default;
510 #ifdef CONFIG_NFS_V4
512 typedef u64 clientid4;
514 struct nfs4_accessargs {
515 const struct nfs_fh * fh;
516 u32 access;
519 struct nfs4_accessres {
520 u32 supported;
521 u32 access;
524 struct nfs4_create_arg {
525 u32 ftype;
526 union {
527 struct qstr * symlink; /* NF4LNK */
528 struct {
529 u32 specdata1;
530 u32 specdata2;
531 } device; /* NF4BLK, NF4CHR */
532 } u;
533 const struct qstr * name;
534 const struct nfs_server * server;
535 const struct iattr * attrs;
536 const struct nfs_fh * dir_fh;
537 const u32 * bitmask;
540 struct nfs4_create_res {
541 const struct nfs_server * server;
542 struct nfs_fh * fh;
543 struct nfs_fattr * fattr;
544 struct nfs4_change_info dir_cinfo;
545 struct nfs_fattr * dir_fattr;
548 struct nfs4_fsinfo_arg {
549 const struct nfs_fh * fh;
550 const u32 * bitmask;
553 struct nfs4_getattr_arg {
554 const struct nfs_fh * fh;
555 const u32 * bitmask;
558 struct nfs4_getattr_res {
559 const struct nfs_server * server;
560 struct nfs_fattr * fattr;
563 struct nfs4_link_arg {
564 const struct nfs_fh * fh;
565 const struct nfs_fh * dir_fh;
566 const struct qstr * name;
567 const u32 * bitmask;
570 struct nfs4_link_res {
571 const struct nfs_server * server;
572 struct nfs_fattr * fattr;
573 struct nfs4_change_info cinfo;
574 struct nfs_fattr * dir_attr;
578 struct nfs4_lookup_arg {
579 const struct nfs_fh * dir_fh;
580 const struct qstr * name;
581 const u32 * bitmask;
584 struct nfs4_lookup_res {
585 const struct nfs_server * server;
586 struct nfs_fattr * fattr;
587 struct nfs_fh * fh;
590 struct nfs4_lookup_root_arg {
591 const u32 * bitmask;
594 struct nfs4_pathconf_arg {
595 const struct nfs_fh * fh;
596 const u32 * bitmask;
599 struct nfs4_readdir_arg {
600 const struct nfs_fh * fh;
601 u64 cookie;
602 nfs4_verifier verifier;
603 u32 count;
604 struct page ** pages; /* zero-copy data */
605 unsigned int pgbase; /* zero-copy data */
606 const u32 * bitmask;
609 struct nfs4_readdir_res {
610 nfs4_verifier verifier;
611 unsigned int pgbase;
614 struct nfs4_readlink {
615 const struct nfs_fh * fh;
616 unsigned int pgbase;
617 unsigned int pglen; /* zero-copy data */
618 struct page ** pages; /* zero-copy data */
621 struct nfs4_remove_arg {
622 const struct nfs_fh * fh;
623 const struct qstr * name;
624 const u32 * bitmask;
627 struct nfs4_remove_res {
628 const struct nfs_server * server;
629 struct nfs4_change_info cinfo;
630 struct nfs_fattr * dir_attr;
633 struct nfs4_rename_arg {
634 const struct nfs_fh * old_dir;
635 const struct nfs_fh * new_dir;
636 const struct qstr * old_name;
637 const struct qstr * new_name;
638 const u32 * bitmask;
641 struct nfs4_rename_res {
642 const struct nfs_server * server;
643 struct nfs4_change_info old_cinfo;
644 struct nfs_fattr * old_fattr;
645 struct nfs4_change_info new_cinfo;
646 struct nfs_fattr * new_fattr;
649 struct nfs4_setclientid {
650 const nfs4_verifier * sc_verifier; /* request */
651 unsigned int sc_name_len;
652 char sc_name[32]; /* request */
653 u32 sc_prog; /* request */
654 unsigned int sc_netid_len;
655 char sc_netid[4]; /* request */
656 unsigned int sc_uaddr_len;
657 char sc_uaddr[24]; /* request */
658 u32 sc_cb_ident; /* request */
661 struct nfs4_statfs_arg {
662 const struct nfs_fh * fh;
663 const u32 * bitmask;
666 struct nfs4_server_caps_res {
667 u32 attr_bitmask[2];
668 u32 acl_bitmask;
669 u32 has_links;
670 u32 has_symlinks;
673 #endif /* CONFIG_NFS_V4 */
675 struct nfs_page;
677 struct nfs_read_data {
678 int flags;
679 struct rpc_task task;
680 struct inode *inode;
681 struct rpc_cred *cred;
682 struct nfs_fattr fattr; /* fattr storage */
683 struct list_head pages; /* Coalesced read requests */
684 struct nfs_page *req; /* multi ops per nfs_page */
685 struct page *pagevec[NFS_READ_MAXIOV];
686 struct nfs_readargs args;
687 struct nfs_readres res;
688 #ifdef CONFIG_NFS_V4
689 unsigned long timestamp; /* For lease renewal */
690 #endif
691 void (*complete) (struct nfs_read_data *, int);
694 struct nfs_write_data {
695 int flags;
696 struct rpc_task task;
697 struct inode *inode;
698 struct rpc_cred *cred;
699 struct nfs_fattr fattr;
700 struct nfs_writeverf verf;
701 struct list_head pages; /* Coalesced requests we wish to flush */
702 struct nfs_page *req; /* multi ops per nfs_page */
703 struct page *pagevec[NFS_WRITE_MAXIOV];
704 struct nfs_writeargs args; /* argument struct */
705 struct nfs_writeres res; /* result struct */
706 #ifdef CONFIG_NFS_V4
707 unsigned long timestamp; /* For lease renewal */
708 #endif
709 void (*complete) (struct nfs_write_data *, int);
712 struct nfs_access_entry;
715 * RPC procedure vector for NFSv2/NFSv3 demuxing
717 struct nfs_rpc_ops {
718 int version; /* Protocol version */
719 struct dentry_operations *dentry_ops;
720 struct inode_operations *dir_inode_ops;
721 struct inode_operations *file_inode_ops;
723 int (*getroot) (struct nfs_server *, struct nfs_fh *,
724 struct nfs_fsinfo *);
725 int (*getattr) (struct nfs_server *, struct nfs_fh *,
726 struct nfs_fattr *);
727 int (*setattr) (struct dentry *, struct nfs_fattr *,
728 struct iattr *);
729 int (*lookup) (struct inode *, struct qstr *,
730 struct nfs_fh *, struct nfs_fattr *);
731 int (*access) (struct inode *, struct nfs_access_entry *);
732 int (*readlink)(struct inode *, struct page *, unsigned int,
733 unsigned int);
734 int (*read) (struct nfs_read_data *);
735 int (*write) (struct nfs_write_data *);
736 int (*commit) (struct nfs_write_data *);
737 int (*create) (struct inode *, struct dentry *,
738 struct iattr *, int, struct nameidata *);
739 int (*remove) (struct inode *, struct qstr *);
740 int (*unlink_setup) (struct rpc_message *,
741 struct dentry *, struct qstr *);
742 int (*unlink_done) (struct dentry *, struct rpc_task *);
743 int (*rename) (struct inode *, struct qstr *,
744 struct inode *, struct qstr *);
745 int (*link) (struct inode *, struct inode *, struct qstr *);
746 int (*symlink) (struct inode *, struct qstr *, struct qstr *,
747 struct iattr *, struct nfs_fh *,
748 struct nfs_fattr *);
749 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
750 int (*rmdir) (struct inode *, struct qstr *);
751 int (*readdir) (struct dentry *, struct rpc_cred *,
752 u64, struct page *, unsigned int, int);
753 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
754 dev_t);
755 int (*statfs) (struct nfs_server *, struct nfs_fh *,
756 struct nfs_fsstat *);
757 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
758 struct nfs_fsinfo *);
759 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
760 struct nfs_pathconf *);
761 u32 * (*decode_dirent)(u32 *, struct nfs_entry *, int plus);
762 void (*read_setup) (struct nfs_read_data *);
763 void (*write_setup) (struct nfs_write_data *, int how);
764 void (*commit_setup) (struct nfs_write_data *, int how);
765 int (*file_open) (struct inode *, struct file *);
766 int (*file_release) (struct inode *, struct file *);
767 int (*lock)(struct file *, int, struct file_lock *);
768 void (*clear_acl_cache)(struct inode *);
772 * NFS_CALL(getattr, inode, (fattr));
773 * into
774 * NFS_PROTO(inode)->getattr(fattr);
776 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
779 * Function vectors etc. for the NFS client
781 extern struct nfs_rpc_ops nfs_v2_clientops;
782 extern struct nfs_rpc_ops nfs_v3_clientops;
783 extern struct nfs_rpc_ops nfs_v4_clientops;
784 extern struct rpc_version nfs_version2;
785 extern struct rpc_version nfs_version3;
786 extern struct rpc_version nfs_version4;
788 extern struct rpc_version nfsacl_version3;
789 extern struct rpc_program nfsacl_program;
791 #endif