1 #ifndef _LINUX_NFS_XDR_H
2 #define _LINUX_NFS_XDR_H
4 #include <linux/nfsacl.h>
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.
12 #define NFS_MAX_FILE_IO_SIZE (1048576U)
13 #define NFS_DEF_FILE_IO_SIZE (4096U)
14 #define NFS_MIN_FILE_IO_SIZE (1024U)
22 * Helper for checking equality between 2 fsids.
24 static inline int nfs_fsid_equal(const struct nfs_fsid *a, const struct nfs_fsid *b)
26 return a->major == b->major && a->minor == b->minor;
30 unsigned short valid; /* which fields are valid */
31 __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 */
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 */
58 unsigned long time_start;
61 #define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */
62 #define NFS_ATTR_FATTR 0x0002 /* post-op attributes */
63 #define NFS_ATTR_FATTR_V3 0x0004 /* NFSv3 attributes */
64 #define NFS_ATTR_FATTR_V4 0x0008 /* NFSv4 change attribute */
65 #define NFS_ATTR_FATTR_V4_REFERRAL 0x0010 /* NFSv4 referral */
68 * Info on the file system
71 struct nfs_fattr *fattr; /* Post-op attributes */
72 __u32 rtmax; /* max. read transfer size */
73 __u32 rtpref; /* pref. read transfer size */
74 __u32 rtmult; /* reads should be multiple of this */
75 __u32 wtmax; /* max. write transfer size */
76 __u32 wtpref; /* pref. write transfer size */
77 __u32 wtmult; /* writes should be multiple of this */
78 __u32 dtpref; /* pref. readdir transfer size */
80 __u32 lease_time; /* in seconds */
84 struct nfs_fattr *fattr; /* Post-op attributes */
85 __u64 tbytes; /* total size in bytes */
86 __u64 fbytes; /* # of free bytes */
87 __u64 abytes; /* # of bytes available to user */
88 __u64 tfiles; /* # of files */
89 __u64 ffiles; /* # of free files */
90 __u64 afiles; /* # of files available to user */
94 __u32 tsize; /* Server transfer size */
95 __u32 bsize; /* Filesystem block size */
96 __u32 blocks; /* No. of "bsize" blocks on filesystem */
97 __u32 bfree; /* No. of free "bsize" blocks */
98 __u32 bavail; /* No. of available "bsize" blocks */
101 struct nfs_pathconf {
102 struct nfs_fattr *fattr; /* Post-op attributes */
103 __u32 max_link; /* max # of hard links */
104 __u32 max_namelen; /* max name length */
107 struct nfs4_change_info {
115 * Arguments to the open call.
117 struct nfs_openargs {
118 const struct nfs_fh * fh;
119 struct nfs_seqid * seqid;
124 struct iattr * attrs; /* UNCHECKED, GUARDED */
125 nfs4_verifier verifier; /* EXCLUSIVE */
126 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
127 int delegation_type; /* CLAIM_PREVIOUS */
129 const struct qstr * name;
130 const struct nfs_server *server; /* Needed for ID mapping */
136 nfs4_stateid stateid;
138 struct nfs4_change_info cinfo;
140 struct nfs_fattr * f_attr;
141 struct nfs_fattr * dir_attr;
142 const struct nfs_server *server;
144 nfs4_stateid delegation;
147 __u32 attrset[NFS4_BITMAP_SIZE];
151 * Arguments to the open_confirm call.
153 struct nfs_open_confirmargs {
154 const struct nfs_fh * fh;
155 nfs4_stateid * stateid;
156 struct nfs_seqid * seqid;
159 struct nfs_open_confirmres {
160 nfs4_stateid stateid;
164 * Arguments to the close call.
166 struct nfs_closeargs {
168 nfs4_stateid * stateid;
169 struct nfs_seqid * seqid;
174 struct nfs_closeres {
175 nfs4_stateid stateid;
176 struct nfs_fattr * fattr;
177 const struct nfs_server *server;
180 * * Arguments to the lock,lockt, and locku call.
187 struct nfs_lock_args {
189 struct file_lock * fl;
190 struct nfs_seqid * lock_seqid;
191 nfs4_stateid * lock_stateid;
192 struct nfs_seqid * open_seqid;
193 nfs4_stateid * open_stateid;
194 struct nfs_lowner lock_owner;
195 unsigned char block : 1;
196 unsigned char reclaim : 1;
197 unsigned char new_lock_owner : 1;
200 struct nfs_lock_res {
201 nfs4_stateid stateid;
204 struct nfs_locku_args {
206 struct file_lock * fl;
207 struct nfs_seqid * seqid;
208 nfs4_stateid * stateid;
211 struct nfs_locku_res {
212 nfs4_stateid stateid;
215 struct nfs_lockt_args {
217 struct file_lock * fl;
218 struct nfs_lowner lock_owner;
221 struct nfs_lockt_res {
222 struct file_lock * denied; /* LOCK, LOCKT failed */
225 struct nfs4_delegreturnargs {
226 const struct nfs_fh *fhandle;
227 const nfs4_stateid *stateid;
231 struct nfs4_delegreturnres {
232 struct nfs_fattr * fattr;
233 const struct nfs_server *server;
237 * Arguments to the read call.
239 struct nfs_readargs {
241 struct nfs_open_context *context;
245 struct page ** pages;
249 struct nfs_fattr * fattr;
255 * Arguments to the write call.
257 struct nfs_writeargs {
259 struct nfs_open_context *context;
262 enum nfs3_stable_how stable;
264 struct page ** pages;
268 struct nfs_writeverf {
269 enum nfs3_stable_how committed;
273 struct nfs_writeres {
274 struct nfs_fattr * fattr;
275 struct nfs_writeverf * verf;
277 const struct nfs_server *server;
281 * Argument struct for decode_entry function
291 struct nfs_fattr * fattr;
295 * The following types are for NFSv2 only.
297 struct nfs_sattrargs {
299 struct iattr * sattr;
302 struct nfs_diropargs {
308 struct nfs_createargs {
312 struct iattr * sattr;
315 struct nfs_renameargs {
316 struct nfs_fh * fromfh;
317 const char * fromname;
318 unsigned int fromlen;
319 struct nfs_fh * tofh;
324 struct nfs_setattrargs {
326 nfs4_stateid stateid;
328 const struct nfs_server * server; /* Needed for name mapping */
332 struct nfs_setaclargs {
335 unsigned int acl_pgbase;
336 struct page ** acl_pages;
339 struct nfs_getaclargs {
342 unsigned int acl_pgbase;
343 struct page ** acl_pages;
346 struct nfs_setattrres {
347 struct nfs_fattr * fattr;
348 const struct nfs_server * server;
351 struct nfs_linkargs {
352 struct nfs_fh * fromfh;
353 struct nfs_fh * tofh;
358 struct nfs_symlinkargs {
359 struct nfs_fh * fromfh;
360 const char * fromname;
361 unsigned int fromlen;
362 struct page ** pages;
363 unsigned int pathlen;
364 struct iattr * sattr;
367 struct nfs_readdirargs {
371 struct page ** pages;
374 struct nfs3_getaclargs {
377 struct page ** pages;
380 struct nfs3_setaclargs {
381 struct inode * inode;
383 struct posix_acl * acl_access;
384 struct posix_acl * acl_default;
385 struct page ** pages;
390 struct nfs_fattr * fattr;
393 struct nfs_readlinkargs {
397 struct page ** pages;
400 struct nfs3_sattrargs {
402 struct iattr * sattr;
404 struct timespec guardtime;
407 struct nfs3_diropargs {
413 struct nfs3_accessargs {
418 struct nfs3_createargs {
422 struct iattr * sattr;
423 enum nfs3_createmode createmode;
427 struct nfs3_mkdirargs {
431 struct iattr * sattr;
434 struct nfs3_symlinkargs {
435 struct nfs_fh * fromfh;
436 const char * fromname;
437 unsigned int fromlen;
438 struct page ** pages;
439 unsigned int pathlen;
440 struct iattr * sattr;
443 struct nfs3_mknodargs {
447 enum nfs3_ftype type;
448 struct iattr * sattr;
452 struct nfs3_renameargs {
453 struct nfs_fh * fromfh;
454 const char * fromname;
455 unsigned int fromlen;
456 struct nfs_fh * tofh;
461 struct nfs3_linkargs {
462 struct nfs_fh * fromfh;
463 struct nfs_fh * tofh;
468 struct nfs3_readdirargs {
474 struct page ** pages;
477 struct nfs3_diropres {
478 struct nfs_fattr * dir_attr;
480 struct nfs_fattr * fattr;
483 struct nfs3_accessres {
484 struct nfs_fattr * fattr;
488 struct nfs3_readlinkargs {
492 struct page ** pages;
495 struct nfs3_renameres {
496 struct nfs_fattr * fromattr;
497 struct nfs_fattr * toattr;
500 struct nfs3_linkres {
501 struct nfs_fattr * dir_attr;
502 struct nfs_fattr * fattr;
505 struct nfs3_readdirres {
506 struct nfs_fattr * dir_attr;
511 struct nfs3_getaclres {
512 struct nfs_fattr * fattr;
514 unsigned int acl_access_count;
515 unsigned int acl_default_count;
516 struct posix_acl * acl_access;
517 struct posix_acl * acl_default;
522 typedef u64 clientid4;
524 struct nfs4_accessargs {
525 const struct nfs_fh * fh;
529 struct nfs4_accessres {
534 struct nfs4_create_arg {
538 struct page ** pages;
540 } symlink; /* NF4LNK */
544 } device; /* NF4BLK, NF4CHR */
546 const struct qstr * name;
547 const struct nfs_server * server;
548 const struct iattr * attrs;
549 const struct nfs_fh * dir_fh;
553 struct nfs4_create_res {
554 const struct nfs_server * server;
556 struct nfs_fattr * fattr;
557 struct nfs4_change_info dir_cinfo;
558 struct nfs_fattr * dir_fattr;
561 struct nfs4_fsinfo_arg {
562 const struct nfs_fh * fh;
566 struct nfs4_getattr_arg {
567 const struct nfs_fh * fh;
571 struct nfs4_getattr_res {
572 const struct nfs_server * server;
573 struct nfs_fattr * fattr;
576 struct nfs4_link_arg {
577 const struct nfs_fh * fh;
578 const struct nfs_fh * dir_fh;
579 const struct qstr * name;
583 struct nfs4_link_res {
584 const struct nfs_server * server;
585 struct nfs_fattr * fattr;
586 struct nfs4_change_info cinfo;
587 struct nfs_fattr * dir_attr;
591 struct nfs4_lookup_arg {
592 const struct nfs_fh * dir_fh;
593 const struct qstr * name;
597 struct nfs4_lookup_res {
598 const struct nfs_server * server;
599 struct nfs_fattr * fattr;
603 struct nfs4_lookup_root_arg {
607 struct nfs4_pathconf_arg {
608 const struct nfs_fh * fh;
612 struct nfs4_readdir_arg {
613 const struct nfs_fh * fh;
615 nfs4_verifier verifier;
617 struct page ** pages; /* zero-copy data */
618 unsigned int pgbase; /* zero-copy data */
622 struct nfs4_readdir_res {
623 nfs4_verifier verifier;
627 struct nfs4_readlink {
628 const struct nfs_fh * fh;
630 unsigned int pglen; /* zero-copy data */
631 struct page ** pages; /* zero-copy data */
634 struct nfs4_remove_arg {
635 const struct nfs_fh * fh;
636 const struct qstr * name;
640 struct nfs4_remove_res {
641 const struct nfs_server * server;
642 struct nfs4_change_info cinfo;
643 struct nfs_fattr * dir_attr;
646 struct nfs4_rename_arg {
647 const struct nfs_fh * old_dir;
648 const struct nfs_fh * new_dir;
649 const struct qstr * old_name;
650 const struct qstr * new_name;
654 struct nfs4_rename_res {
655 const struct nfs_server * server;
656 struct nfs4_change_info old_cinfo;
657 struct nfs_fattr * old_fattr;
658 struct nfs4_change_info new_cinfo;
659 struct nfs_fattr * new_fattr;
662 struct nfs4_setclientid {
663 const nfs4_verifier * sc_verifier; /* request */
664 unsigned int sc_name_len;
665 char sc_name[48]; /* request */
666 u32 sc_prog; /* request */
667 unsigned int sc_netid_len;
668 char sc_netid[4]; /* request */
669 unsigned int sc_uaddr_len;
670 char sc_uaddr[24]; /* request */
671 u32 sc_cb_ident; /* request */
674 struct nfs4_statfs_arg {
675 const struct nfs_fh * fh;
679 struct nfs4_server_caps_res {
691 #define NFS4_PATHNAME_MAXCOMPONENTS 512
692 struct nfs4_pathname {
693 unsigned int ncomponents;
694 struct nfs4_string components[NFS4_PATHNAME_MAXCOMPONENTS];
697 #define NFS4_FS_LOCATION_MAXSERVERS 10
698 struct nfs4_fs_location {
699 unsigned int nservers;
700 struct nfs4_string servers[NFS4_FS_LOCATION_MAXSERVERS];
701 struct nfs4_pathname rootpath;
704 #define NFS4_FS_LOCATIONS_MAXENTRIES 10
705 struct nfs4_fs_locations {
706 struct nfs_fattr fattr;
707 const struct nfs_server *server;
708 struct nfs4_pathname fs_path;
710 struct nfs4_fs_location locations[NFS4_FS_LOCATIONS_MAXENTRIES];
713 struct nfs4_fs_locations_arg {
714 const struct nfs_fh *dir_fh;
715 const struct qstr *name;
720 #endif /* CONFIG_NFS_V4 */
724 #define NFS_PAGEVEC_SIZE (8U)
726 struct nfs_read_data {
728 struct rpc_task task;
730 struct rpc_cred *cred;
731 struct nfs_fattr fattr; /* fattr storage */
732 struct list_head pages; /* Coalesced read requests */
733 struct nfs_page *req; /* multi ops per nfs_page */
734 struct page **pagevec;
735 unsigned int npages; /* Max length of pagevec */
736 struct nfs_readargs args;
737 struct nfs_readres res;
739 unsigned long timestamp; /* For lease renewal */
741 struct page *page_array[NFS_PAGEVEC_SIZE];
744 struct nfs_write_data {
746 struct rpc_task task;
748 struct rpc_cred *cred;
749 struct nfs_fattr fattr;
750 struct nfs_writeverf verf;
751 struct list_head pages; /* Coalesced requests we wish to flush */
752 struct nfs_page *req; /* multi ops per nfs_page */
753 struct page **pagevec;
754 unsigned int npages; /* Max length of pagevec */
755 struct nfs_writeargs args; /* argument struct */
756 struct nfs_writeres res; /* result struct */
758 unsigned long timestamp; /* For lease renewal */
760 struct page *page_array[NFS_PAGEVEC_SIZE];
763 struct nfs_access_entry;
766 * RPC procedure vector for NFSv2/NFSv3 demuxing
769 int version; /* Protocol version */
770 struct dentry_operations *dentry_ops;
771 const struct inode_operations *dir_inode_ops;
772 const struct inode_operations *file_inode_ops;
774 int (*getroot) (struct nfs_server *, struct nfs_fh *,
775 struct nfs_fsinfo *);
776 int (*lookupfh)(struct nfs_server *, struct nfs_fh *,
777 struct qstr *, struct nfs_fh *,
779 int (*getattr) (struct nfs_server *, struct nfs_fh *,
781 int (*setattr) (struct dentry *, struct nfs_fattr *,
783 int (*lookup) (struct inode *, struct qstr *,
784 struct nfs_fh *, struct nfs_fattr *);
785 int (*access) (struct inode *, struct nfs_access_entry *);
786 int (*readlink)(struct inode *, struct page *, unsigned int,
788 int (*create) (struct inode *, struct dentry *,
789 struct iattr *, int, struct nameidata *);
790 int (*remove) (struct inode *, struct qstr *);
791 int (*unlink_setup) (struct rpc_message *,
792 struct dentry *, struct qstr *);
793 int (*unlink_done) (struct dentry *, struct rpc_task *);
794 int (*rename) (struct inode *, struct qstr *,
795 struct inode *, struct qstr *);
796 int (*link) (struct inode *, struct inode *, struct qstr *);
797 int (*symlink) (struct inode *, struct dentry *, struct page *,
798 unsigned int, struct iattr *);
799 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
800 int (*rmdir) (struct inode *, struct qstr *);
801 int (*readdir) (struct dentry *, struct rpc_cred *,
802 u64, struct page *, unsigned int, int);
803 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
805 int (*statfs) (struct nfs_server *, struct nfs_fh *,
806 struct nfs_fsstat *);
807 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
808 struct nfs_fsinfo *);
809 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
810 struct nfs_pathconf *);
811 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
812 __be32 *(*decode_dirent)(__be32 *, struct nfs_entry *, int plus);
813 void (*read_setup) (struct nfs_read_data *);
814 int (*read_done) (struct rpc_task *, struct nfs_read_data *);
815 void (*write_setup) (struct nfs_write_data *, int how);
816 int (*write_done) (struct rpc_task *, struct nfs_write_data *);
817 void (*commit_setup) (struct nfs_write_data *, int how);
818 int (*commit_done) (struct rpc_task *, struct nfs_write_data *);
819 int (*file_open) (struct inode *, struct file *);
820 int (*file_release) (struct inode *, struct file *);
821 int (*lock)(struct file *, int, struct file_lock *);
822 void (*clear_acl_cache)(struct inode *);
826 * NFS_CALL(getattr, inode, (fattr));
828 * NFS_PROTO(inode)->getattr(fattr);
830 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
833 * Function vectors etc. for the NFS client
835 extern const struct nfs_rpc_ops nfs_v2_clientops;
836 extern const struct nfs_rpc_ops nfs_v3_clientops;
837 extern const struct nfs_rpc_ops nfs_v4_clientops;
838 extern struct rpc_version nfs_version2;
839 extern struct rpc_version nfs_version3;
840 extern struct rpc_version nfs_version4;
842 extern struct rpc_version nfsacl_version3;
843 extern struct rpc_program nfsacl_program;