1 #ifndef _LINUX_NFS_XDR_H
2 #define _LINUX_NFS_XDR_H
4 #include <linux/sunrpc/xprt.h>
5 #include <linux/nfsacl.h>
8 * To change the maximum rsize and wsize supported by the NFS client, adjust
9 * NFS_MAX_FILE_IO_SIZE. 64KB is a typical maximum, but some servers can
10 * support a megabyte or more. The default is left at 4096 bytes, which is
11 * reasonable for NFS over UDP.
13 #define NFS_MAX_FILE_IO_SIZE (1048576U)
14 #define NFS_DEF_FILE_IO_SIZE (4096U)
15 #define NFS_MIN_FILE_IO_SIZE (1024U)
23 unsigned short valid
; /* which fields are valid */
24 __u64 pre_size
; /* pre_op_attr.size */
25 struct timespec pre_mtime
; /* pre_op_attr.mtime */
26 struct timespec pre_ctime
; /* pre_op_attr.ctime */
27 enum nfs_ftype type
; /* always use NFSv2 types */
44 __u64 nfs3
; /* also nfs2 */
45 struct nfs4_fsid nfs4
;
48 struct timespec atime
;
49 struct timespec mtime
;
50 struct timespec ctime
;
51 __u32 bitmap
[2]; /* NFSv4 returned attribute bitmap */
52 __u64 change_attr
; /* NFSv4 change attribute */
53 __u64 pre_change_attr
;/* pre-op NFSv4 change attribute */
54 unsigned long time_start
;
57 #define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */
58 #define NFS_ATTR_FATTR 0x0002 /* post-op attributes */
59 #define NFS_ATTR_FATTR_V3 0x0004 /* NFSv3 attributes */
60 #define NFS_ATTR_FATTR_V4 0x0008
61 #define NFS_ATTR_PRE_CHANGE 0x0010
64 * Info on the file system
67 struct nfs_fattr
*fattr
; /* Post-op attributes */
68 __u32 rtmax
; /* max. read transfer size */
69 __u32 rtpref
; /* pref. read transfer size */
70 __u32 rtmult
; /* reads should be multiple of this */
71 __u32 wtmax
; /* max. write transfer size */
72 __u32 wtpref
; /* pref. write transfer size */
73 __u32 wtmult
; /* writes should be multiple of this */
74 __u32 dtpref
; /* pref. readdir transfer size */
76 __u32 lease_time
; /* in seconds */
80 struct nfs_fattr
*fattr
; /* Post-op attributes */
81 __u64 tbytes
; /* total size in bytes */
82 __u64 fbytes
; /* # of free bytes */
83 __u64 abytes
; /* # of bytes available to user */
84 __u64 tfiles
; /* # of files */
85 __u64 ffiles
; /* # of free files */
86 __u64 afiles
; /* # of files available to user */
90 __u32 tsize
; /* Server transfer size */
91 __u32 bsize
; /* Filesystem block size */
92 __u32 blocks
; /* No. of "bsize" blocks on filesystem */
93 __u32 bfree
; /* No. of free "bsize" blocks */
94 __u32 bavail
; /* No. of available "bsize" blocks */
98 struct nfs_fattr
*fattr
; /* Post-op attributes */
99 __u32 max_link
; /* max # of hard links */
100 __u32 max_namelen
; /* max name length */
103 struct nfs4_change_info
{
111 * Arguments to the open call.
113 struct nfs_openargs
{
114 const struct nfs_fh
* fh
;
115 struct nfs_seqid
* seqid
;
120 struct iattr
* attrs
; /* UNCHECKED, GUARDED */
121 nfs4_verifier verifier
; /* EXCLUSIVE */
122 nfs4_stateid delegation
; /* CLAIM_DELEGATE_CUR */
123 int delegation_type
; /* CLAIM_PREVIOUS */
125 const struct qstr
* name
;
126 const struct nfs_server
*server
; /* Needed for ID mapping */
132 nfs4_stateid stateid
;
134 struct nfs4_change_info cinfo
;
136 struct nfs_fattr
* f_attr
;
137 struct nfs_fattr
* dir_attr
;
138 const struct nfs_server
*server
;
140 nfs4_stateid delegation
;
146 * Arguments to the open_confirm call.
148 struct nfs_open_confirmargs
{
149 const struct nfs_fh
* fh
;
150 nfs4_stateid
* stateid
;
151 struct nfs_seqid
* seqid
;
154 struct nfs_open_confirmres
{
155 nfs4_stateid stateid
;
159 * Arguments to the close call.
161 struct nfs_closeargs
{
163 nfs4_stateid
* stateid
;
164 struct nfs_seqid
* seqid
;
169 struct nfs_closeres
{
170 nfs4_stateid stateid
;
171 struct nfs_fattr
* fattr
;
172 const struct nfs_server
*server
;
175 * * Arguments to the lock,lockt, and locku call.
182 struct nfs_lock_args
{
184 struct file_lock
* fl
;
185 struct nfs_seqid
* lock_seqid
;
186 nfs4_stateid
* lock_stateid
;
187 struct nfs_seqid
* open_seqid
;
188 nfs4_stateid
* open_stateid
;
189 struct nfs_lowner lock_owner
;
190 unsigned char block
: 1;
191 unsigned char reclaim
: 1;
192 unsigned char new_lock_owner
: 1;
195 struct nfs_lock_res
{
196 nfs4_stateid stateid
;
199 struct nfs_locku_args
{
201 struct file_lock
* fl
;
202 struct nfs_seqid
* seqid
;
203 nfs4_stateid
* stateid
;
206 struct nfs_locku_res
{
207 nfs4_stateid stateid
;
210 struct nfs_lockt_args
{
212 struct file_lock
* fl
;
213 struct nfs_lowner lock_owner
;
216 struct nfs_lockt_res
{
217 struct file_lock
* denied
; /* LOCK, LOCKT failed */
220 struct nfs4_delegreturnargs
{
221 const struct nfs_fh
*fhandle
;
222 const nfs4_stateid
*stateid
;
226 struct nfs4_delegreturnres
{
227 struct nfs_fattr
* fattr
;
228 const struct nfs_server
*server
;
232 * Arguments to the read call.
234 struct nfs_readargs
{
236 struct nfs_open_context
*context
;
240 struct page
** pages
;
244 struct nfs_fattr
* fattr
;
250 * Arguments to the write call.
252 struct nfs_writeargs
{
254 struct nfs_open_context
*context
;
257 enum nfs3_stable_how stable
;
259 struct page
** pages
;
263 struct nfs_writeverf
{
264 enum nfs3_stable_how committed
;
268 struct nfs_writeres
{
269 struct nfs_fattr
* fattr
;
270 struct nfs_writeverf
* verf
;
272 const struct nfs_server
*server
;
276 * Argument struct for decode_entry function
286 struct nfs_fattr
* fattr
;
290 * The following types are for NFSv2 only.
292 struct nfs_sattrargs
{
294 struct iattr
* sattr
;
297 struct nfs_diropargs
{
303 struct nfs_createargs
{
307 struct iattr
* sattr
;
310 struct nfs_renameargs
{
311 struct nfs_fh
* fromfh
;
312 const char * fromname
;
313 unsigned int fromlen
;
314 struct nfs_fh
* tofh
;
319 struct nfs_setattrargs
{
321 nfs4_stateid stateid
;
323 const struct nfs_server
* server
; /* Needed for name mapping */
327 struct nfs_setaclargs
{
330 unsigned int acl_pgbase
;
331 struct page
** acl_pages
;
334 struct nfs_getaclargs
{
337 unsigned int acl_pgbase
;
338 struct page
** acl_pages
;
341 struct nfs_setattrres
{
342 struct nfs_fattr
* fattr
;
343 const struct nfs_server
* server
;
346 struct nfs_linkargs
{
347 struct nfs_fh
* fromfh
;
348 struct nfs_fh
* tofh
;
353 struct nfs_symlinkargs
{
354 struct nfs_fh
* fromfh
;
355 const char * fromname
;
356 unsigned int fromlen
;
359 struct iattr
* sattr
;
362 struct nfs_readdirargs
{
366 struct page
** pages
;
369 struct nfs3_getaclargs
{
372 struct page
** pages
;
375 struct nfs3_setaclargs
{
376 struct inode
* inode
;
378 struct posix_acl
* acl_access
;
379 struct posix_acl
* acl_default
;
380 struct page
** pages
;
385 struct nfs_fattr
* fattr
;
388 struct nfs_readlinkargs
{
392 struct page
** pages
;
395 struct nfs3_sattrargs
{
397 struct iattr
* sattr
;
399 struct timespec guardtime
;
402 struct nfs3_diropargs
{
408 struct nfs3_accessargs
{
413 struct nfs3_createargs
{
417 struct iattr
* sattr
;
418 enum nfs3_createmode createmode
;
422 struct nfs3_mkdirargs
{
426 struct iattr
* sattr
;
429 struct nfs3_symlinkargs
{
430 struct nfs_fh
* fromfh
;
431 const char * fromname
;
432 unsigned int fromlen
;
435 struct iattr
* sattr
;
438 struct nfs3_mknodargs
{
442 enum nfs3_ftype type
;
443 struct iattr
* sattr
;
447 struct nfs3_renameargs
{
448 struct nfs_fh
* fromfh
;
449 const char * fromname
;
450 unsigned int fromlen
;
451 struct nfs_fh
* tofh
;
456 struct nfs3_linkargs
{
457 struct nfs_fh
* fromfh
;
458 struct nfs_fh
* tofh
;
463 struct nfs3_readdirargs
{
469 struct page
** pages
;
472 struct nfs3_diropres
{
473 struct nfs_fattr
* dir_attr
;
475 struct nfs_fattr
* fattr
;
478 struct nfs3_accessres
{
479 struct nfs_fattr
* fattr
;
483 struct nfs3_readlinkargs
{
487 struct page
** pages
;
490 struct nfs3_renameres
{
491 struct nfs_fattr
* fromattr
;
492 struct nfs_fattr
* toattr
;
495 struct nfs3_linkres
{
496 struct nfs_fattr
* dir_attr
;
497 struct nfs_fattr
* fattr
;
500 struct nfs3_readdirres
{
501 struct nfs_fattr
* dir_attr
;
506 struct nfs3_getaclres
{
507 struct nfs_fattr
* fattr
;
509 unsigned int acl_access_count
;
510 unsigned int acl_default_count
;
511 struct posix_acl
* acl_access
;
512 struct posix_acl
* acl_default
;
517 typedef u64 clientid4
;
519 struct nfs4_accessargs
{
520 const struct nfs_fh
* fh
;
524 struct nfs4_accessres
{
529 struct nfs4_create_arg
{
532 struct qstr
* symlink
; /* NF4LNK */
536 } device
; /* NF4BLK, NF4CHR */
538 const struct qstr
* name
;
539 const struct nfs_server
* server
;
540 const struct iattr
* attrs
;
541 const struct nfs_fh
* dir_fh
;
545 struct nfs4_create_res
{
546 const struct nfs_server
* server
;
548 struct nfs_fattr
* fattr
;
549 struct nfs4_change_info dir_cinfo
;
550 struct nfs_fattr
* dir_fattr
;
553 struct nfs4_fsinfo_arg
{
554 const struct nfs_fh
* fh
;
558 struct nfs4_getattr_arg
{
559 const struct nfs_fh
* fh
;
563 struct nfs4_getattr_res
{
564 const struct nfs_server
* server
;
565 struct nfs_fattr
* fattr
;
568 struct nfs4_link_arg
{
569 const struct nfs_fh
* fh
;
570 const struct nfs_fh
* dir_fh
;
571 const struct qstr
* name
;
575 struct nfs4_link_res
{
576 const struct nfs_server
* server
;
577 struct nfs_fattr
* fattr
;
578 struct nfs4_change_info cinfo
;
579 struct nfs_fattr
* dir_attr
;
583 struct nfs4_lookup_arg
{
584 const struct nfs_fh
* dir_fh
;
585 const struct qstr
* name
;
589 struct nfs4_lookup_res
{
590 const struct nfs_server
* server
;
591 struct nfs_fattr
* fattr
;
595 struct nfs4_lookup_root_arg
{
599 struct nfs4_pathconf_arg
{
600 const struct nfs_fh
* fh
;
604 struct nfs4_readdir_arg
{
605 const struct nfs_fh
* fh
;
607 nfs4_verifier verifier
;
609 struct page
** pages
; /* zero-copy data */
610 unsigned int pgbase
; /* zero-copy data */
614 struct nfs4_readdir_res
{
615 nfs4_verifier verifier
;
619 struct nfs4_readlink
{
620 const struct nfs_fh
* fh
;
622 unsigned int pglen
; /* zero-copy data */
623 struct page
** pages
; /* zero-copy data */
626 struct nfs4_remove_arg
{
627 const struct nfs_fh
* fh
;
628 const struct qstr
* name
;
632 struct nfs4_remove_res
{
633 const struct nfs_server
* server
;
634 struct nfs4_change_info cinfo
;
635 struct nfs_fattr
* dir_attr
;
638 struct nfs4_rename_arg
{
639 const struct nfs_fh
* old_dir
;
640 const struct nfs_fh
* new_dir
;
641 const struct qstr
* old_name
;
642 const struct qstr
* new_name
;
646 struct nfs4_rename_res
{
647 const struct nfs_server
* server
;
648 struct nfs4_change_info old_cinfo
;
649 struct nfs_fattr
* old_fattr
;
650 struct nfs4_change_info new_cinfo
;
651 struct nfs_fattr
* new_fattr
;
654 struct nfs4_setclientid
{
655 const nfs4_verifier
* sc_verifier
; /* request */
656 unsigned int sc_name_len
;
657 char sc_name
[32]; /* request */
658 u32 sc_prog
; /* request */
659 unsigned int sc_netid_len
;
660 char sc_netid
[4]; /* request */
661 unsigned int sc_uaddr_len
;
662 char sc_uaddr
[24]; /* request */
663 u32 sc_cb_ident
; /* request */
666 struct nfs4_statfs_arg
{
667 const struct nfs_fh
* fh
;
671 struct nfs4_server_caps_res
{
678 #endif /* CONFIG_NFS_V4 */
682 #define NFS_PAGEVEC_SIZE (8U)
684 struct nfs_read_data
{
686 struct rpc_task task
;
688 struct rpc_cred
*cred
;
689 struct nfs_fattr fattr
; /* fattr storage */
690 struct list_head pages
; /* Coalesced read requests */
691 struct nfs_page
*req
; /* multi ops per nfs_page */
692 struct page
**pagevec
;
693 struct nfs_readargs args
;
694 struct nfs_readres res
;
696 unsigned long timestamp
; /* For lease renewal */
698 struct page
*page_array
[NFS_PAGEVEC_SIZE
+ 1];
701 struct nfs_write_data
{
703 struct rpc_task task
;
705 struct rpc_cred
*cred
;
706 struct nfs_fattr fattr
;
707 struct nfs_writeverf verf
;
708 struct list_head pages
; /* Coalesced requests we wish to flush */
709 struct nfs_page
*req
; /* multi ops per nfs_page */
710 struct page
**pagevec
;
711 struct nfs_writeargs args
; /* argument struct */
712 struct nfs_writeres res
; /* result struct */
714 unsigned long timestamp
; /* For lease renewal */
716 struct page
*page_array
[NFS_PAGEVEC_SIZE
+ 1];
719 struct nfs_access_entry
;
722 * RPC procedure vector for NFSv2/NFSv3 demuxing
725 int version
; /* Protocol version */
726 struct dentry_operations
*dentry_ops
;
727 struct inode_operations
*dir_inode_ops
;
728 struct inode_operations
*file_inode_ops
;
730 int (*getroot
) (struct nfs_server
*, struct nfs_fh
*,
731 struct nfs_fsinfo
*);
732 int (*getattr
) (struct nfs_server
*, struct nfs_fh
*,
734 int (*setattr
) (struct dentry
*, struct nfs_fattr
*,
736 int (*lookup
) (struct inode
*, struct qstr
*,
737 struct nfs_fh
*, struct nfs_fattr
*);
738 int (*access
) (struct inode
*, struct nfs_access_entry
*);
739 int (*readlink
)(struct inode
*, struct page
*, unsigned int,
741 int (*read
) (struct nfs_read_data
*);
742 int (*write
) (struct nfs_write_data
*);
743 int (*commit
) (struct nfs_write_data
*);
744 int (*create
) (struct inode
*, struct dentry
*,
745 struct iattr
*, int, struct nameidata
*);
746 int (*remove
) (struct inode
*, struct qstr
*);
747 int (*unlink_setup
) (struct rpc_message
*,
748 struct dentry
*, struct qstr
*);
749 int (*unlink_done
) (struct dentry
*, struct rpc_task
*);
750 int (*rename
) (struct inode
*, struct qstr
*,
751 struct inode
*, struct qstr
*);
752 int (*link
) (struct inode
*, struct inode
*, struct qstr
*);
753 int (*symlink
) (struct inode
*, struct qstr
*, struct qstr
*,
754 struct iattr
*, struct nfs_fh
*,
756 int (*mkdir
) (struct inode
*, struct dentry
*, struct iattr
*);
757 int (*rmdir
) (struct inode
*, struct qstr
*);
758 int (*readdir
) (struct dentry
*, struct rpc_cred
*,
759 u64
, struct page
*, unsigned int, int);
760 int (*mknod
) (struct inode
*, struct dentry
*, struct iattr
*,
762 int (*statfs
) (struct nfs_server
*, struct nfs_fh
*,
763 struct nfs_fsstat
*);
764 int (*fsinfo
) (struct nfs_server
*, struct nfs_fh
*,
765 struct nfs_fsinfo
*);
766 int (*pathconf
) (struct nfs_server
*, struct nfs_fh
*,
767 struct nfs_pathconf
*);
768 u32
* (*decode_dirent
)(u32
*, struct nfs_entry
*, int plus
);
769 void (*read_setup
) (struct nfs_read_data
*);
770 int (*read_done
) (struct rpc_task
*, struct nfs_read_data
*);
771 void (*write_setup
) (struct nfs_write_data
*, int how
);
772 int (*write_done
) (struct rpc_task
*, struct nfs_write_data
*);
773 void (*commit_setup
) (struct nfs_write_data
*, int how
);
774 int (*commit_done
) (struct rpc_task
*, struct nfs_write_data
*);
775 int (*file_open
) (struct inode
*, struct file
*);
776 int (*file_release
) (struct inode
*, struct file
*);
777 int (*lock
)(struct file
*, int, struct file_lock
*);
778 void (*clear_acl_cache
)(struct inode
*);
782 * NFS_CALL(getattr, inode, (fattr));
784 * NFS_PROTO(inode)->getattr(fattr);
786 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
789 * Function vectors etc. for the NFS client
791 extern struct nfs_rpc_ops nfs_v2_clientops
;
792 extern struct nfs_rpc_ops nfs_v3_clientops
;
793 extern struct nfs_rpc_ops nfs_v4_clientops
;
794 extern struct rpc_version nfs_version2
;
795 extern struct rpc_version nfs_version3
;
796 extern struct rpc_version nfs_version4
;
798 extern struct rpc_version nfsacl_version3
;
799 extern struct rpc_program nfsacl_program
;