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
;
127 struct iattr
* attrs
; /* UNCHECKED, GUARDED */
128 nfs4_verifier verifier
; /* EXCLUSIVE */
129 nfs4_stateid delegation
; /* CLAIM_DELEGATE_CUR */
130 fmode_t delegation_type
; /* CLAIM_PREVIOUS */
132 const struct qstr
* name
;
133 const struct nfs_server
*server
; /* Needed for ID mapping */
139 nfs4_stateid stateid
;
141 struct nfs4_change_info cinfo
;
143 struct nfs_fattr
* f_attr
;
144 struct nfs_fattr
* dir_attr
;
145 struct nfs_seqid
* seqid
;
146 const struct nfs_server
*server
;
147 fmode_t delegation_type
;
148 nfs4_stateid delegation
;
151 __u32 attrset
[NFS4_BITMAP_SIZE
];
155 * Arguments to the open_confirm call.
157 struct nfs_open_confirmargs
{
158 const struct nfs_fh
* fh
;
159 nfs4_stateid
* stateid
;
160 struct nfs_seqid
* seqid
;
163 struct nfs_open_confirmres
{
164 nfs4_stateid stateid
;
165 struct nfs_seqid
* seqid
;
169 * Arguments to the close call.
171 struct nfs_closeargs
{
173 nfs4_stateid
* stateid
;
174 struct nfs_seqid
* seqid
;
179 struct nfs_closeres
{
180 nfs4_stateid stateid
;
181 struct nfs_fattr
* fattr
;
182 struct nfs_seqid
* seqid
;
183 const struct nfs_server
*server
;
186 * * Arguments to the lock,lockt, and locku call.
193 struct nfs_lock_args
{
195 struct file_lock
* fl
;
196 struct nfs_seqid
* lock_seqid
;
197 nfs4_stateid
* lock_stateid
;
198 struct nfs_seqid
* open_seqid
;
199 nfs4_stateid
* open_stateid
;
200 struct nfs_lowner lock_owner
;
201 unsigned char block
: 1;
202 unsigned char reclaim
: 1;
203 unsigned char new_lock_owner
: 1;
206 struct nfs_lock_res
{
207 nfs4_stateid stateid
;
208 struct nfs_seqid
* lock_seqid
;
209 struct nfs_seqid
* open_seqid
;
212 struct nfs_locku_args
{
214 struct file_lock
* fl
;
215 struct nfs_seqid
* seqid
;
216 nfs4_stateid
* stateid
;
219 struct nfs_locku_res
{
220 nfs4_stateid stateid
;
221 struct nfs_seqid
* seqid
;
224 struct nfs_lockt_args
{
226 struct file_lock
* fl
;
227 struct nfs_lowner lock_owner
;
230 struct nfs_lockt_res
{
231 struct file_lock
* denied
; /* LOCK, LOCKT failed */
234 struct nfs4_delegreturnargs
{
235 const struct nfs_fh
*fhandle
;
236 const nfs4_stateid
*stateid
;
240 struct nfs4_delegreturnres
{
241 struct nfs_fattr
* fattr
;
242 const struct nfs_server
*server
;
246 * Arguments to the read call.
248 struct nfs_readargs
{
250 struct nfs_open_context
*context
;
254 struct page
** pages
;
258 struct nfs_fattr
* fattr
;
264 * Arguments to the write call.
266 struct nfs_writeargs
{
268 struct nfs_open_context
*context
;
271 enum nfs3_stable_how stable
;
273 struct page
** pages
;
277 struct nfs_writeverf
{
278 enum nfs3_stable_how committed
;
282 struct nfs_writeres
{
283 struct nfs_fattr
* fattr
;
284 struct nfs_writeverf
* verf
;
286 const struct nfs_server
*server
;
290 * Common arguments to the unlink call
292 struct nfs_removeargs
{
293 const struct nfs_fh
*fh
;
298 struct nfs_removeres
{
299 const struct nfs_server
*server
;
300 struct nfs4_change_info cinfo
;
301 struct nfs_fattr dir_attr
;
305 * Argument struct for decode_entry function
315 struct nfs_fattr
* fattr
;
319 * The following types are for NFSv2 only.
321 struct nfs_sattrargs
{
323 struct iattr
* sattr
;
326 struct nfs_diropargs
{
332 struct nfs_createargs
{
336 struct iattr
* sattr
;
339 struct nfs_renameargs
{
340 struct nfs_fh
* fromfh
;
341 const char * fromname
;
342 unsigned int fromlen
;
343 struct nfs_fh
* tofh
;
348 struct nfs_setattrargs
{
350 nfs4_stateid stateid
;
352 const struct nfs_server
* server
; /* Needed for name mapping */
356 struct nfs_setaclargs
{
359 unsigned int acl_pgbase
;
360 struct page
** acl_pages
;
363 struct nfs_getaclargs
{
366 unsigned int acl_pgbase
;
367 struct page
** acl_pages
;
370 struct nfs_setattrres
{
371 struct nfs_fattr
* fattr
;
372 const struct nfs_server
* server
;
375 struct nfs_linkargs
{
376 struct nfs_fh
* fromfh
;
377 struct nfs_fh
* tofh
;
382 struct nfs_symlinkargs
{
383 struct nfs_fh
* fromfh
;
384 const char * fromname
;
385 unsigned int fromlen
;
386 struct page
** pages
;
387 unsigned int pathlen
;
388 struct iattr
* sattr
;
391 struct nfs_readdirargs
{
395 struct page
** pages
;
398 struct nfs3_getaclargs
{
401 struct page
** pages
;
404 struct nfs3_setaclargs
{
405 struct inode
* inode
;
407 struct posix_acl
* acl_access
;
408 struct posix_acl
* acl_default
;
411 struct page
** pages
;
416 struct nfs_fattr
* fattr
;
419 struct nfs_readlinkargs
{
423 struct page
** pages
;
426 struct nfs3_sattrargs
{
428 struct iattr
* sattr
;
430 struct timespec guardtime
;
433 struct nfs3_diropargs
{
439 struct nfs3_accessargs
{
444 struct nfs3_createargs
{
448 struct iattr
* sattr
;
449 enum nfs3_createmode createmode
;
453 struct nfs3_mkdirargs
{
457 struct iattr
* sattr
;
460 struct nfs3_symlinkargs
{
461 struct nfs_fh
* fromfh
;
462 const char * fromname
;
463 unsigned int fromlen
;
464 struct page
** pages
;
465 unsigned int pathlen
;
466 struct iattr
* sattr
;
469 struct nfs3_mknodargs
{
473 enum nfs3_ftype type
;
474 struct iattr
* sattr
;
478 struct nfs3_renameargs
{
479 struct nfs_fh
* fromfh
;
480 const char * fromname
;
481 unsigned int fromlen
;
482 struct nfs_fh
* tofh
;
487 struct nfs3_linkargs
{
488 struct nfs_fh
* fromfh
;
489 struct nfs_fh
* tofh
;
494 struct nfs3_readdirargs
{
500 struct page
** pages
;
503 struct nfs3_diropres
{
504 struct nfs_fattr
* dir_attr
;
506 struct nfs_fattr
* fattr
;
509 struct nfs3_accessres
{
510 struct nfs_fattr
* fattr
;
514 struct nfs3_readlinkargs
{
518 struct page
** pages
;
521 struct nfs3_renameres
{
522 struct nfs_fattr
* fromattr
;
523 struct nfs_fattr
* toattr
;
526 struct nfs3_linkres
{
527 struct nfs_fattr
* dir_attr
;
528 struct nfs_fattr
* fattr
;
531 struct nfs3_readdirres
{
532 struct nfs_fattr
* dir_attr
;
537 struct nfs3_getaclres
{
538 struct nfs_fattr
* fattr
;
540 unsigned int acl_access_count
;
541 unsigned int acl_default_count
;
542 struct posix_acl
* acl_access
;
543 struct posix_acl
* acl_default
;
548 typedef u64 clientid4
;
550 struct nfs4_accessargs
{
551 const struct nfs_fh
* fh
;
556 struct nfs4_accessres
{
557 const struct nfs_server
* server
;
558 struct nfs_fattr
* fattr
;
563 struct nfs4_create_arg
{
567 struct page
** pages
;
569 } symlink
; /* NF4LNK */
573 } device
; /* NF4BLK, NF4CHR */
575 const struct qstr
* name
;
576 const struct nfs_server
* server
;
577 const struct iattr
* attrs
;
578 const struct nfs_fh
* dir_fh
;
582 struct nfs4_create_res
{
583 const struct nfs_server
* server
;
585 struct nfs_fattr
* fattr
;
586 struct nfs4_change_info dir_cinfo
;
587 struct nfs_fattr
* dir_fattr
;
590 struct nfs4_fsinfo_arg
{
591 const struct nfs_fh
* fh
;
595 struct nfs4_getattr_arg
{
596 const struct nfs_fh
* fh
;
600 struct nfs4_getattr_res
{
601 const struct nfs_server
* server
;
602 struct nfs_fattr
* fattr
;
605 struct nfs4_link_arg
{
606 const struct nfs_fh
* fh
;
607 const struct nfs_fh
* dir_fh
;
608 const struct qstr
* name
;
612 struct nfs4_link_res
{
613 const struct nfs_server
* server
;
614 struct nfs_fattr
* fattr
;
615 struct nfs4_change_info cinfo
;
616 struct nfs_fattr
* dir_attr
;
620 struct nfs4_lookup_arg
{
621 const struct nfs_fh
* dir_fh
;
622 const struct qstr
* name
;
626 struct nfs4_lookup_res
{
627 const struct nfs_server
* server
;
628 struct nfs_fattr
* fattr
;
632 struct nfs4_lookup_root_arg
{
636 struct nfs4_pathconf_arg
{
637 const struct nfs_fh
* fh
;
641 struct nfs4_readdir_arg
{
642 const struct nfs_fh
* fh
;
644 nfs4_verifier verifier
;
646 struct page
** pages
; /* zero-copy data */
647 unsigned int pgbase
; /* zero-copy data */
651 struct nfs4_readdir_res
{
652 nfs4_verifier verifier
;
656 struct nfs4_readlink
{
657 const struct nfs_fh
* fh
;
659 unsigned int pglen
; /* zero-copy data */
660 struct page
** pages
; /* zero-copy data */
663 struct nfs4_rename_arg
{
664 const struct nfs_fh
* old_dir
;
665 const struct nfs_fh
* new_dir
;
666 const struct qstr
* old_name
;
667 const struct qstr
* new_name
;
671 struct nfs4_rename_res
{
672 const struct nfs_server
* server
;
673 struct nfs4_change_info old_cinfo
;
674 struct nfs_fattr
* old_fattr
;
675 struct nfs4_change_info new_cinfo
;
676 struct nfs_fattr
* new_fattr
;
679 #define NFS4_SETCLIENTID_NAMELEN (127)
680 struct nfs4_setclientid
{
681 const nfs4_verifier
* sc_verifier
;
682 unsigned int sc_name_len
;
683 char sc_name
[NFS4_SETCLIENTID_NAMELEN
+ 1];
685 unsigned int sc_netid_len
;
686 char sc_netid
[RPCBIND_MAXNETIDLEN
+ 1];
687 unsigned int sc_uaddr_len
;
688 char sc_uaddr
[RPCBIND_MAXUADDRLEN
+ 1];
692 struct nfs4_statfs_arg
{
693 const struct nfs_fh
* fh
;
697 struct nfs4_server_caps_res
{
709 #define NFS4_PATHNAME_MAXCOMPONENTS 512
710 struct nfs4_pathname
{
711 unsigned int ncomponents
;
712 struct nfs4_string components
[NFS4_PATHNAME_MAXCOMPONENTS
];
715 #define NFS4_FS_LOCATION_MAXSERVERS 10
716 struct nfs4_fs_location
{
717 unsigned int nservers
;
718 struct nfs4_string servers
[NFS4_FS_LOCATION_MAXSERVERS
];
719 struct nfs4_pathname rootpath
;
722 #define NFS4_FS_LOCATIONS_MAXENTRIES 10
723 struct nfs4_fs_locations
{
724 struct nfs_fattr fattr
;
725 const struct nfs_server
*server
;
726 struct nfs4_pathname fs_path
;
728 struct nfs4_fs_location locations
[NFS4_FS_LOCATIONS_MAXENTRIES
];
731 struct nfs4_fs_locations_arg
{
732 const struct nfs_fh
*dir_fh
;
733 const struct qstr
*name
;
738 #endif /* CONFIG_NFS_V4 */
742 #define NFS_PAGEVEC_SIZE (8U)
744 struct nfs_read_data
{
746 struct rpc_task task
;
748 struct rpc_cred
*cred
;
749 struct nfs_fattr fattr
; /* fattr storage */
750 struct list_head pages
; /* Coalesced read requests */
751 struct nfs_page
*req
; /* multi ops per nfs_page */
752 struct page
**pagevec
;
753 unsigned int npages
; /* Max length of pagevec */
754 struct nfs_readargs args
;
755 struct nfs_readres res
;
757 unsigned long timestamp
; /* For lease renewal */
759 struct page
*page_array
[NFS_PAGEVEC_SIZE
];
762 struct nfs_write_data
{
764 struct rpc_task task
;
766 struct rpc_cred
*cred
;
767 struct nfs_fattr fattr
;
768 struct nfs_writeverf verf
;
769 struct list_head pages
; /* Coalesced requests we wish to flush */
770 struct nfs_page
*req
; /* multi ops per nfs_page */
771 struct page
**pagevec
;
772 unsigned int npages
; /* Max length of pagevec */
773 struct nfs_writeargs args
; /* argument struct */
774 struct nfs_writeres res
; /* result struct */
776 unsigned long timestamp
; /* For lease renewal */
778 struct page
*page_array
[NFS_PAGEVEC_SIZE
];
781 struct nfs_access_entry
;
784 * RPC procedure vector for NFSv2/NFSv3 demuxing
787 u32 version
; /* Protocol version */
788 const struct dentry_operations
*dentry_ops
;
789 const struct inode_operations
*dir_inode_ops
;
790 const struct inode_operations
*file_inode_ops
;
792 int (*getroot
) (struct nfs_server
*, struct nfs_fh
*,
793 struct nfs_fsinfo
*);
794 int (*lookupfh
)(struct nfs_server
*, struct nfs_fh
*,
795 struct qstr
*, struct nfs_fh
*,
797 int (*getattr
) (struct nfs_server
*, struct nfs_fh
*,
799 int (*setattr
) (struct dentry
*, struct nfs_fattr
*,
801 int (*lookup
) (struct inode
*, struct qstr
*,
802 struct nfs_fh
*, struct nfs_fattr
*);
803 int (*access
) (struct inode
*, struct nfs_access_entry
*);
804 int (*readlink
)(struct inode
*, struct page
*, unsigned int,
806 int (*create
) (struct inode
*, struct dentry
*,
807 struct iattr
*, int, struct nameidata
*);
808 int (*remove
) (struct inode
*, struct qstr
*);
809 void (*unlink_setup
) (struct rpc_message
*, struct inode
*dir
);
810 int (*unlink_done
) (struct rpc_task
*, struct inode
*);
811 int (*rename
) (struct inode
*, struct qstr
*,
812 struct inode
*, struct qstr
*);
813 int (*link
) (struct inode
*, struct inode
*, struct qstr
*);
814 int (*symlink
) (struct inode
*, struct dentry
*, struct page
*,
815 unsigned int, struct iattr
*);
816 int (*mkdir
) (struct inode
*, struct dentry
*, struct iattr
*);
817 int (*rmdir
) (struct inode
*, struct qstr
*);
818 int (*readdir
) (struct dentry
*, struct rpc_cred
*,
819 u64
, struct page
*, unsigned int, int);
820 int (*mknod
) (struct inode
*, struct dentry
*, struct iattr
*,
822 int (*statfs
) (struct nfs_server
*, struct nfs_fh
*,
823 struct nfs_fsstat
*);
824 int (*fsinfo
) (struct nfs_server
*, struct nfs_fh
*,
825 struct nfs_fsinfo
*);
826 int (*pathconf
) (struct nfs_server
*, struct nfs_fh
*,
827 struct nfs_pathconf
*);
828 int (*set_capabilities
)(struct nfs_server
*, struct nfs_fh
*);
829 __be32
*(*decode_dirent
)(__be32
*, struct nfs_entry
*, int plus
);
830 void (*read_setup
) (struct nfs_read_data
*, struct rpc_message
*);
831 int (*read_done
) (struct rpc_task
*, struct nfs_read_data
*);
832 void (*write_setup
) (struct nfs_write_data
*, struct rpc_message
*);
833 int (*write_done
) (struct rpc_task
*, struct nfs_write_data
*);
834 void (*commit_setup
) (struct nfs_write_data
*, struct rpc_message
*);
835 int (*commit_done
) (struct rpc_task
*, struct nfs_write_data
*);
836 int (*lock
)(struct file
*, int, struct file_lock
*);
837 int (*lock_check_bounds
)(const struct file_lock
*);
838 void (*clear_acl_cache
)(struct inode
*);
842 * NFS_CALL(getattr, inode, (fattr));
844 * NFS_PROTO(inode)->getattr(fattr);
846 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
849 * Function vectors etc. for the NFS client
851 extern const struct nfs_rpc_ops nfs_v2_clientops
;
852 extern const struct nfs_rpc_ops nfs_v3_clientops
;
853 extern const struct nfs_rpc_ops nfs_v4_clientops
;
854 extern struct rpc_version nfs_version2
;
855 extern struct rpc_version nfs_version3
;
856 extern struct rpc_version nfs_version4
;
858 extern struct rpc_version nfsacl_version3
;
859 extern struct rpc_program nfsacl_program
;