1 #ifndef _LINUX_NFS_XDR_H
2 #define _LINUX_NFS_XDR_H
4 #include <linux/sunrpc/xprt.h>
5 #include <linux/nfsacl.h>
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.
13 #define NFS_MAX_FILE_IO_SIZE (1048576U)
14 #define NFS_DEF_FILE_IO_SIZE (4096U)
15 #define NFS_MIN_FILE_IO_SIZE (1024U)
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 */
44 __u64 nfs3; /* also nfs2 */
45 struct nfs4_fsid nfs4;
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;
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 /* NFSv4 change attribute */
63 * Info on the file system
66 struct nfs_fattr *fattr; /* Post-op attributes */
67 __u32 rtmax; /* max. read transfer size */
68 __u32 rtpref; /* pref. read transfer size */
69 __u32 rtmult; /* reads should be multiple of this */
70 __u32 wtmax; /* max. write transfer size */
71 __u32 wtpref; /* pref. write transfer size */
72 __u32 wtmult; /* writes should be multiple of this */
73 __u32 dtpref; /* pref. readdir transfer size */
75 __u32 lease_time; /* in seconds */
79 struct nfs_fattr *fattr; /* Post-op attributes */
80 __u64 tbytes; /* total size in bytes */
81 __u64 fbytes; /* # of free bytes */
82 __u64 abytes; /* # of bytes available to user */
83 __u64 tfiles; /* # of files */
84 __u64 ffiles; /* # of free files */
85 __u64 afiles; /* # of files available to user */
89 __u32 tsize; /* Server transfer size */
90 __u32 bsize; /* Filesystem block size */
91 __u32 blocks; /* No. of "bsize" blocks on filesystem */
92 __u32 bfree; /* No. of free "bsize" blocks */
93 __u32 bavail; /* No. of available "bsize" blocks */
97 struct nfs_fattr *fattr; /* Post-op attributes */
98 __u32 max_link; /* max # of hard links */
99 __u32 max_namelen; /* max name length */
102 struct nfs4_change_info {
110 * Arguments to the open call.
112 struct nfs_openargs {
113 const struct nfs_fh * fh;
114 struct nfs_seqid * seqid;
119 struct iattr * attrs; /* UNCHECKED, GUARDED */
120 nfs4_verifier verifier; /* EXCLUSIVE */
121 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
122 int delegation_type; /* CLAIM_PREVIOUS */
124 const struct qstr * name;
125 const struct nfs_server *server; /* Needed for ID mapping */
131 nfs4_stateid stateid;
133 struct nfs4_change_info cinfo;
135 struct nfs_fattr * f_attr;
136 struct nfs_fattr * dir_attr;
137 const struct nfs_server *server;
139 nfs4_stateid delegation;
145 * Arguments to the open_confirm call.
147 struct nfs_open_confirmargs {
148 const struct nfs_fh * fh;
149 nfs4_stateid * stateid;
150 struct nfs_seqid * seqid;
153 struct nfs_open_confirmres {
154 nfs4_stateid stateid;
158 * Arguments to the close call.
160 struct nfs_closeargs {
162 nfs4_stateid * stateid;
163 struct nfs_seqid * seqid;
168 struct nfs_closeres {
169 nfs4_stateid stateid;
170 struct nfs_fattr * fattr;
171 const struct nfs_server *server;
174 * * Arguments to the lock,lockt, and locku call.
181 struct nfs_lock_args {
183 struct file_lock * fl;
184 struct nfs_seqid * lock_seqid;
185 nfs4_stateid * lock_stateid;
186 struct nfs_seqid * open_seqid;
187 nfs4_stateid * open_stateid;
188 struct nfs_lowner lock_owner;
189 unsigned char block : 1;
190 unsigned char reclaim : 1;
191 unsigned char new_lock_owner : 1;
194 struct nfs_lock_res {
195 nfs4_stateid stateid;
198 struct nfs_locku_args {
200 struct file_lock * fl;
201 struct nfs_seqid * seqid;
202 nfs4_stateid * stateid;
205 struct nfs_locku_res {
206 nfs4_stateid stateid;
209 struct nfs_lockt_args {
211 struct file_lock * fl;
212 struct nfs_lowner lock_owner;
215 struct nfs_lockt_res {
216 struct file_lock * denied; /* LOCK, LOCKT failed */
219 struct nfs4_delegreturnargs {
220 const struct nfs_fh *fhandle;
221 const nfs4_stateid *stateid;
225 struct nfs4_delegreturnres {
226 struct nfs_fattr * fattr;
227 const struct nfs_server *server;
231 * Arguments to the read call.
233 struct nfs_readargs {
235 struct nfs_open_context *context;
239 struct page ** pages;
243 struct nfs_fattr * fattr;
249 * Arguments to the write call.
251 struct nfs_writeargs {
253 struct nfs_open_context *context;
256 enum nfs3_stable_how stable;
258 struct page ** pages;
262 struct nfs_writeverf {
263 enum nfs3_stable_how committed;
267 struct nfs_writeres {
268 struct nfs_fattr * fattr;
269 struct nfs_writeverf * verf;
271 const struct nfs_server *server;
275 * Argument struct for decode_entry function
285 struct nfs_fattr * fattr;
289 * The following types are for NFSv2 only.
291 struct nfs_sattrargs {
293 struct iattr * sattr;
296 struct nfs_diropargs {
302 struct nfs_createargs {
306 struct iattr * sattr;
309 struct nfs_renameargs {
310 struct nfs_fh * fromfh;
311 const char * fromname;
312 unsigned int fromlen;
313 struct nfs_fh * tofh;
318 struct nfs_setattrargs {
320 nfs4_stateid stateid;
322 const struct nfs_server * server; /* Needed for name mapping */
326 struct nfs_setaclargs {
329 unsigned int acl_pgbase;
330 struct page ** acl_pages;
333 struct nfs_getaclargs {
336 unsigned int acl_pgbase;
337 struct page ** acl_pages;
340 struct nfs_setattrres {
341 struct nfs_fattr * fattr;
342 const struct nfs_server * server;
345 struct nfs_linkargs {
346 struct nfs_fh * fromfh;
347 struct nfs_fh * tofh;
352 struct nfs_symlinkargs {
353 struct nfs_fh * fromfh;
354 const char * fromname;
355 unsigned int fromlen;
358 struct iattr * sattr;
361 struct nfs_readdirargs {
365 struct page ** pages;
368 struct nfs3_getaclargs {
371 struct page ** pages;
374 struct nfs3_setaclargs {
375 struct inode * inode;
377 struct posix_acl * acl_access;
378 struct posix_acl * acl_default;
379 struct page ** pages;
384 struct nfs_fattr * fattr;
387 struct nfs_readlinkargs {
391 struct page ** pages;
394 struct nfs3_sattrargs {
396 struct iattr * sattr;
398 struct timespec guardtime;
401 struct nfs3_diropargs {
407 struct nfs3_accessargs {
412 struct nfs3_createargs {
416 struct iattr * sattr;
417 enum nfs3_createmode createmode;
421 struct nfs3_mkdirargs {
425 struct iattr * sattr;
428 struct nfs3_symlinkargs {
429 struct nfs_fh * fromfh;
430 const char * fromname;
431 unsigned int fromlen;
434 struct iattr * sattr;
437 struct nfs3_mknodargs {
441 enum nfs3_ftype type;
442 struct iattr * sattr;
446 struct nfs3_renameargs {
447 struct nfs_fh * fromfh;
448 const char * fromname;
449 unsigned int fromlen;
450 struct nfs_fh * tofh;
455 struct nfs3_linkargs {
456 struct nfs_fh * fromfh;
457 struct nfs_fh * tofh;
462 struct nfs3_readdirargs {
468 struct page ** pages;
471 struct nfs3_diropres {
472 struct nfs_fattr * dir_attr;
474 struct nfs_fattr * fattr;
477 struct nfs3_accessres {
478 struct nfs_fattr * fattr;
482 struct nfs3_readlinkargs {
486 struct page ** pages;
489 struct nfs3_renameres {
490 struct nfs_fattr * fromattr;
491 struct nfs_fattr * toattr;
494 struct nfs3_linkres {
495 struct nfs_fattr * dir_attr;
496 struct nfs_fattr * fattr;
499 struct nfs3_readdirres {
500 struct nfs_fattr * dir_attr;
505 struct nfs3_getaclres {
506 struct nfs_fattr * fattr;
508 unsigned int acl_access_count;
509 unsigned int acl_default_count;
510 struct posix_acl * acl_access;
511 struct posix_acl * acl_default;
516 typedef u64 clientid4;
518 struct nfs4_accessargs {
519 const struct nfs_fh * fh;
523 struct nfs4_accessres {
528 struct nfs4_create_arg {
531 struct qstr * symlink; /* NF4LNK */
535 } device; /* NF4BLK, NF4CHR */
537 const struct qstr * name;
538 const struct nfs_server * server;
539 const struct iattr * attrs;
540 const struct nfs_fh * dir_fh;
544 struct nfs4_create_res {
545 const struct nfs_server * server;
547 struct nfs_fattr * fattr;
548 struct nfs4_change_info dir_cinfo;
549 struct nfs_fattr * dir_fattr;
552 struct nfs4_fsinfo_arg {
553 const struct nfs_fh * fh;
557 struct nfs4_getattr_arg {
558 const struct nfs_fh * fh;
562 struct nfs4_getattr_res {
563 const struct nfs_server * server;
564 struct nfs_fattr * fattr;
567 struct nfs4_link_arg {
568 const struct nfs_fh * fh;
569 const struct nfs_fh * dir_fh;
570 const struct qstr * name;
574 struct nfs4_link_res {
575 const struct nfs_server * server;
576 struct nfs_fattr * fattr;
577 struct nfs4_change_info cinfo;
578 struct nfs_fattr * dir_attr;
582 struct nfs4_lookup_arg {
583 const struct nfs_fh * dir_fh;
584 const struct qstr * name;
588 struct nfs4_lookup_res {
589 const struct nfs_server * server;
590 struct nfs_fattr * fattr;
594 struct nfs4_lookup_root_arg {
598 struct nfs4_pathconf_arg {
599 const struct nfs_fh * fh;
603 struct nfs4_readdir_arg {
604 const struct nfs_fh * fh;
606 nfs4_verifier verifier;
608 struct page ** pages; /* zero-copy data */
609 unsigned int pgbase; /* zero-copy data */
613 struct nfs4_readdir_res {
614 nfs4_verifier verifier;
618 struct nfs4_readlink {
619 const struct nfs_fh * fh;
621 unsigned int pglen; /* zero-copy data */
622 struct page ** pages; /* zero-copy data */
625 struct nfs4_remove_arg {
626 const struct nfs_fh * fh;
627 const struct qstr * name;
631 struct nfs4_remove_res {
632 const struct nfs_server * server;
633 struct nfs4_change_info cinfo;
634 struct nfs_fattr * dir_attr;
637 struct nfs4_rename_arg {
638 const struct nfs_fh * old_dir;
639 const struct nfs_fh * new_dir;
640 const struct qstr * old_name;
641 const struct qstr * new_name;
645 struct nfs4_rename_res {
646 const struct nfs_server * server;
647 struct nfs4_change_info old_cinfo;
648 struct nfs_fattr * old_fattr;
649 struct nfs4_change_info new_cinfo;
650 struct nfs_fattr * new_fattr;
653 struct nfs4_setclientid {
654 const nfs4_verifier * sc_verifier; /* request */
655 unsigned int sc_name_len;
656 char sc_name[32]; /* request */
657 u32 sc_prog; /* request */
658 unsigned int sc_netid_len;
659 char sc_netid[4]; /* request */
660 unsigned int sc_uaddr_len;
661 char sc_uaddr[24]; /* request */
662 u32 sc_cb_ident; /* request */
665 struct nfs4_statfs_arg {
666 const struct nfs_fh * fh;
670 struct nfs4_server_caps_res {
677 #endif /* CONFIG_NFS_V4 */
681 #define NFS_PAGEVEC_SIZE (8U)
683 struct nfs_read_data {
685 struct rpc_task task;
687 struct rpc_cred *cred;
688 struct nfs_fattr fattr; /* fattr storage */
689 struct list_head pages; /* Coalesced read requests */
690 struct nfs_page *req; /* multi ops per nfs_page */
691 struct page **pagevec;
692 struct nfs_readargs args;
693 struct nfs_readres res;
695 unsigned long timestamp; /* For lease renewal */
697 struct page *page_array[NFS_PAGEVEC_SIZE + 1];
700 struct nfs_write_data {
702 struct rpc_task task;
704 struct rpc_cred *cred;
705 struct nfs_fattr fattr;
706 struct nfs_writeverf verf;
707 struct list_head pages; /* Coalesced requests we wish to flush */
708 struct nfs_page *req; /* multi ops per nfs_page */
709 struct page **pagevec;
710 struct nfs_writeargs args; /* argument struct */
711 struct nfs_writeres res; /* result struct */
713 unsigned long timestamp; /* For lease renewal */
715 struct page *page_array[NFS_PAGEVEC_SIZE + 1];
718 struct nfs_access_entry;
721 * RPC procedure vector for NFSv2/NFSv3 demuxing
724 int version; /* Protocol version */
725 struct dentry_operations *dentry_ops;
726 struct inode_operations *dir_inode_ops;
727 struct inode_operations *file_inode_ops;
729 int (*getroot) (struct nfs_server *, struct nfs_fh *,
730 struct nfs_fsinfo *);
731 int (*getattr) (struct nfs_server *, struct nfs_fh *,
733 int (*setattr) (struct dentry *, struct nfs_fattr *,
735 int (*lookup) (struct inode *, struct qstr *,
736 struct nfs_fh *, struct nfs_fattr *);
737 int (*access) (struct inode *, struct nfs_access_entry *);
738 int (*readlink)(struct inode *, struct page *, unsigned int,
740 int (*read) (struct nfs_read_data *);
741 int (*write) (struct nfs_write_data *);
742 int (*commit) (struct nfs_write_data *);
743 int (*create) (struct inode *, struct dentry *,
744 struct iattr *, int, struct nameidata *);
745 int (*remove) (struct inode *, struct qstr *);
746 int (*unlink_setup) (struct rpc_message *,
747 struct dentry *, struct qstr *);
748 int (*unlink_done) (struct dentry *, struct rpc_task *);
749 int (*rename) (struct inode *, struct qstr *,
750 struct inode *, struct qstr *);
751 int (*link) (struct inode *, struct inode *, struct qstr *);
752 int (*symlink) (struct inode *, struct qstr *, struct qstr *,
753 struct iattr *, struct nfs_fh *,
755 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
756 int (*rmdir) (struct inode *, struct qstr *);
757 int (*readdir) (struct dentry *, struct rpc_cred *,
758 u64, struct page *, unsigned int, int);
759 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
761 int (*statfs) (struct nfs_server *, struct nfs_fh *,
762 struct nfs_fsstat *);
763 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
764 struct nfs_fsinfo *);
765 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
766 struct nfs_pathconf *);
767 u32 * (*decode_dirent)(u32 *, struct nfs_entry *, int plus);
768 void (*read_setup) (struct nfs_read_data *);
769 int (*read_done) (struct rpc_task *, struct nfs_read_data *);
770 void (*write_setup) (struct nfs_write_data *, int how);
771 int (*write_done) (struct rpc_task *, struct nfs_write_data *);
772 void (*commit_setup) (struct nfs_write_data *, int how);
773 int (*commit_done) (struct rpc_task *, struct nfs_write_data *);
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 *);
781 * NFS_CALL(getattr, inode, (fattr));
783 * NFS_PROTO(inode)->getattr(fattr);
785 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
788 * Function vectors etc. for the NFS client
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;
797 extern struct rpc_version nfsacl_version3;
798 extern struct rpc_program nfsacl_program;