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_WCC_V4 0x0010 /* pre-op change attribute */
66 #define NFS_ATTR_FATTR_V4_REFERRAL 0x0020 /* NFSv4 referral */
69 * Info on the file system
72 struct nfs_fattr
*fattr
; /* Post-op attributes */
73 __u32 rtmax
; /* max. read transfer size */
74 __u32 rtpref
; /* pref. read transfer size */
75 __u32 rtmult
; /* reads should be multiple of this */
76 __u32 wtmax
; /* max. write transfer size */
77 __u32 wtpref
; /* pref. write transfer size */
78 __u32 wtmult
; /* writes should be multiple of this */
79 __u32 dtpref
; /* pref. readdir transfer size */
81 __u32 lease_time
; /* in seconds */
85 struct nfs_fattr
*fattr
; /* Post-op attributes */
86 __u64 tbytes
; /* total size in bytes */
87 __u64 fbytes
; /* # of free bytes */
88 __u64 abytes
; /* # of bytes available to user */
89 __u64 tfiles
; /* # of files */
90 __u64 ffiles
; /* # of free files */
91 __u64 afiles
; /* # of files available to user */
95 __u32 tsize
; /* Server transfer size */
96 __u32 bsize
; /* Filesystem block size */
97 __u32 blocks
; /* No. of "bsize" blocks on filesystem */
98 __u32 bfree
; /* No. of free "bsize" blocks */
99 __u32 bavail
; /* No. of available "bsize" blocks */
102 struct nfs_pathconf
{
103 struct nfs_fattr
*fattr
; /* Post-op attributes */
104 __u32 max_link
; /* max # of hard links */
105 __u32 max_namelen
; /* max name length */
108 struct nfs4_change_info
{
116 * Arguments to the open call.
118 struct nfs_openargs
{
119 const struct nfs_fh
* fh
;
120 struct nfs_seqid
* seqid
;
125 struct iattr
* attrs
; /* UNCHECKED, GUARDED */
126 nfs4_verifier verifier
; /* EXCLUSIVE */
127 nfs4_stateid delegation
; /* CLAIM_DELEGATE_CUR */
128 int delegation_type
; /* CLAIM_PREVIOUS */
130 const struct qstr
* name
;
131 const struct nfs_server
*server
; /* Needed for ID mapping */
137 nfs4_stateid stateid
;
139 struct nfs4_change_info cinfo
;
141 struct nfs_fattr
* f_attr
;
142 struct nfs_fattr
* dir_attr
;
143 const struct nfs_server
*server
;
145 nfs4_stateid delegation
;
148 __u32 attrset
[NFS4_BITMAP_SIZE
];
152 * Arguments to the open_confirm call.
154 struct nfs_open_confirmargs
{
155 const struct nfs_fh
* fh
;
156 nfs4_stateid
* stateid
;
157 struct nfs_seqid
* seqid
;
160 struct nfs_open_confirmres
{
161 nfs4_stateid stateid
;
165 * Arguments to the close call.
167 struct nfs_closeargs
{
169 nfs4_stateid
* stateid
;
170 struct nfs_seqid
* seqid
;
175 struct nfs_closeres
{
176 nfs4_stateid stateid
;
177 struct nfs_fattr
* fattr
;
178 const struct nfs_server
*server
;
181 * * Arguments to the lock,lockt, and locku call.
188 struct nfs_lock_args
{
190 struct file_lock
* fl
;
191 struct nfs_seqid
* lock_seqid
;
192 nfs4_stateid
* lock_stateid
;
193 struct nfs_seqid
* open_seqid
;
194 nfs4_stateid
* open_stateid
;
195 struct nfs_lowner lock_owner
;
196 unsigned char block
: 1;
197 unsigned char reclaim
: 1;
198 unsigned char new_lock_owner
: 1;
201 struct nfs_lock_res
{
202 nfs4_stateid stateid
;
205 struct nfs_locku_args
{
207 struct file_lock
* fl
;
208 struct nfs_seqid
* seqid
;
209 nfs4_stateid
* stateid
;
212 struct nfs_locku_res
{
213 nfs4_stateid stateid
;
216 struct nfs_lockt_args
{
218 struct file_lock
* fl
;
219 struct nfs_lowner lock_owner
;
222 struct nfs_lockt_res
{
223 struct file_lock
* denied
; /* LOCK, LOCKT failed */
226 struct nfs4_delegreturnargs
{
227 const struct nfs_fh
*fhandle
;
228 const nfs4_stateid
*stateid
;
232 struct nfs4_delegreturnres
{
233 struct nfs_fattr
* fattr
;
234 const struct nfs_server
*server
;
238 * Arguments to the read call.
240 struct nfs_readargs
{
242 struct nfs_open_context
*context
;
246 struct page
** pages
;
250 struct nfs_fattr
* fattr
;
256 * Arguments to the write call.
258 struct nfs_writeargs
{
260 struct nfs_open_context
*context
;
263 enum nfs3_stable_how stable
;
265 struct page
** pages
;
269 struct nfs_writeverf
{
270 enum nfs3_stable_how committed
;
274 struct nfs_writeres
{
275 struct nfs_fattr
* fattr
;
276 struct nfs_writeverf
* verf
;
278 const struct nfs_server
*server
;
282 * Common arguments to the unlink call
284 struct nfs_removeargs
{
285 const struct nfs_fh
*fh
;
290 struct nfs_removeres
{
291 const struct nfs_server
*server
;
292 struct nfs4_change_info cinfo
;
293 struct nfs_fattr dir_attr
;
297 * Argument struct for decode_entry function
307 struct nfs_fattr
* fattr
;
311 * The following types are for NFSv2 only.
313 struct nfs_sattrargs
{
315 struct iattr
* sattr
;
318 struct nfs_diropargs
{
324 struct nfs_createargs
{
328 struct iattr
* sattr
;
331 struct nfs_renameargs
{
332 struct nfs_fh
* fromfh
;
333 const char * fromname
;
334 unsigned int fromlen
;
335 struct nfs_fh
* tofh
;
340 struct nfs_setattrargs
{
342 nfs4_stateid stateid
;
344 const struct nfs_server
* server
; /* Needed for name mapping */
348 struct nfs_setaclargs
{
351 unsigned int acl_pgbase
;
352 struct page
** acl_pages
;
355 struct nfs_getaclargs
{
358 unsigned int acl_pgbase
;
359 struct page
** acl_pages
;
362 struct nfs_setattrres
{
363 struct nfs_fattr
* fattr
;
364 const struct nfs_server
* server
;
367 struct nfs_linkargs
{
368 struct nfs_fh
* fromfh
;
369 struct nfs_fh
* tofh
;
374 struct nfs_symlinkargs
{
375 struct nfs_fh
* fromfh
;
376 const char * fromname
;
377 unsigned int fromlen
;
378 struct page
** pages
;
379 unsigned int pathlen
;
380 struct iattr
* sattr
;
383 struct nfs_readdirargs
{
387 struct page
** pages
;
390 struct nfs3_getaclargs
{
393 struct page
** pages
;
396 struct nfs3_setaclargs
{
397 struct inode
* inode
;
399 struct posix_acl
* acl_access
;
400 struct posix_acl
* acl_default
;
401 struct page
** pages
;
406 struct nfs_fattr
* fattr
;
409 struct nfs_readlinkargs
{
413 struct page
** pages
;
416 struct nfs3_sattrargs
{
418 struct iattr
* sattr
;
420 struct timespec guardtime
;
423 struct nfs3_diropargs
{
429 struct nfs3_accessargs
{
434 struct nfs3_createargs
{
438 struct iattr
* sattr
;
439 enum nfs3_createmode createmode
;
443 struct nfs3_mkdirargs
{
447 struct iattr
* sattr
;
450 struct nfs3_symlinkargs
{
451 struct nfs_fh
* fromfh
;
452 const char * fromname
;
453 unsigned int fromlen
;
454 struct page
** pages
;
455 unsigned int pathlen
;
456 struct iattr
* sattr
;
459 struct nfs3_mknodargs
{
463 enum nfs3_ftype type
;
464 struct iattr
* sattr
;
468 struct nfs3_renameargs
{
469 struct nfs_fh
* fromfh
;
470 const char * fromname
;
471 unsigned int fromlen
;
472 struct nfs_fh
* tofh
;
477 struct nfs3_linkargs
{
478 struct nfs_fh
* fromfh
;
479 struct nfs_fh
* tofh
;
484 struct nfs3_readdirargs
{
490 struct page
** pages
;
493 struct nfs3_diropres
{
494 struct nfs_fattr
* dir_attr
;
496 struct nfs_fattr
* fattr
;
499 struct nfs3_accessres
{
500 struct nfs_fattr
* fattr
;
504 struct nfs3_readlinkargs
{
508 struct page
** pages
;
511 struct nfs3_renameres
{
512 struct nfs_fattr
* fromattr
;
513 struct nfs_fattr
* toattr
;
516 struct nfs3_linkres
{
517 struct nfs_fattr
* dir_attr
;
518 struct nfs_fattr
* fattr
;
521 struct nfs3_readdirres
{
522 struct nfs_fattr
* dir_attr
;
527 struct nfs3_getaclres
{
528 struct nfs_fattr
* fattr
;
530 unsigned int acl_access_count
;
531 unsigned int acl_default_count
;
532 struct posix_acl
* acl_access
;
533 struct posix_acl
* acl_default
;
538 typedef u64 clientid4
;
540 struct nfs4_accessargs
{
541 const struct nfs_fh
* fh
;
546 struct nfs4_accessres
{
547 const struct nfs_server
* server
;
548 struct nfs_fattr
* fattr
;
553 struct nfs4_create_arg
{
557 struct page
** pages
;
559 } symlink
; /* NF4LNK */
563 } device
; /* NF4BLK, NF4CHR */
565 const struct qstr
* name
;
566 const struct nfs_server
* server
;
567 const struct iattr
* attrs
;
568 const struct nfs_fh
* dir_fh
;
572 struct nfs4_create_res
{
573 const struct nfs_server
* server
;
575 struct nfs_fattr
* fattr
;
576 struct nfs4_change_info dir_cinfo
;
577 struct nfs_fattr
* dir_fattr
;
580 struct nfs4_fsinfo_arg
{
581 const struct nfs_fh
* fh
;
585 struct nfs4_getattr_arg
{
586 const struct nfs_fh
* fh
;
590 struct nfs4_getattr_res
{
591 const struct nfs_server
* server
;
592 struct nfs_fattr
* fattr
;
595 struct nfs4_link_arg
{
596 const struct nfs_fh
* fh
;
597 const struct nfs_fh
* dir_fh
;
598 const struct qstr
* name
;
602 struct nfs4_link_res
{
603 const struct nfs_server
* server
;
604 struct nfs_fattr
* fattr
;
605 struct nfs4_change_info cinfo
;
606 struct nfs_fattr
* dir_attr
;
610 struct nfs4_lookup_arg
{
611 const struct nfs_fh
* dir_fh
;
612 const struct qstr
* name
;
616 struct nfs4_lookup_res
{
617 const struct nfs_server
* server
;
618 struct nfs_fattr
* fattr
;
622 struct nfs4_lookup_root_arg
{
626 struct nfs4_pathconf_arg
{
627 const struct nfs_fh
* fh
;
631 struct nfs4_readdir_arg
{
632 const struct nfs_fh
* fh
;
634 nfs4_verifier verifier
;
636 struct page
** pages
; /* zero-copy data */
637 unsigned int pgbase
; /* zero-copy data */
641 struct nfs4_readdir_res
{
642 nfs4_verifier verifier
;
646 struct nfs4_readlink
{
647 const struct nfs_fh
* fh
;
649 unsigned int pglen
; /* zero-copy data */
650 struct page
** pages
; /* zero-copy data */
653 struct nfs4_rename_arg
{
654 const struct nfs_fh
* old_dir
;
655 const struct nfs_fh
* new_dir
;
656 const struct qstr
* old_name
;
657 const struct qstr
* new_name
;
661 struct nfs4_rename_res
{
662 const struct nfs_server
* server
;
663 struct nfs4_change_info old_cinfo
;
664 struct nfs_fattr
* old_fattr
;
665 struct nfs4_change_info new_cinfo
;
666 struct nfs_fattr
* new_fattr
;
669 #define NFS4_SETCLIENTID_NAMELEN (56)
670 struct nfs4_setclientid
{
671 const nfs4_verifier
* sc_verifier
;
672 unsigned int sc_name_len
;
673 char sc_name
[NFS4_SETCLIENTID_NAMELEN
];
675 unsigned int sc_netid_len
;
676 char sc_netid
[RPCBIND_MAXNETIDLEN
];
677 unsigned int sc_uaddr_len
;
678 char sc_uaddr
[RPCBIND_MAXUADDRLEN
];
682 struct nfs4_statfs_arg
{
683 const struct nfs_fh
* fh
;
687 struct nfs4_server_caps_res
{
699 #define NFS4_PATHNAME_MAXCOMPONENTS 512
700 struct nfs4_pathname
{
701 unsigned int ncomponents
;
702 struct nfs4_string components
[NFS4_PATHNAME_MAXCOMPONENTS
];
705 #define NFS4_FS_LOCATION_MAXSERVERS 10
706 struct nfs4_fs_location
{
707 unsigned int nservers
;
708 struct nfs4_string servers
[NFS4_FS_LOCATION_MAXSERVERS
];
709 struct nfs4_pathname rootpath
;
712 #define NFS4_FS_LOCATIONS_MAXENTRIES 10
713 struct nfs4_fs_locations
{
714 struct nfs_fattr fattr
;
715 const struct nfs_server
*server
;
716 struct nfs4_pathname fs_path
;
718 struct nfs4_fs_location locations
[NFS4_FS_LOCATIONS_MAXENTRIES
];
721 struct nfs4_fs_locations_arg
{
722 const struct nfs_fh
*dir_fh
;
723 const struct qstr
*name
;
728 #endif /* CONFIG_NFS_V4 */
732 #define NFS_PAGEVEC_SIZE (8U)
734 struct nfs_read_data
{
736 struct rpc_task task
;
738 struct rpc_cred
*cred
;
739 struct nfs_fattr fattr
; /* fattr storage */
740 struct list_head pages
; /* Coalesced read requests */
741 struct nfs_page
*req
; /* multi ops per nfs_page */
742 struct page
**pagevec
;
743 unsigned int npages
; /* Max length of pagevec */
744 struct nfs_readargs args
;
745 struct nfs_readres res
;
747 unsigned long timestamp
; /* For lease renewal */
749 struct page
*page_array
[NFS_PAGEVEC_SIZE
];
752 struct nfs_write_data
{
754 struct rpc_task task
;
756 struct rpc_cred
*cred
;
757 struct nfs_fattr fattr
;
758 struct nfs_writeverf verf
;
759 struct list_head pages
; /* Coalesced requests we wish to flush */
760 struct nfs_page
*req
; /* multi ops per nfs_page */
761 struct page
**pagevec
;
762 unsigned int npages
; /* Max length of pagevec */
763 struct nfs_writeargs args
; /* argument struct */
764 struct nfs_writeres res
; /* result struct */
766 unsigned long timestamp
; /* For lease renewal */
768 struct page
*page_array
[NFS_PAGEVEC_SIZE
];
771 struct nfs_access_entry
;
774 * RPC procedure vector for NFSv2/NFSv3 demuxing
777 u32 version
; /* Protocol version */
778 struct dentry_operations
*dentry_ops
;
779 const struct inode_operations
*dir_inode_ops
;
780 const struct inode_operations
*file_inode_ops
;
782 int (*getroot
) (struct nfs_server
*, struct nfs_fh
*,
783 struct nfs_fsinfo
*);
784 int (*lookupfh
)(struct nfs_server
*, struct nfs_fh
*,
785 struct qstr
*, struct nfs_fh
*,
787 int (*getattr
) (struct nfs_server
*, struct nfs_fh
*,
789 int (*setattr
) (struct dentry
*, struct nfs_fattr
*,
791 int (*lookup
) (struct inode
*, struct qstr
*,
792 struct nfs_fh
*, struct nfs_fattr
*);
793 int (*access
) (struct inode
*, struct nfs_access_entry
*);
794 int (*readlink
)(struct inode
*, struct page
*, unsigned int,
796 int (*create
) (struct inode
*, struct dentry
*,
797 struct iattr
*, int, struct nameidata
*);
798 int (*remove
) (struct inode
*, struct qstr
*);
799 void (*unlink_setup
) (struct rpc_message
*, struct inode
*dir
);
800 int (*unlink_done
) (struct rpc_task
*, struct inode
*);
801 int (*rename
) (struct inode
*, struct qstr
*,
802 struct inode
*, struct qstr
*);
803 int (*link
) (struct inode
*, struct inode
*, struct qstr
*);
804 int (*symlink
) (struct inode
*, struct dentry
*, struct page
*,
805 unsigned int, struct iattr
*);
806 int (*mkdir
) (struct inode
*, struct dentry
*, struct iattr
*);
807 int (*rmdir
) (struct inode
*, struct qstr
*);
808 int (*readdir
) (struct dentry
*, struct rpc_cred
*,
809 u64
, struct page
*, unsigned int, int);
810 int (*mknod
) (struct inode
*, struct dentry
*, struct iattr
*,
812 int (*statfs
) (struct nfs_server
*, struct nfs_fh
*,
813 struct nfs_fsstat
*);
814 int (*fsinfo
) (struct nfs_server
*, struct nfs_fh
*,
815 struct nfs_fsinfo
*);
816 int (*pathconf
) (struct nfs_server
*, struct nfs_fh
*,
817 struct nfs_pathconf
*);
818 int (*set_capabilities
)(struct nfs_server
*, struct nfs_fh
*);
819 __be32
*(*decode_dirent
)(__be32
*, struct nfs_entry
*, int plus
);
820 void (*read_setup
) (struct nfs_read_data
*, struct rpc_message
*);
821 int (*read_done
) (struct rpc_task
*, struct nfs_read_data
*);
822 void (*write_setup
) (struct nfs_write_data
*, struct rpc_message
*);
823 int (*write_done
) (struct rpc_task
*, struct nfs_write_data
*);
824 void (*commit_setup
) (struct nfs_write_data
*, struct rpc_message
*);
825 int (*commit_done
) (struct rpc_task
*, struct nfs_write_data
*);
826 int (*file_open
) (struct inode
*, struct file
*);
827 int (*file_release
) (struct inode
*, struct file
*);
828 int (*lock
)(struct file
*, int, struct file_lock
*);
829 void (*clear_acl_cache
)(struct inode
*);
833 * NFS_CALL(getattr, inode, (fattr));
835 * NFS_PROTO(inode)->getattr(fattr);
837 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
840 * Function vectors etc. for the NFS client
842 extern const struct nfs_rpc_ops nfs_v2_clientops
;
843 extern const struct nfs_rpc_ops nfs_v3_clientops
;
844 extern const struct nfs_rpc_ops nfs_v4_clientops
;
845 extern struct rpc_version nfs_version2
;
846 extern struct rpc_version nfs_version3
;
847 extern struct rpc_version nfs_version4
;
849 extern struct rpc_version nfsacl_version3
;
850 extern struct rpc_program nfsacl_program
;