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;
59 unsigned long gencount;
62 #define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */
63 #define NFS_ATTR_FATTR 0x0002 /* post-op attributes */
64 #define NFS_ATTR_FATTR_V3 0x0004 /* NFSv3 attributes */
65 #define NFS_ATTR_FATTR_V4 0x0008 /* NFSv4 change attribute */
66 #define NFS_ATTR_WCC_V4 0x0010 /* pre-op change attribute */
67 #define NFS_ATTR_FATTR_V4_REFERRAL 0x0020 /* NFSv4 referral */
70 * Info on the file system
73 struct nfs_fattr *fattr; /* Post-op attributes */
74 __u32 rtmax; /* max. read transfer size */
75 __u32 rtpref; /* pref. read transfer size */
76 __u32 rtmult; /* reads should be multiple of this */
77 __u32 wtmax; /* max. write transfer size */
78 __u32 wtpref; /* pref. write transfer size */
79 __u32 wtmult; /* writes should be multiple of this */
80 __u32 dtpref; /* pref. readdir transfer size */
82 __u32 lease_time; /* in seconds */
86 struct nfs_fattr *fattr; /* Post-op attributes */
87 __u64 tbytes; /* total size in bytes */
88 __u64 fbytes; /* # of free bytes */
89 __u64 abytes; /* # of bytes available to user */
90 __u64 tfiles; /* # of files */
91 __u64 ffiles; /* # of free files */
92 __u64 afiles; /* # of files available to user */
96 __u32 tsize; /* Server transfer size */
97 __u32 bsize; /* Filesystem block size */
98 __u32 blocks; /* No. of "bsize" blocks on filesystem */
99 __u32 bfree; /* No. of free "bsize" blocks */
100 __u32 bavail; /* No. of available "bsize" blocks */
103 struct nfs_pathconf {
104 struct nfs_fattr *fattr; /* Post-op attributes */
105 __u32 max_link; /* max # of hard links */
106 __u32 max_namelen; /* max name length */
109 struct nfs4_change_info {
117 * Arguments to the open call.
119 struct nfs_openargs {
120 const struct nfs_fh * fh;
121 struct nfs_seqid * seqid;
126 struct iattr * attrs; /* UNCHECKED, GUARDED */
127 nfs4_verifier verifier; /* EXCLUSIVE */
128 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
129 int delegation_type; /* CLAIM_PREVIOUS */
131 const struct qstr * name;
132 const struct nfs_server *server; /* Needed for ID mapping */
138 nfs4_stateid stateid;
140 struct nfs4_change_info cinfo;
142 struct nfs_fattr * f_attr;
143 struct nfs_fattr * dir_attr;
144 struct nfs_seqid * seqid;
145 const struct nfs_server *server;
147 nfs4_stateid delegation;
150 __u32 attrset[NFS4_BITMAP_SIZE];
154 * Arguments to the open_confirm call.
156 struct nfs_open_confirmargs {
157 const struct nfs_fh * fh;
158 nfs4_stateid * stateid;
159 struct nfs_seqid * seqid;
162 struct nfs_open_confirmres {
163 nfs4_stateid stateid;
164 struct nfs_seqid * seqid;
168 * Arguments to the close call.
170 struct nfs_closeargs {
172 nfs4_stateid * stateid;
173 struct nfs_seqid * seqid;
178 struct nfs_closeres {
179 nfs4_stateid stateid;
180 struct nfs_fattr * fattr;
181 struct nfs_seqid * seqid;
182 const struct nfs_server *server;
185 * * Arguments to the lock,lockt, and locku call.
192 struct nfs_lock_args {
194 struct file_lock * fl;
195 struct nfs_seqid * lock_seqid;
196 nfs4_stateid * lock_stateid;
197 struct nfs_seqid * open_seqid;
198 nfs4_stateid * open_stateid;
199 struct nfs_lowner lock_owner;
200 unsigned char block : 1;
201 unsigned char reclaim : 1;
202 unsigned char new_lock_owner : 1;
205 struct nfs_lock_res {
206 nfs4_stateid stateid;
207 struct nfs_seqid * lock_seqid;
208 struct nfs_seqid * open_seqid;
211 struct nfs_locku_args {
213 struct file_lock * fl;
214 struct nfs_seqid * seqid;
215 nfs4_stateid * stateid;
218 struct nfs_locku_res {
219 nfs4_stateid stateid;
220 struct nfs_seqid * seqid;
223 struct nfs_lockt_args {
225 struct file_lock * fl;
226 struct nfs_lowner lock_owner;
229 struct nfs_lockt_res {
230 struct file_lock * denied; /* LOCK, LOCKT failed */
233 struct nfs4_delegreturnargs {
234 const struct nfs_fh *fhandle;
235 const nfs4_stateid *stateid;
239 struct nfs4_delegreturnres {
240 struct nfs_fattr * fattr;
241 const struct nfs_server *server;
245 * Arguments to the read call.
247 struct nfs_readargs {
249 struct nfs_open_context *context;
253 struct page ** pages;
257 struct nfs_fattr * fattr;
263 * Arguments to the write call.
265 struct nfs_writeargs {
267 struct nfs_open_context *context;
270 enum nfs3_stable_how stable;
272 struct page ** pages;
276 struct nfs_writeverf {
277 enum nfs3_stable_how committed;
281 struct nfs_writeres {
282 struct nfs_fattr * fattr;
283 struct nfs_writeverf * verf;
285 const struct nfs_server *server;
289 * Common arguments to the unlink call
291 struct nfs_removeargs {
292 const struct nfs_fh *fh;
297 struct nfs_removeres {
298 const struct nfs_server *server;
299 struct nfs4_change_info cinfo;
300 struct nfs_fattr dir_attr;
304 * Argument struct for decode_entry function
314 struct nfs_fattr * fattr;
318 * The following types are for NFSv2 only.
320 struct nfs_sattrargs {
322 struct iattr * sattr;
325 struct nfs_diropargs {
331 struct nfs_createargs {
335 struct iattr * sattr;
338 struct nfs_renameargs {
339 struct nfs_fh * fromfh;
340 const char * fromname;
341 unsigned int fromlen;
342 struct nfs_fh * tofh;
347 struct nfs_setattrargs {
349 nfs4_stateid stateid;
351 const struct nfs_server * server; /* Needed for name mapping */
355 struct nfs_setaclargs {
358 unsigned int acl_pgbase;
359 struct page ** acl_pages;
362 struct nfs_getaclargs {
365 unsigned int acl_pgbase;
366 struct page ** acl_pages;
369 struct nfs_setattrres {
370 struct nfs_fattr * fattr;
371 const struct nfs_server * server;
374 struct nfs_linkargs {
375 struct nfs_fh * fromfh;
376 struct nfs_fh * tofh;
381 struct nfs_symlinkargs {
382 struct nfs_fh * fromfh;
383 const char * fromname;
384 unsigned int fromlen;
385 struct page ** pages;
386 unsigned int pathlen;
387 struct iattr * sattr;
390 struct nfs_readdirargs {
394 struct page ** pages;
397 struct nfs3_getaclargs {
400 struct page ** pages;
403 struct nfs3_setaclargs {
404 struct inode * inode;
406 struct posix_acl * acl_access;
407 struct posix_acl * acl_default;
408 struct page ** pages;
413 struct nfs_fattr * fattr;
416 struct nfs_readlinkargs {
420 struct page ** pages;
423 struct nfs3_sattrargs {
425 struct iattr * sattr;
427 struct timespec guardtime;
430 struct nfs3_diropargs {
436 struct nfs3_accessargs {
441 struct nfs3_createargs {
445 struct iattr * sattr;
446 enum nfs3_createmode createmode;
450 struct nfs3_mkdirargs {
454 struct iattr * sattr;
457 struct nfs3_symlinkargs {
458 struct nfs_fh * fromfh;
459 const char * fromname;
460 unsigned int fromlen;
461 struct page ** pages;
462 unsigned int pathlen;
463 struct iattr * sattr;
466 struct nfs3_mknodargs {
470 enum nfs3_ftype type;
471 struct iattr * sattr;
475 struct nfs3_renameargs {
476 struct nfs_fh * fromfh;
477 const char * fromname;
478 unsigned int fromlen;
479 struct nfs_fh * tofh;
484 struct nfs3_linkargs {
485 struct nfs_fh * fromfh;
486 struct nfs_fh * tofh;
491 struct nfs3_readdirargs {
497 struct page ** pages;
500 struct nfs3_diropres {
501 struct nfs_fattr * dir_attr;
503 struct nfs_fattr * fattr;
506 struct nfs3_accessres {
507 struct nfs_fattr * fattr;
511 struct nfs3_readlinkargs {
515 struct page ** pages;
518 struct nfs3_renameres {
519 struct nfs_fattr * fromattr;
520 struct nfs_fattr * toattr;
523 struct nfs3_linkres {
524 struct nfs_fattr * dir_attr;
525 struct nfs_fattr * fattr;
528 struct nfs3_readdirres {
529 struct nfs_fattr * dir_attr;
534 struct nfs3_getaclres {
535 struct nfs_fattr * fattr;
537 unsigned int acl_access_count;
538 unsigned int acl_default_count;
539 struct posix_acl * acl_access;
540 struct posix_acl * acl_default;
545 typedef u64 clientid4;
547 struct nfs4_accessargs {
548 const struct nfs_fh * fh;
553 struct nfs4_accessres {
554 const struct nfs_server * server;
555 struct nfs_fattr * fattr;
560 struct nfs4_create_arg {
564 struct page ** pages;
566 } symlink; /* NF4LNK */
570 } device; /* NF4BLK, NF4CHR */
572 const struct qstr * name;
573 const struct nfs_server * server;
574 const struct iattr * attrs;
575 const struct nfs_fh * dir_fh;
579 struct nfs4_create_res {
580 const struct nfs_server * server;
582 struct nfs_fattr * fattr;
583 struct nfs4_change_info dir_cinfo;
584 struct nfs_fattr * dir_fattr;
587 struct nfs4_fsinfo_arg {
588 const struct nfs_fh * fh;
592 struct nfs4_getattr_arg {
593 const struct nfs_fh * fh;
597 struct nfs4_getattr_res {
598 const struct nfs_server * server;
599 struct nfs_fattr * fattr;
602 struct nfs4_link_arg {
603 const struct nfs_fh * fh;
604 const struct nfs_fh * dir_fh;
605 const struct qstr * name;
609 struct nfs4_link_res {
610 const struct nfs_server * server;
611 struct nfs_fattr * fattr;
612 struct nfs4_change_info cinfo;
613 struct nfs_fattr * dir_attr;
617 struct nfs4_lookup_arg {
618 const struct nfs_fh * dir_fh;
619 const struct qstr * name;
623 struct nfs4_lookup_res {
624 const struct nfs_server * server;
625 struct nfs_fattr * fattr;
629 struct nfs4_lookup_root_arg {
633 struct nfs4_pathconf_arg {
634 const struct nfs_fh * fh;
638 struct nfs4_readdir_arg {
639 const struct nfs_fh * fh;
641 nfs4_verifier verifier;
643 struct page ** pages; /* zero-copy data */
644 unsigned int pgbase; /* zero-copy data */
648 struct nfs4_readdir_res {
649 nfs4_verifier verifier;
653 struct nfs4_readlink {
654 const struct nfs_fh * fh;
656 unsigned int pglen; /* zero-copy data */
657 struct page ** pages; /* zero-copy data */
660 struct nfs4_rename_arg {
661 const struct nfs_fh * old_dir;
662 const struct nfs_fh * new_dir;
663 const struct qstr * old_name;
664 const struct qstr * new_name;
668 struct nfs4_rename_res {
669 const struct nfs_server * server;
670 struct nfs4_change_info old_cinfo;
671 struct nfs_fattr * old_fattr;
672 struct nfs4_change_info new_cinfo;
673 struct nfs_fattr * new_fattr;
676 #define NFS4_SETCLIENTID_NAMELEN (127)
677 struct nfs4_setclientid {
678 const nfs4_verifier * sc_verifier;
679 unsigned int sc_name_len;
680 char sc_name[NFS4_SETCLIENTID_NAMELEN + 1];
682 unsigned int sc_netid_len;
683 char sc_netid[RPCBIND_MAXNETIDLEN + 1];
684 unsigned int sc_uaddr_len;
685 char sc_uaddr[RPCBIND_MAXUADDRLEN + 1];
689 struct nfs4_statfs_arg {
690 const struct nfs_fh * fh;
694 struct nfs4_server_caps_res {
706 #define NFS4_PATHNAME_MAXCOMPONENTS 512
707 struct nfs4_pathname {
708 unsigned int ncomponents;
709 struct nfs4_string components[NFS4_PATHNAME_MAXCOMPONENTS];
712 #define NFS4_FS_LOCATION_MAXSERVERS 10
713 struct nfs4_fs_location {
714 unsigned int nservers;
715 struct nfs4_string servers[NFS4_FS_LOCATION_MAXSERVERS];
716 struct nfs4_pathname rootpath;
719 #define NFS4_FS_LOCATIONS_MAXENTRIES 10
720 struct nfs4_fs_locations {
721 struct nfs_fattr fattr;
722 const struct nfs_server *server;
723 struct nfs4_pathname fs_path;
725 struct nfs4_fs_location locations[NFS4_FS_LOCATIONS_MAXENTRIES];
728 struct nfs4_fs_locations_arg {
729 const struct nfs_fh *dir_fh;
730 const struct qstr *name;
735 #endif /* CONFIG_NFS_V4 */
739 #define NFS_PAGEVEC_SIZE (8U)
741 struct nfs_read_data {
743 struct rpc_task task;
745 struct rpc_cred *cred;
746 struct nfs_fattr fattr; /* fattr storage */
747 struct list_head pages; /* Coalesced read requests */
748 struct nfs_page *req; /* multi ops per nfs_page */
749 struct page **pagevec;
750 unsigned int npages; /* Max length of pagevec */
751 struct nfs_readargs args;
752 struct nfs_readres res;
754 unsigned long timestamp; /* For lease renewal */
756 struct page *page_array[NFS_PAGEVEC_SIZE];
759 struct nfs_write_data {
761 struct rpc_task task;
763 struct rpc_cred *cred;
764 struct nfs_fattr fattr;
765 struct nfs_writeverf verf;
766 struct list_head pages; /* Coalesced requests we wish to flush */
767 struct nfs_page *req; /* multi ops per nfs_page */
768 struct page **pagevec;
769 unsigned int npages; /* Max length of pagevec */
770 struct nfs_writeargs args; /* argument struct */
771 struct nfs_writeres res; /* result struct */
773 unsigned long timestamp; /* For lease renewal */
775 struct page *page_array[NFS_PAGEVEC_SIZE];
778 struct nfs_access_entry;
781 * RPC procedure vector for NFSv2/NFSv3 demuxing
784 u32 version; /* Protocol version */
785 struct dentry_operations *dentry_ops;
786 const struct inode_operations *dir_inode_ops;
787 const struct inode_operations *file_inode_ops;
789 int (*getroot) (struct nfs_server *, struct nfs_fh *,
790 struct nfs_fsinfo *);
791 int (*lookupfh)(struct nfs_server *, struct nfs_fh *,
792 struct qstr *, struct nfs_fh *,
794 int (*getattr) (struct nfs_server *, struct nfs_fh *,
796 int (*setattr) (struct dentry *, struct nfs_fattr *,
798 int (*lookup) (struct inode *, struct qstr *,
799 struct nfs_fh *, struct nfs_fattr *);
800 int (*access) (struct inode *, struct nfs_access_entry *);
801 int (*readlink)(struct inode *, struct page *, unsigned int,
803 int (*create) (struct inode *, struct dentry *,
804 struct iattr *, int, struct nameidata *);
805 int (*remove) (struct inode *, struct qstr *);
806 void (*unlink_setup) (struct rpc_message *, struct inode *dir);
807 int (*unlink_done) (struct rpc_task *, struct inode *);
808 int (*rename) (struct inode *, struct qstr *,
809 struct inode *, struct qstr *);
810 int (*link) (struct inode *, struct inode *, struct qstr *);
811 int (*symlink) (struct inode *, struct dentry *, struct page *,
812 unsigned int, struct iattr *);
813 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
814 int (*rmdir) (struct inode *, struct qstr *);
815 int (*readdir) (struct dentry *, struct rpc_cred *,
816 u64, struct page *, unsigned int, int);
817 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
819 int (*statfs) (struct nfs_server *, struct nfs_fh *,
820 struct nfs_fsstat *);
821 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
822 struct nfs_fsinfo *);
823 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
824 struct nfs_pathconf *);
825 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
826 __be32 *(*decode_dirent)(__be32 *, struct nfs_entry *, int plus);
827 void (*read_setup) (struct nfs_read_data *, struct rpc_message *);
828 int (*read_done) (struct rpc_task *, struct nfs_read_data *);
829 void (*write_setup) (struct nfs_write_data *, struct rpc_message *);
830 int (*write_done) (struct rpc_task *, struct nfs_write_data *);
831 void (*commit_setup) (struct nfs_write_data *, struct rpc_message *);
832 int (*commit_done) (struct rpc_task *, struct nfs_write_data *);
833 int (*lock)(struct file *, int, struct file_lock *);
834 int (*lock_check_bounds)(const struct file_lock *);
835 void (*clear_acl_cache)(struct inode *);
839 * NFS_CALL(getattr, inode, (fattr));
841 * NFS_PROTO(inode)->getattr(fattr);
843 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
846 * Function vectors etc. for the NFS client
848 extern const struct nfs_rpc_ops nfs_v2_clientops;
849 extern const struct nfs_rpc_ops nfs_v3_clientops;
850 extern const struct nfs_rpc_ops nfs_v4_clientops;
851 extern struct rpc_version nfs_version2;
852 extern struct rpc_version nfs_version3;
853 extern struct rpc_version nfs_version4;
855 extern struct rpc_version nfsacl_version3;
856 extern struct rpc_program nfsacl_program;