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 struct nfs_seqid
* seqid
;
144 const struct nfs_server
*server
;
146 nfs4_stateid delegation
;
149 __u32 attrset
[NFS4_BITMAP_SIZE
];
153 * Arguments to the open_confirm call.
155 struct nfs_open_confirmargs
{
156 const struct nfs_fh
* fh
;
157 nfs4_stateid
* stateid
;
158 struct nfs_seqid
* seqid
;
161 struct nfs_open_confirmres
{
162 nfs4_stateid stateid
;
163 struct nfs_seqid
* seqid
;
167 * Arguments to the close call.
169 struct nfs_closeargs
{
171 nfs4_stateid
* stateid
;
172 struct nfs_seqid
* seqid
;
177 struct nfs_closeres
{
178 nfs4_stateid stateid
;
179 struct nfs_fattr
* fattr
;
180 struct nfs_seqid
* seqid
;
181 const struct nfs_server
*server
;
184 * * Arguments to the lock,lockt, and locku call.
191 struct nfs_lock_args
{
193 struct file_lock
* fl
;
194 struct nfs_seqid
* lock_seqid
;
195 nfs4_stateid
* lock_stateid
;
196 struct nfs_seqid
* open_seqid
;
197 nfs4_stateid
* open_stateid
;
198 struct nfs_lowner lock_owner
;
199 unsigned char block
: 1;
200 unsigned char reclaim
: 1;
201 unsigned char new_lock_owner
: 1;
204 struct nfs_lock_res
{
205 nfs4_stateid stateid
;
206 struct nfs_seqid
* lock_seqid
;
207 struct nfs_seqid
* open_seqid
;
210 struct nfs_locku_args
{
212 struct file_lock
* fl
;
213 struct nfs_seqid
* seqid
;
214 nfs4_stateid
* stateid
;
217 struct nfs_locku_res
{
218 nfs4_stateid stateid
;
219 struct nfs_seqid
* seqid
;
222 struct nfs_lockt_args
{
224 struct file_lock
* fl
;
225 struct nfs_lowner lock_owner
;
228 struct nfs_lockt_res
{
229 struct file_lock
* denied
; /* LOCK, LOCKT failed */
232 struct nfs4_delegreturnargs
{
233 const struct nfs_fh
*fhandle
;
234 const nfs4_stateid
*stateid
;
238 struct nfs4_delegreturnres
{
239 struct nfs_fattr
* fattr
;
240 const struct nfs_server
*server
;
244 * Arguments to the read call.
246 struct nfs_readargs
{
248 struct nfs_open_context
*context
;
252 struct page
** pages
;
256 struct nfs_fattr
* fattr
;
262 * Arguments to the write call.
264 struct nfs_writeargs
{
266 struct nfs_open_context
*context
;
269 enum nfs3_stable_how stable
;
271 struct page
** pages
;
275 struct nfs_writeverf
{
276 enum nfs3_stable_how committed
;
280 struct nfs_writeres
{
281 struct nfs_fattr
* fattr
;
282 struct nfs_writeverf
* verf
;
284 const struct nfs_server
*server
;
288 * Common arguments to the unlink call
290 struct nfs_removeargs
{
291 const struct nfs_fh
*fh
;
296 struct nfs_removeres
{
297 const struct nfs_server
*server
;
298 struct nfs4_change_info cinfo
;
299 struct nfs_fattr dir_attr
;
303 * Argument struct for decode_entry function
313 struct nfs_fattr
* fattr
;
317 * The following types are for NFSv2 only.
319 struct nfs_sattrargs
{
321 struct iattr
* sattr
;
324 struct nfs_diropargs
{
330 struct nfs_createargs
{
334 struct iattr
* sattr
;
337 struct nfs_renameargs
{
338 struct nfs_fh
* fromfh
;
339 const char * fromname
;
340 unsigned int fromlen
;
341 struct nfs_fh
* tofh
;
346 struct nfs_setattrargs
{
348 nfs4_stateid stateid
;
350 const struct nfs_server
* server
; /* Needed for name mapping */
354 struct nfs_setaclargs
{
357 unsigned int acl_pgbase
;
358 struct page
** acl_pages
;
361 struct nfs_getaclargs
{
364 unsigned int acl_pgbase
;
365 struct page
** acl_pages
;
368 struct nfs_setattrres
{
369 struct nfs_fattr
* fattr
;
370 const struct nfs_server
* server
;
373 struct nfs_linkargs
{
374 struct nfs_fh
* fromfh
;
375 struct nfs_fh
* tofh
;
380 struct nfs_symlinkargs
{
381 struct nfs_fh
* fromfh
;
382 const char * fromname
;
383 unsigned int fromlen
;
384 struct page
** pages
;
385 unsigned int pathlen
;
386 struct iattr
* sattr
;
389 struct nfs_readdirargs
{
393 struct page
** pages
;
396 struct nfs3_getaclargs
{
399 struct page
** pages
;
402 struct nfs3_setaclargs
{
403 struct inode
* inode
;
405 struct posix_acl
* acl_access
;
406 struct posix_acl
* acl_default
;
407 struct page
** pages
;
412 struct nfs_fattr
* fattr
;
415 struct nfs_readlinkargs
{
419 struct page
** pages
;
422 struct nfs3_sattrargs
{
424 struct iattr
* sattr
;
426 struct timespec guardtime
;
429 struct nfs3_diropargs
{
435 struct nfs3_accessargs
{
440 struct nfs3_createargs
{
444 struct iattr
* sattr
;
445 enum nfs3_createmode createmode
;
449 struct nfs3_mkdirargs
{
453 struct iattr
* sattr
;
456 struct nfs3_symlinkargs
{
457 struct nfs_fh
* fromfh
;
458 const char * fromname
;
459 unsigned int fromlen
;
460 struct page
** pages
;
461 unsigned int pathlen
;
462 struct iattr
* sattr
;
465 struct nfs3_mknodargs
{
469 enum nfs3_ftype type
;
470 struct iattr
* sattr
;
474 struct nfs3_renameargs
{
475 struct nfs_fh
* fromfh
;
476 const char * fromname
;
477 unsigned int fromlen
;
478 struct nfs_fh
* tofh
;
483 struct nfs3_linkargs
{
484 struct nfs_fh
* fromfh
;
485 struct nfs_fh
* tofh
;
490 struct nfs3_readdirargs
{
496 struct page
** pages
;
499 struct nfs3_diropres
{
500 struct nfs_fattr
* dir_attr
;
502 struct nfs_fattr
* fattr
;
505 struct nfs3_accessres
{
506 struct nfs_fattr
* fattr
;
510 struct nfs3_readlinkargs
{
514 struct page
** pages
;
517 struct nfs3_renameres
{
518 struct nfs_fattr
* fromattr
;
519 struct nfs_fattr
* toattr
;
522 struct nfs3_linkres
{
523 struct nfs_fattr
* dir_attr
;
524 struct nfs_fattr
* fattr
;
527 struct nfs3_readdirres
{
528 struct nfs_fattr
* dir_attr
;
533 struct nfs3_getaclres
{
534 struct nfs_fattr
* fattr
;
536 unsigned int acl_access_count
;
537 unsigned int acl_default_count
;
538 struct posix_acl
* acl_access
;
539 struct posix_acl
* acl_default
;
544 typedef u64 clientid4
;
546 struct nfs4_accessargs
{
547 const struct nfs_fh
* fh
;
552 struct nfs4_accessres
{
553 const struct nfs_server
* server
;
554 struct nfs_fattr
* fattr
;
559 struct nfs4_create_arg
{
563 struct page
** pages
;
565 } symlink
; /* NF4LNK */
569 } device
; /* NF4BLK, NF4CHR */
571 const struct qstr
* name
;
572 const struct nfs_server
* server
;
573 const struct iattr
* attrs
;
574 const struct nfs_fh
* dir_fh
;
578 struct nfs4_create_res
{
579 const struct nfs_server
* server
;
581 struct nfs_fattr
* fattr
;
582 struct nfs4_change_info dir_cinfo
;
583 struct nfs_fattr
* dir_fattr
;
586 struct nfs4_fsinfo_arg
{
587 const struct nfs_fh
* fh
;
591 struct nfs4_getattr_arg
{
592 const struct nfs_fh
* fh
;
596 struct nfs4_getattr_res
{
597 const struct nfs_server
* server
;
598 struct nfs_fattr
* fattr
;
601 struct nfs4_link_arg
{
602 const struct nfs_fh
* fh
;
603 const struct nfs_fh
* dir_fh
;
604 const struct qstr
* name
;
608 struct nfs4_link_res
{
609 const struct nfs_server
* server
;
610 struct nfs_fattr
* fattr
;
611 struct nfs4_change_info cinfo
;
612 struct nfs_fattr
* dir_attr
;
616 struct nfs4_lookup_arg
{
617 const struct nfs_fh
* dir_fh
;
618 const struct qstr
* name
;
622 struct nfs4_lookup_res
{
623 const struct nfs_server
* server
;
624 struct nfs_fattr
* fattr
;
628 struct nfs4_lookup_root_arg
{
632 struct nfs4_pathconf_arg
{
633 const struct nfs_fh
* fh
;
637 struct nfs4_readdir_arg
{
638 const struct nfs_fh
* fh
;
640 nfs4_verifier verifier
;
642 struct page
** pages
; /* zero-copy data */
643 unsigned int pgbase
; /* zero-copy data */
647 struct nfs4_readdir_res
{
648 nfs4_verifier verifier
;
652 struct nfs4_readlink
{
653 const struct nfs_fh
* fh
;
655 unsigned int pglen
; /* zero-copy data */
656 struct page
** pages
; /* zero-copy data */
659 struct nfs4_rename_arg
{
660 const struct nfs_fh
* old_dir
;
661 const struct nfs_fh
* new_dir
;
662 const struct qstr
* old_name
;
663 const struct qstr
* new_name
;
667 struct nfs4_rename_res
{
668 const struct nfs_server
* server
;
669 struct nfs4_change_info old_cinfo
;
670 struct nfs_fattr
* old_fattr
;
671 struct nfs4_change_info new_cinfo
;
672 struct nfs_fattr
* new_fattr
;
675 #define NFS4_SETCLIENTID_NAMELEN (56)
676 struct nfs4_setclientid
{
677 const nfs4_verifier
* sc_verifier
;
678 unsigned int sc_name_len
;
679 char sc_name
[NFS4_SETCLIENTID_NAMELEN
];
681 unsigned int sc_netid_len
;
682 char sc_netid
[RPCBIND_MAXNETIDLEN
];
683 unsigned int sc_uaddr_len
;
684 char sc_uaddr
[RPCBIND_MAXUADDRLEN
];
688 struct nfs4_statfs_arg
{
689 const struct nfs_fh
* fh
;
693 struct nfs4_server_caps_res
{
705 #define NFS4_PATHNAME_MAXCOMPONENTS 512
706 struct nfs4_pathname
{
707 unsigned int ncomponents
;
708 struct nfs4_string components
[NFS4_PATHNAME_MAXCOMPONENTS
];
711 #define NFS4_FS_LOCATION_MAXSERVERS 10
712 struct nfs4_fs_location
{
713 unsigned int nservers
;
714 struct nfs4_string servers
[NFS4_FS_LOCATION_MAXSERVERS
];
715 struct nfs4_pathname rootpath
;
718 #define NFS4_FS_LOCATIONS_MAXENTRIES 10
719 struct nfs4_fs_locations
{
720 struct nfs_fattr fattr
;
721 const struct nfs_server
*server
;
722 struct nfs4_pathname fs_path
;
724 struct nfs4_fs_location locations
[NFS4_FS_LOCATIONS_MAXENTRIES
];
727 struct nfs4_fs_locations_arg
{
728 const struct nfs_fh
*dir_fh
;
729 const struct qstr
*name
;
734 #endif /* CONFIG_NFS_V4 */
738 #define NFS_PAGEVEC_SIZE (8U)
740 struct nfs_read_data
{
742 struct rpc_task task
;
744 struct rpc_cred
*cred
;
745 struct nfs_fattr fattr
; /* fattr storage */
746 struct list_head pages
; /* Coalesced read requests */
747 struct nfs_page
*req
; /* multi ops per nfs_page */
748 struct page
**pagevec
;
749 unsigned int npages
; /* Max length of pagevec */
750 struct nfs_readargs args
;
751 struct nfs_readres res
;
753 unsigned long timestamp
; /* For lease renewal */
755 struct page
*page_array
[NFS_PAGEVEC_SIZE
];
758 struct nfs_write_data
{
760 struct rpc_task task
;
762 struct rpc_cred
*cred
;
763 struct nfs_fattr fattr
;
764 struct nfs_writeverf verf
;
765 struct list_head pages
; /* Coalesced requests we wish to flush */
766 struct nfs_page
*req
; /* multi ops per nfs_page */
767 struct page
**pagevec
;
768 unsigned int npages
; /* Max length of pagevec */
769 struct nfs_writeargs args
; /* argument struct */
770 struct nfs_writeres res
; /* result struct */
772 unsigned long timestamp
; /* For lease renewal */
774 struct page
*page_array
[NFS_PAGEVEC_SIZE
];
777 struct nfs_access_entry
;
780 * RPC procedure vector for NFSv2/NFSv3 demuxing
783 u32 version
; /* Protocol version */
784 struct dentry_operations
*dentry_ops
;
785 const struct inode_operations
*dir_inode_ops
;
786 const struct inode_operations
*file_inode_ops
;
788 int (*getroot
) (struct nfs_server
*, struct nfs_fh
*,
789 struct nfs_fsinfo
*);
790 int (*lookupfh
)(struct nfs_server
*, struct nfs_fh
*,
791 struct qstr
*, struct nfs_fh
*,
793 int (*getattr
) (struct nfs_server
*, struct nfs_fh
*,
795 int (*setattr
) (struct dentry
*, struct nfs_fattr
*,
797 int (*lookup
) (struct inode
*, struct qstr
*,
798 struct nfs_fh
*, struct nfs_fattr
*);
799 int (*access
) (struct inode
*, struct nfs_access_entry
*);
800 int (*readlink
)(struct inode
*, struct page
*, unsigned int,
802 int (*create
) (struct inode
*, struct dentry
*,
803 struct iattr
*, int, struct nameidata
*);
804 int (*remove
) (struct inode
*, struct qstr
*);
805 void (*unlink_setup
) (struct rpc_message
*, struct inode
*dir
);
806 int (*unlink_done
) (struct rpc_task
*, struct inode
*);
807 int (*rename
) (struct inode
*, struct qstr
*,
808 struct inode
*, struct qstr
*);
809 int (*link
) (struct inode
*, struct inode
*, struct qstr
*);
810 int (*symlink
) (struct inode
*, struct dentry
*, struct page
*,
811 unsigned int, struct iattr
*);
812 int (*mkdir
) (struct inode
*, struct dentry
*, struct iattr
*);
813 int (*rmdir
) (struct inode
*, struct qstr
*);
814 int (*readdir
) (struct dentry
*, struct rpc_cred
*,
815 u64
, struct page
*, unsigned int, int);
816 int (*mknod
) (struct inode
*, struct dentry
*, struct iattr
*,
818 int (*statfs
) (struct nfs_server
*, struct nfs_fh
*,
819 struct nfs_fsstat
*);
820 int (*fsinfo
) (struct nfs_server
*, struct nfs_fh
*,
821 struct nfs_fsinfo
*);
822 int (*pathconf
) (struct nfs_server
*, struct nfs_fh
*,
823 struct nfs_pathconf
*);
824 int (*set_capabilities
)(struct nfs_server
*, struct nfs_fh
*);
825 __be32
*(*decode_dirent
)(__be32
*, struct nfs_entry
*, int plus
);
826 void (*read_setup
) (struct nfs_read_data
*, struct rpc_message
*);
827 int (*read_done
) (struct rpc_task
*, struct nfs_read_data
*);
828 void (*write_setup
) (struct nfs_write_data
*, struct rpc_message
*);
829 int (*write_done
) (struct rpc_task
*, struct nfs_write_data
*);
830 void (*commit_setup
) (struct nfs_write_data
*, struct rpc_message
*);
831 int (*commit_done
) (struct rpc_task
*, struct nfs_write_data
*);
832 int (*lock
)(struct file
*, int, struct file_lock
*);
833 int (*lock_check_bounds
)(const struct file_lock
*);
834 void (*clear_acl_cache
)(struct inode
*);
838 * NFS_CALL(getattr, inode, (fattr));
840 * NFS_PROTO(inode)->getattr(fattr);
842 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
845 * Function vectors etc. for the NFS client
847 extern const struct nfs_rpc_ops nfs_v2_clientops
;
848 extern const struct nfs_rpc_ops nfs_v3_clientops
;
849 extern const struct nfs_rpc_ops nfs_v4_clientops
;
850 extern struct rpc_version nfs_version2
;
851 extern struct rpc_version nfs_version3
;
852 extern struct rpc_version nfs_version4
;
854 extern struct rpc_version nfsacl_version3
;
855 extern struct rpc_program nfsacl_program
;