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 * Arguments to the read call.
228 struct nfs_readargs {
230 struct nfs_open_context *context;
234 struct page ** pages;
238 struct nfs_fattr * fattr;
244 * Arguments to the write call.
246 struct nfs_writeargs {
248 struct nfs_open_context *context;
251 enum nfs3_stable_how stable;
253 struct page ** pages;
257 struct nfs_writeverf {
258 enum nfs3_stable_how committed;
262 struct nfs_writeres {
263 struct nfs_fattr * fattr;
264 struct nfs_writeverf * verf;
266 const struct nfs_server *server;
270 * Argument struct for decode_entry function
280 struct nfs_fattr * fattr;
284 * The following types are for NFSv2 only.
286 struct nfs_sattrargs {
288 struct iattr * sattr;
291 struct nfs_diropargs {
297 struct nfs_createargs {
301 struct iattr * sattr;
304 struct nfs_renameargs {
305 struct nfs_fh * fromfh;
306 const char * fromname;
307 unsigned int fromlen;
308 struct nfs_fh * tofh;
313 struct nfs_setattrargs {
315 nfs4_stateid stateid;
317 const struct nfs_server * server; /* Needed for name mapping */
321 struct nfs_setaclargs {
324 unsigned int acl_pgbase;
325 struct page ** acl_pages;
328 struct nfs_getaclargs {
331 unsigned int acl_pgbase;
332 struct page ** acl_pages;
335 struct nfs_setattrres {
336 struct nfs_fattr * fattr;
337 const struct nfs_server * server;
340 struct nfs_linkargs {
341 struct nfs_fh * fromfh;
342 struct nfs_fh * tofh;
347 struct nfs_symlinkargs {
348 struct nfs_fh * fromfh;
349 const char * fromname;
350 unsigned int fromlen;
353 struct iattr * sattr;
356 struct nfs_readdirargs {
360 struct page ** pages;
363 struct nfs3_getaclargs {
366 struct page ** pages;
369 struct nfs3_setaclargs {
370 struct inode * inode;
372 struct posix_acl * acl_access;
373 struct posix_acl * acl_default;
374 struct page ** pages;
379 struct nfs_fattr * fattr;
382 struct nfs_readlinkargs {
386 struct page ** pages;
389 struct nfs3_sattrargs {
391 struct iattr * sattr;
393 struct timespec guardtime;
396 struct nfs3_diropargs {
402 struct nfs3_accessargs {
407 struct nfs3_createargs {
411 struct iattr * sattr;
412 enum nfs3_createmode createmode;
416 struct nfs3_mkdirargs {
420 struct iattr * sattr;
423 struct nfs3_symlinkargs {
424 struct nfs_fh * fromfh;
425 const char * fromname;
426 unsigned int fromlen;
429 struct iattr * sattr;
432 struct nfs3_mknodargs {
436 enum nfs3_ftype type;
437 struct iattr * sattr;
441 struct nfs3_renameargs {
442 struct nfs_fh * fromfh;
443 const char * fromname;
444 unsigned int fromlen;
445 struct nfs_fh * tofh;
450 struct nfs3_linkargs {
451 struct nfs_fh * fromfh;
452 struct nfs_fh * tofh;
457 struct nfs3_readdirargs {
463 struct page ** pages;
466 struct nfs3_diropres {
467 struct nfs_fattr * dir_attr;
469 struct nfs_fattr * fattr;
472 struct nfs3_accessres {
473 struct nfs_fattr * fattr;
477 struct nfs3_readlinkargs {
481 struct page ** pages;
484 struct nfs3_renameres {
485 struct nfs_fattr * fromattr;
486 struct nfs_fattr * toattr;
489 struct nfs3_linkres {
490 struct nfs_fattr * dir_attr;
491 struct nfs_fattr * fattr;
494 struct nfs3_readdirres {
495 struct nfs_fattr * dir_attr;
500 struct nfs3_getaclres {
501 struct nfs_fattr * fattr;
503 unsigned int acl_access_count;
504 unsigned int acl_default_count;
505 struct posix_acl * acl_access;
506 struct posix_acl * acl_default;
511 typedef u64 clientid4;
513 struct nfs4_accessargs {
514 const struct nfs_fh * fh;
518 struct nfs4_accessres {
523 struct nfs4_create_arg {
526 struct qstr * symlink; /* NF4LNK */
530 } device; /* NF4BLK, NF4CHR */
532 const struct qstr * name;
533 const struct nfs_server * server;
534 const struct iattr * attrs;
535 const struct nfs_fh * dir_fh;
539 struct nfs4_create_res {
540 const struct nfs_server * server;
542 struct nfs_fattr * fattr;
543 struct nfs4_change_info dir_cinfo;
544 struct nfs_fattr * dir_fattr;
547 struct nfs4_fsinfo_arg {
548 const struct nfs_fh * fh;
552 struct nfs4_getattr_arg {
553 const struct nfs_fh * fh;
557 struct nfs4_getattr_res {
558 const struct nfs_server * server;
559 struct nfs_fattr * fattr;
562 struct nfs4_link_arg {
563 const struct nfs_fh * fh;
564 const struct nfs_fh * dir_fh;
565 const struct qstr * name;
569 struct nfs4_link_res {
570 const struct nfs_server * server;
571 struct nfs_fattr * fattr;
572 struct nfs4_change_info cinfo;
573 struct nfs_fattr * dir_attr;
577 struct nfs4_lookup_arg {
578 const struct nfs_fh * dir_fh;
579 const struct qstr * name;
583 struct nfs4_lookup_res {
584 const struct nfs_server * server;
585 struct nfs_fattr * fattr;
589 struct nfs4_lookup_root_arg {
593 struct nfs4_pathconf_arg {
594 const struct nfs_fh * fh;
598 struct nfs4_readdir_arg {
599 const struct nfs_fh * fh;
601 nfs4_verifier verifier;
603 struct page ** pages; /* zero-copy data */
604 unsigned int pgbase; /* zero-copy data */
608 struct nfs4_readdir_res {
609 nfs4_verifier verifier;
613 struct nfs4_readlink {
614 const struct nfs_fh * fh;
616 unsigned int pglen; /* zero-copy data */
617 struct page ** pages; /* zero-copy data */
620 struct nfs4_remove_arg {
621 const struct nfs_fh * fh;
622 const struct qstr * name;
626 struct nfs4_remove_res {
627 const struct nfs_server * server;
628 struct nfs4_change_info cinfo;
629 struct nfs_fattr * dir_attr;
632 struct nfs4_rename_arg {
633 const struct nfs_fh * old_dir;
634 const struct nfs_fh * new_dir;
635 const struct qstr * old_name;
636 const struct qstr * new_name;
640 struct nfs4_rename_res {
641 const struct nfs_server * server;
642 struct nfs4_change_info old_cinfo;
643 struct nfs_fattr * old_fattr;
644 struct nfs4_change_info new_cinfo;
645 struct nfs_fattr * new_fattr;
648 struct nfs4_setclientid {
649 const nfs4_verifier * sc_verifier; /* request */
650 unsigned int sc_name_len;
651 char sc_name[32]; /* request */
652 u32 sc_prog; /* request */
653 unsigned int sc_netid_len;
654 char sc_netid[4]; /* request */
655 unsigned int sc_uaddr_len;
656 char sc_uaddr[24]; /* request */
657 u32 sc_cb_ident; /* request */
660 struct nfs4_statfs_arg {
661 const struct nfs_fh * fh;
665 struct nfs4_server_caps_res {
672 #endif /* CONFIG_NFS_V4 */
676 #define NFS_PAGEVEC_SIZE (8U)
678 struct nfs_read_data {
680 struct rpc_task task;
682 struct rpc_cred *cred;
683 struct nfs_fattr fattr; /* fattr storage */
684 struct list_head pages; /* Coalesced read requests */
685 struct nfs_page *req; /* multi ops per nfs_page */
686 struct page **pagevec;
687 struct nfs_readargs args;
688 struct nfs_readres res;
690 unsigned long timestamp; /* For lease renewal */
692 void (*complete) (struct nfs_read_data *, int);
693 struct page *page_array[NFS_PAGEVEC_SIZE + 1];
696 struct nfs_write_data {
698 struct rpc_task task;
700 struct rpc_cred *cred;
701 struct nfs_fattr fattr;
702 struct nfs_writeverf verf;
703 struct list_head pages; /* Coalesced requests we wish to flush */
704 struct nfs_page *req; /* multi ops per nfs_page */
705 struct page **pagevec;
706 struct nfs_writeargs args; /* argument struct */
707 struct nfs_writeres res; /* result struct */
709 unsigned long timestamp; /* For lease renewal */
711 void (*complete) (struct nfs_write_data *, int);
712 struct page *page_array[NFS_PAGEVEC_SIZE + 1];
715 struct nfs_access_entry;
718 * RPC procedure vector for NFSv2/NFSv3 demuxing
721 int version; /* Protocol version */
722 struct dentry_operations *dentry_ops;
723 struct inode_operations *dir_inode_ops;
724 struct inode_operations *file_inode_ops;
726 int (*getroot) (struct nfs_server *, struct nfs_fh *,
727 struct nfs_fsinfo *);
728 int (*getattr) (struct nfs_server *, struct nfs_fh *,
730 int (*setattr) (struct dentry *, struct nfs_fattr *,
732 int (*lookup) (struct inode *, struct qstr *,
733 struct nfs_fh *, struct nfs_fattr *);
734 int (*access) (struct inode *, struct nfs_access_entry *);
735 int (*readlink)(struct inode *, struct page *, unsigned int,
737 int (*read) (struct nfs_read_data *);
738 int (*write) (struct nfs_write_data *);
739 int (*commit) (struct nfs_write_data *);
740 int (*create) (struct inode *, struct dentry *,
741 struct iattr *, int, struct nameidata *);
742 int (*remove) (struct inode *, struct qstr *);
743 int (*unlink_setup) (struct rpc_message *,
744 struct dentry *, struct qstr *);
745 int (*unlink_done) (struct dentry *, struct rpc_task *);
746 int (*rename) (struct inode *, struct qstr *,
747 struct inode *, struct qstr *);
748 int (*link) (struct inode *, struct inode *, struct qstr *);
749 int (*symlink) (struct inode *, struct qstr *, struct qstr *,
750 struct iattr *, struct nfs_fh *,
752 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
753 int (*rmdir) (struct inode *, struct qstr *);
754 int (*readdir) (struct dentry *, struct rpc_cred *,
755 u64, struct page *, unsigned int, int);
756 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
758 int (*statfs) (struct nfs_server *, struct nfs_fh *,
759 struct nfs_fsstat *);
760 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
761 struct nfs_fsinfo *);
762 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
763 struct nfs_pathconf *);
764 u32 * (*decode_dirent)(u32 *, struct nfs_entry *, int plus);
765 void (*read_setup) (struct nfs_read_data *);
766 void (*write_setup) (struct nfs_write_data *, int how);
767 void (*commit_setup) (struct nfs_write_data *, int how);
768 int (*file_open) (struct inode *, struct file *);
769 int (*file_release) (struct inode *, struct file *);
770 int (*lock)(struct file *, int, struct file_lock *);
771 void (*clear_acl_cache)(struct inode *);
775 * NFS_CALL(getattr, inode, (fattr));
777 * NFS_PROTO(inode)->getattr(fattr);
779 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
782 * Function vectors etc. for the NFS client
784 extern struct nfs_rpc_ops nfs_v2_clientops;
785 extern struct nfs_rpc_ops nfs_v3_clientops;
786 extern struct nfs_rpc_ops nfs_v4_clientops;
787 extern struct rpc_version nfs_version2;
788 extern struct rpc_version nfs_version3;
789 extern struct rpc_version nfs_version4;
791 extern struct rpc_version nfsacl_version3;
792 extern struct rpc_program nfsacl_program;