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 * Common arguments to the unlink call
283 struct nfs_removeargs {
284 const struct nfs_fh *fh;
289 struct nfs_removeres {
290 const struct nfs_server *server;
291 struct nfs4_change_info cinfo;
292 struct nfs_fattr dir_attr;
296 * Argument struct for decode_entry function
306 struct nfs_fattr * fattr;
310 * The following types are for NFSv2 only.
312 struct nfs_sattrargs {
314 struct iattr * sattr;
317 struct nfs_diropargs {
323 struct nfs_createargs {
327 struct iattr * sattr;
330 struct nfs_renameargs {
331 struct nfs_fh * fromfh;
332 const char * fromname;
333 unsigned int fromlen;
334 struct nfs_fh * tofh;
339 struct nfs_setattrargs {
341 nfs4_stateid stateid;
343 const struct nfs_server * server; /* Needed for name mapping */
347 struct nfs_setaclargs {
350 unsigned int acl_pgbase;
351 struct page ** acl_pages;
354 struct nfs_getaclargs {
357 unsigned int acl_pgbase;
358 struct page ** acl_pages;
361 struct nfs_setattrres {
362 struct nfs_fattr * fattr;
363 const struct nfs_server * server;
366 struct nfs_linkargs {
367 struct nfs_fh * fromfh;
368 struct nfs_fh * tofh;
373 struct nfs_symlinkargs {
374 struct nfs_fh * fromfh;
375 const char * fromname;
376 unsigned int fromlen;
377 struct page ** pages;
378 unsigned int pathlen;
379 struct iattr * sattr;
382 struct nfs_readdirargs {
386 struct page ** pages;
389 struct nfs3_getaclargs {
392 struct page ** pages;
395 struct nfs3_setaclargs {
396 struct inode * inode;
398 struct posix_acl * acl_access;
399 struct posix_acl * acl_default;
400 struct page ** pages;
405 struct nfs_fattr * fattr;
408 struct nfs_readlinkargs {
412 struct page ** pages;
415 struct nfs3_sattrargs {
417 struct iattr * sattr;
419 struct timespec guardtime;
422 struct nfs3_diropargs {
428 struct nfs3_accessargs {
433 struct nfs3_createargs {
437 struct iattr * sattr;
438 enum nfs3_createmode createmode;
442 struct nfs3_mkdirargs {
446 struct iattr * sattr;
449 struct nfs3_symlinkargs {
450 struct nfs_fh * fromfh;
451 const char * fromname;
452 unsigned int fromlen;
453 struct page ** pages;
454 unsigned int pathlen;
455 struct iattr * sattr;
458 struct nfs3_mknodargs {
462 enum nfs3_ftype type;
463 struct iattr * sattr;
467 struct nfs3_renameargs {
468 struct nfs_fh * fromfh;
469 const char * fromname;
470 unsigned int fromlen;
471 struct nfs_fh * tofh;
476 struct nfs3_linkargs {
477 struct nfs_fh * fromfh;
478 struct nfs_fh * tofh;
483 struct nfs3_readdirargs {
489 struct page ** pages;
492 struct nfs3_diropres {
493 struct nfs_fattr * dir_attr;
495 struct nfs_fattr * fattr;
498 struct nfs3_accessres {
499 struct nfs_fattr * fattr;
503 struct nfs3_readlinkargs {
507 struct page ** pages;
510 struct nfs3_renameres {
511 struct nfs_fattr * fromattr;
512 struct nfs_fattr * toattr;
515 struct nfs3_linkres {
516 struct nfs_fattr * dir_attr;
517 struct nfs_fattr * fattr;
520 struct nfs3_readdirres {
521 struct nfs_fattr * dir_attr;
526 struct nfs3_getaclres {
527 struct nfs_fattr * fattr;
529 unsigned int acl_access_count;
530 unsigned int acl_default_count;
531 struct posix_acl * acl_access;
532 struct posix_acl * acl_default;
537 typedef u64 clientid4;
539 struct nfs4_accessargs {
540 const struct nfs_fh * fh;
545 struct nfs4_accessres {
546 const struct nfs_server * server;
547 struct nfs_fattr * fattr;
552 struct nfs4_create_arg {
556 struct page ** pages;
558 } symlink; /* NF4LNK */
562 } device; /* NF4BLK, NF4CHR */
564 const struct qstr * name;
565 const struct nfs_server * server;
566 const struct iattr * attrs;
567 const struct nfs_fh * dir_fh;
571 struct nfs4_create_res {
572 const struct nfs_server * server;
574 struct nfs_fattr * fattr;
575 struct nfs4_change_info dir_cinfo;
576 struct nfs_fattr * dir_fattr;
579 struct nfs4_fsinfo_arg {
580 const struct nfs_fh * fh;
584 struct nfs4_getattr_arg {
585 const struct nfs_fh * fh;
589 struct nfs4_getattr_res {
590 const struct nfs_server * server;
591 struct nfs_fattr * fattr;
594 struct nfs4_link_arg {
595 const struct nfs_fh * fh;
596 const struct nfs_fh * dir_fh;
597 const struct qstr * name;
601 struct nfs4_link_res {
602 const struct nfs_server * server;
603 struct nfs_fattr * fattr;
604 struct nfs4_change_info cinfo;
605 struct nfs_fattr * dir_attr;
609 struct nfs4_lookup_arg {
610 const struct nfs_fh * dir_fh;
611 const struct qstr * name;
615 struct nfs4_lookup_res {
616 const struct nfs_server * server;
617 struct nfs_fattr * fattr;
621 struct nfs4_lookup_root_arg {
625 struct nfs4_pathconf_arg {
626 const struct nfs_fh * fh;
630 struct nfs4_readdir_arg {
631 const struct nfs_fh * fh;
633 nfs4_verifier verifier;
635 struct page ** pages; /* zero-copy data */
636 unsigned int pgbase; /* zero-copy data */
640 struct nfs4_readdir_res {
641 nfs4_verifier verifier;
645 struct nfs4_readlink {
646 const struct nfs_fh * fh;
648 unsigned int pglen; /* zero-copy data */
649 struct page ** pages; /* zero-copy data */
652 struct nfs4_rename_arg {
653 const struct nfs_fh * old_dir;
654 const struct nfs_fh * new_dir;
655 const struct qstr * old_name;
656 const struct qstr * new_name;
660 struct nfs4_rename_res {
661 const struct nfs_server * server;
662 struct nfs4_change_info old_cinfo;
663 struct nfs_fattr * old_fattr;
664 struct nfs4_change_info new_cinfo;
665 struct nfs_fattr * new_fattr;
668 struct nfs4_setclientid {
669 const nfs4_verifier * sc_verifier; /* request */
670 unsigned int sc_name_len;
671 char sc_name[48]; /* request */
672 u32 sc_prog; /* request */
673 unsigned int sc_netid_len;
674 char sc_netid[4]; /* request */
675 unsigned int sc_uaddr_len;
676 char sc_uaddr[24]; /* request */
677 u32 sc_cb_ident; /* request */
680 struct nfs4_statfs_arg {
681 const struct nfs_fh * fh;
685 struct nfs4_server_caps_res {
697 #define NFS4_PATHNAME_MAXCOMPONENTS 512
698 struct nfs4_pathname {
699 unsigned int ncomponents;
700 struct nfs4_string components[NFS4_PATHNAME_MAXCOMPONENTS];
703 #define NFS4_FS_LOCATION_MAXSERVERS 10
704 struct nfs4_fs_location {
705 unsigned int nservers;
706 struct nfs4_string servers[NFS4_FS_LOCATION_MAXSERVERS];
707 struct nfs4_pathname rootpath;
710 #define NFS4_FS_LOCATIONS_MAXENTRIES 10
711 struct nfs4_fs_locations {
712 struct nfs_fattr fattr;
713 const struct nfs_server *server;
714 struct nfs4_pathname fs_path;
716 struct nfs4_fs_location locations[NFS4_FS_LOCATIONS_MAXENTRIES];
719 struct nfs4_fs_locations_arg {
720 const struct nfs_fh *dir_fh;
721 const struct qstr *name;
726 #endif /* CONFIG_NFS_V4 */
730 #define NFS_PAGEVEC_SIZE (8U)
732 struct nfs_read_data {
734 struct rpc_task task;
736 struct rpc_cred *cred;
737 struct nfs_fattr fattr; /* fattr storage */
738 struct list_head pages; /* Coalesced read requests */
739 struct nfs_page *req; /* multi ops per nfs_page */
740 struct page **pagevec;
741 unsigned int npages; /* Max length of pagevec */
742 struct nfs_readargs args;
743 struct nfs_readres res;
745 unsigned long timestamp; /* For lease renewal */
747 struct page *page_array[NFS_PAGEVEC_SIZE];
750 struct nfs_write_data {
752 struct rpc_task task;
754 struct rpc_cred *cred;
755 struct nfs_fattr fattr;
756 struct nfs_writeverf verf;
757 struct list_head pages; /* Coalesced requests we wish to flush */
758 struct nfs_page *req; /* multi ops per nfs_page */
759 struct page **pagevec;
760 unsigned int npages; /* Max length of pagevec */
761 struct nfs_writeargs args; /* argument struct */
762 struct nfs_writeres res; /* result struct */
764 unsigned long timestamp; /* For lease renewal */
766 struct page *page_array[NFS_PAGEVEC_SIZE];
769 struct nfs_access_entry;
772 * RPC procedure vector for NFSv2/NFSv3 demuxing
775 int version; /* Protocol version */
776 struct dentry_operations *dentry_ops;
777 const struct inode_operations *dir_inode_ops;
778 const struct inode_operations *file_inode_ops;
780 int (*getroot) (struct nfs_server *, struct nfs_fh *,
781 struct nfs_fsinfo *);
782 int (*lookupfh)(struct nfs_server *, struct nfs_fh *,
783 struct qstr *, struct nfs_fh *,
785 int (*getattr) (struct nfs_server *, struct nfs_fh *,
787 int (*setattr) (struct dentry *, struct nfs_fattr *,
789 int (*lookup) (struct inode *, struct qstr *,
790 struct nfs_fh *, struct nfs_fattr *);
791 int (*access) (struct inode *, struct nfs_access_entry *);
792 int (*readlink)(struct inode *, struct page *, unsigned int,
794 int (*create) (struct inode *, struct dentry *,
795 struct iattr *, int, struct nameidata *);
796 int (*remove) (struct inode *, struct qstr *);
797 void (*unlink_setup) (struct rpc_message *, struct inode *dir);
798 int (*unlink_done) (struct rpc_task *, struct inode *);
799 int (*rename) (struct inode *, struct qstr *,
800 struct inode *, struct qstr *);
801 int (*link) (struct inode *, struct inode *, struct qstr *);
802 int (*symlink) (struct inode *, struct dentry *, struct page *,
803 unsigned int, struct iattr *);
804 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
805 int (*rmdir) (struct inode *, struct qstr *);
806 int (*readdir) (struct dentry *, struct rpc_cred *,
807 u64, struct page *, unsigned int, int);
808 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
810 int (*statfs) (struct nfs_server *, struct nfs_fh *,
811 struct nfs_fsstat *);
812 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
813 struct nfs_fsinfo *);
814 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
815 struct nfs_pathconf *);
816 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
817 __be32 *(*decode_dirent)(__be32 *, struct nfs_entry *, int plus);
818 void (*read_setup) (struct nfs_read_data *);
819 int (*read_done) (struct rpc_task *, struct nfs_read_data *);
820 void (*write_setup) (struct nfs_write_data *, int how);
821 int (*write_done) (struct rpc_task *, struct nfs_write_data *);
822 void (*commit_setup) (struct nfs_write_data *, int how);
823 int (*commit_done) (struct rpc_task *, struct nfs_write_data *);
824 int (*file_open) (struct inode *, struct file *);
825 int (*file_release) (struct inode *, struct file *);
826 int (*lock)(struct file *, int, struct file_lock *);
827 void (*clear_acl_cache)(struct inode *);
831 * NFS_CALL(getattr, inode, (fattr));
833 * NFS_PROTO(inode)->getattr(fattr);
835 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
838 * Function vectors etc. for the NFS client
840 extern const struct nfs_rpc_ops nfs_v2_clientops;
841 extern const struct nfs_rpc_ops nfs_v3_clientops;
842 extern const struct nfs_rpc_ops nfs_v4_clientops;
843 extern struct rpc_version nfs_version2;
844 extern struct rpc_version nfs_version3;
845 extern struct rpc_version nfs_version4;
847 extern struct rpc_version nfsacl_version3;
848 extern struct rpc_program nfsacl_program;