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 * Helper for checking equality between 2 fsids.
25 static inline int nfs_fsid_equal(const struct nfs_fsid *a, const struct nfs_fsid *b)
27 return a->major == b->major && a->minor == b->minor;
31 unsigned short valid; /* which fields are valid */
32 __u64 pre_size; /* pre_op_attr.size */
33 struct timespec pre_mtime; /* pre_op_attr.mtime */
34 struct timespec pre_ctime; /* pre_op_attr.ctime */
35 enum nfs_ftype type; /* always use NFSv2 types */
53 struct timespec atime;
54 struct timespec mtime;
55 struct timespec ctime;
56 __u32 bitmap[2]; /* NFSv4 returned attribute bitmap */
57 __u64 change_attr; /* NFSv4 change attribute */
58 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
59 unsigned long time_start;
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 */
68 * Info on the file system
71 struct nfs_fattr *fattr; /* Post-op attributes */
72 __u32 rtmax; /* max. read transfer size */
73 __u32 rtpref; /* pref. read transfer size */
74 __u32 rtmult; /* reads should be multiple of this */
75 __u32 wtmax; /* max. write transfer size */
76 __u32 wtpref; /* pref. write transfer size */
77 __u32 wtmult; /* writes should be multiple of this */
78 __u32 dtpref; /* pref. readdir transfer size */
80 __u32 lease_time; /* in seconds */
84 struct nfs_fattr *fattr; /* Post-op attributes */
85 __u64 tbytes; /* total size in bytes */
86 __u64 fbytes; /* # of free bytes */
87 __u64 abytes; /* # of bytes available to user */
88 __u64 tfiles; /* # of files */
89 __u64 ffiles; /* # of free files */
90 __u64 afiles; /* # of files available to user */
94 __u32 tsize; /* Server transfer size */
95 __u32 bsize; /* Filesystem block size */
96 __u32 blocks; /* No. of "bsize" blocks on filesystem */
97 __u32 bfree; /* No. of free "bsize" blocks */
98 __u32 bavail; /* No. of available "bsize" blocks */
101 struct nfs_pathconf {
102 struct nfs_fattr *fattr; /* Post-op attributes */
103 __u32 max_link; /* max # of hard links */
104 __u32 max_namelen; /* max name length */
107 struct nfs4_change_info {
115 * Arguments to the open call.
117 struct nfs_openargs {
118 const struct nfs_fh * fh;
119 struct nfs_seqid * seqid;
124 struct iattr * attrs; /* UNCHECKED, GUARDED */
125 nfs4_verifier verifier; /* EXCLUSIVE */
126 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
127 int delegation_type; /* CLAIM_PREVIOUS */
129 const struct qstr * name;
130 const struct nfs_server *server; /* Needed for ID mapping */
136 nfs4_stateid stateid;
138 struct nfs4_change_info cinfo;
140 struct nfs_fattr * f_attr;
141 struct nfs_fattr * dir_attr;
142 const struct nfs_server *server;
144 nfs4_stateid delegation;
150 * Arguments to the open_confirm call.
152 struct nfs_open_confirmargs {
153 const struct nfs_fh * fh;
154 nfs4_stateid * stateid;
155 struct nfs_seqid * seqid;
158 struct nfs_open_confirmres {
159 nfs4_stateid stateid;
163 * Arguments to the close call.
165 struct nfs_closeargs {
167 nfs4_stateid * stateid;
168 struct nfs_seqid * seqid;
173 struct nfs_closeres {
174 nfs4_stateid stateid;
175 struct nfs_fattr * fattr;
176 const struct nfs_server *server;
179 * * Arguments to the lock,lockt, and locku call.
186 struct nfs_lock_args {
188 struct file_lock * fl;
189 struct nfs_seqid * lock_seqid;
190 nfs4_stateid * lock_stateid;
191 struct nfs_seqid * open_seqid;
192 nfs4_stateid * open_stateid;
193 struct nfs_lowner lock_owner;
194 unsigned char block : 1;
195 unsigned char reclaim : 1;
196 unsigned char new_lock_owner : 1;
199 struct nfs_lock_res {
200 nfs4_stateid stateid;
203 struct nfs_locku_args {
205 struct file_lock * fl;
206 struct nfs_seqid * seqid;
207 nfs4_stateid * stateid;
210 struct nfs_locku_res {
211 nfs4_stateid stateid;
214 struct nfs_lockt_args {
216 struct file_lock * fl;
217 struct nfs_lowner lock_owner;
220 struct nfs_lockt_res {
221 struct file_lock * denied; /* LOCK, LOCKT failed */
224 struct nfs4_delegreturnargs {
225 const struct nfs_fh *fhandle;
226 const nfs4_stateid *stateid;
230 struct nfs4_delegreturnres {
231 struct nfs_fattr * fattr;
232 const struct nfs_server *server;
236 * Arguments to the read call.
238 struct nfs_readargs {
240 struct nfs_open_context *context;
244 struct page ** pages;
248 struct nfs_fattr * fattr;
254 * Arguments to the write call.
256 struct nfs_writeargs {
258 struct nfs_open_context *context;
261 enum nfs3_stable_how stable;
263 struct page ** pages;
267 struct nfs_writeverf {
268 enum nfs3_stable_how committed;
272 struct nfs_writeres {
273 struct nfs_fattr * fattr;
274 struct nfs_writeverf * verf;
276 const struct nfs_server *server;
280 * Argument struct for decode_entry function
290 struct nfs_fattr * fattr;
294 * The following types are for NFSv2 only.
296 struct nfs_sattrargs {
298 struct iattr * sattr;
301 struct nfs_diropargs {
307 struct nfs_createargs {
311 struct iattr * sattr;
314 struct nfs_renameargs {
315 struct nfs_fh * fromfh;
316 const char * fromname;
317 unsigned int fromlen;
318 struct nfs_fh * tofh;
323 struct nfs_setattrargs {
325 nfs4_stateid stateid;
327 const struct nfs_server * server; /* Needed for name mapping */
331 struct nfs_setaclargs {
334 unsigned int acl_pgbase;
335 struct page ** acl_pages;
338 struct nfs_getaclargs {
341 unsigned int acl_pgbase;
342 struct page ** acl_pages;
345 struct nfs_setattrres {
346 struct nfs_fattr * fattr;
347 const struct nfs_server * server;
350 struct nfs_linkargs {
351 struct nfs_fh * fromfh;
352 struct nfs_fh * tofh;
357 struct nfs_symlinkargs {
358 struct nfs_fh * fromfh;
359 const char * fromname;
360 unsigned int fromlen;
363 struct iattr * sattr;
366 struct nfs_readdirargs {
370 struct page ** pages;
373 struct nfs3_getaclargs {
376 struct page ** pages;
379 struct nfs3_setaclargs {
380 struct inode * inode;
382 struct posix_acl * acl_access;
383 struct posix_acl * acl_default;
384 struct page ** pages;
389 struct nfs_fattr * fattr;
392 struct nfs_readlinkargs {
396 struct page ** pages;
399 struct nfs3_sattrargs {
401 struct iattr * sattr;
403 struct timespec guardtime;
406 struct nfs3_diropargs {
412 struct nfs3_accessargs {
417 struct nfs3_createargs {
421 struct iattr * sattr;
422 enum nfs3_createmode createmode;
426 struct nfs3_mkdirargs {
430 struct iattr * sattr;
433 struct nfs3_symlinkargs {
434 struct nfs_fh * fromfh;
435 const char * fromname;
436 unsigned int fromlen;
439 struct iattr * sattr;
442 struct nfs3_mknodargs {
446 enum nfs3_ftype type;
447 struct iattr * sattr;
451 struct nfs3_renameargs {
452 struct nfs_fh * fromfh;
453 const char * fromname;
454 unsigned int fromlen;
455 struct nfs_fh * tofh;
460 struct nfs3_linkargs {
461 struct nfs_fh * fromfh;
462 struct nfs_fh * tofh;
467 struct nfs3_readdirargs {
473 struct page ** pages;
476 struct nfs3_diropres {
477 struct nfs_fattr * dir_attr;
479 struct nfs_fattr * fattr;
482 struct nfs3_accessres {
483 struct nfs_fattr * fattr;
487 struct nfs3_readlinkargs {
491 struct page ** pages;
494 struct nfs3_renameres {
495 struct nfs_fattr * fromattr;
496 struct nfs_fattr * toattr;
499 struct nfs3_linkres {
500 struct nfs_fattr * dir_attr;
501 struct nfs_fattr * fattr;
504 struct nfs3_readdirres {
505 struct nfs_fattr * dir_attr;
510 struct nfs3_getaclres {
511 struct nfs_fattr * fattr;
513 unsigned int acl_access_count;
514 unsigned int acl_default_count;
515 struct posix_acl * acl_access;
516 struct posix_acl * acl_default;
521 typedef u64 clientid4;
523 struct nfs4_accessargs {
524 const struct nfs_fh * fh;
528 struct nfs4_accessres {
533 struct nfs4_create_arg {
536 struct qstr * symlink; /* NF4LNK */
540 } device; /* NF4BLK, NF4CHR */
542 const struct qstr * name;
543 const struct nfs_server * server;
544 const struct iattr * attrs;
545 const struct nfs_fh * dir_fh;
549 struct nfs4_create_res {
550 const struct nfs_server * server;
552 struct nfs_fattr * fattr;
553 struct nfs4_change_info dir_cinfo;
554 struct nfs_fattr * dir_fattr;
557 struct nfs4_fsinfo_arg {
558 const struct nfs_fh * fh;
562 struct nfs4_getattr_arg {
563 const struct nfs_fh * fh;
567 struct nfs4_getattr_res {
568 const struct nfs_server * server;
569 struct nfs_fattr * fattr;
572 struct nfs4_link_arg {
573 const struct nfs_fh * fh;
574 const struct nfs_fh * dir_fh;
575 const struct qstr * name;
579 struct nfs4_link_res {
580 const struct nfs_server * server;
581 struct nfs_fattr * fattr;
582 struct nfs4_change_info cinfo;
583 struct nfs_fattr * dir_attr;
587 struct nfs4_lookup_arg {
588 const struct nfs_fh * dir_fh;
589 const struct qstr * name;
593 struct nfs4_lookup_res {
594 const struct nfs_server * server;
595 struct nfs_fattr * fattr;
599 struct nfs4_lookup_root_arg {
603 struct nfs4_pathconf_arg {
604 const struct nfs_fh * fh;
608 struct nfs4_readdir_arg {
609 const struct nfs_fh * fh;
611 nfs4_verifier verifier;
613 struct page ** pages; /* zero-copy data */
614 unsigned int pgbase; /* zero-copy data */
618 struct nfs4_readdir_res {
619 nfs4_verifier verifier;
623 struct nfs4_readlink {
624 const struct nfs_fh * fh;
626 unsigned int pglen; /* zero-copy data */
627 struct page ** pages; /* zero-copy data */
630 struct nfs4_remove_arg {
631 const struct nfs_fh * fh;
632 const struct qstr * name;
636 struct nfs4_remove_res {
637 const struct nfs_server * server;
638 struct nfs4_change_info cinfo;
639 struct nfs_fattr * dir_attr;
642 struct nfs4_rename_arg {
643 const struct nfs_fh * old_dir;
644 const struct nfs_fh * new_dir;
645 const struct qstr * old_name;
646 const struct qstr * new_name;
650 struct nfs4_rename_res {
651 const struct nfs_server * server;
652 struct nfs4_change_info old_cinfo;
653 struct nfs_fattr * old_fattr;
654 struct nfs4_change_info new_cinfo;
655 struct nfs_fattr * new_fattr;
658 struct nfs4_setclientid {
659 const nfs4_verifier * sc_verifier; /* request */
660 unsigned int sc_name_len;
661 char sc_name[32]; /* request */
662 u32 sc_prog; /* request */
663 unsigned int sc_netid_len;
664 char sc_netid[4]; /* request */
665 unsigned int sc_uaddr_len;
666 char sc_uaddr[24]; /* request */
667 u32 sc_cb_ident; /* request */
670 struct nfs4_statfs_arg {
671 const struct nfs_fh * fh;
675 struct nfs4_server_caps_res {
682 #endif /* CONFIG_NFS_V4 */
686 #define NFS_PAGEVEC_SIZE (8U)
688 struct nfs_read_data {
690 struct rpc_task task;
692 struct rpc_cred *cred;
693 struct nfs_fattr fattr; /* fattr storage */
694 struct list_head pages; /* Coalesced read requests */
695 struct nfs_page *req; /* multi ops per nfs_page */
696 struct page **pagevec;
697 struct nfs_readargs args;
698 struct nfs_readres res;
700 unsigned long timestamp; /* For lease renewal */
702 struct page *page_array[NFS_PAGEVEC_SIZE];
705 struct nfs_write_data {
707 struct rpc_task task;
709 struct rpc_cred *cred;
710 struct nfs_fattr fattr;
711 struct nfs_writeverf verf;
712 struct list_head pages; /* Coalesced requests we wish to flush */
713 struct nfs_page *req; /* multi ops per nfs_page */
714 struct page **pagevec;
715 struct nfs_writeargs args; /* argument struct */
716 struct nfs_writeres res; /* result struct */
718 unsigned long timestamp; /* For lease renewal */
720 struct page *page_array[NFS_PAGEVEC_SIZE];
723 struct nfs_access_entry;
726 * RPC procedure vector for NFSv2/NFSv3 demuxing
729 int version; /* Protocol version */
730 struct dentry_operations *dentry_ops;
731 struct inode_operations *dir_inode_ops;
732 struct inode_operations *file_inode_ops;
734 int (*getroot) (struct nfs_server *, struct nfs_fh *,
735 struct nfs_fsinfo *);
736 int (*getattr) (struct nfs_server *, struct nfs_fh *,
738 int (*setattr) (struct dentry *, struct nfs_fattr *,
740 int (*lookup) (struct inode *, struct qstr *,
741 struct nfs_fh *, struct nfs_fattr *);
742 int (*access) (struct inode *, struct nfs_access_entry *);
743 int (*readlink)(struct inode *, struct page *, unsigned int,
745 int (*read) (struct nfs_read_data *);
746 int (*write) (struct nfs_write_data *);
747 int (*commit) (struct nfs_write_data *);
748 int (*create) (struct inode *, struct dentry *,
749 struct iattr *, int, struct nameidata *);
750 int (*remove) (struct inode *, struct qstr *);
751 int (*unlink_setup) (struct rpc_message *,
752 struct dentry *, struct qstr *);
753 int (*unlink_done) (struct dentry *, struct rpc_task *);
754 int (*rename) (struct inode *, struct qstr *,
755 struct inode *, struct qstr *);
756 int (*link) (struct inode *, struct inode *, struct qstr *);
757 int (*symlink) (struct inode *, struct qstr *, struct qstr *,
758 struct iattr *, struct nfs_fh *,
760 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
761 int (*rmdir) (struct inode *, struct qstr *);
762 int (*readdir) (struct dentry *, struct rpc_cred *,
763 u64, struct page *, unsigned int, int);
764 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
766 int (*statfs) (struct nfs_server *, struct nfs_fh *,
767 struct nfs_fsstat *);
768 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
769 struct nfs_fsinfo *);
770 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
771 struct nfs_pathconf *);
772 u32 * (*decode_dirent)(u32 *, struct nfs_entry *, int plus);
773 void (*read_setup) (struct nfs_read_data *);
774 int (*read_done) (struct rpc_task *, struct nfs_read_data *);
775 void (*write_setup) (struct nfs_write_data *, int how);
776 int (*write_done) (struct rpc_task *, struct nfs_write_data *);
777 void (*commit_setup) (struct nfs_write_data *, int how);
778 int (*commit_done) (struct rpc_task *, struct nfs_write_data *);
779 int (*file_open) (struct inode *, struct file *);
780 int (*file_release) (struct inode *, struct file *);
781 int (*lock)(struct file *, int, struct file_lock *);
782 void (*clear_acl_cache)(struct inode *);
786 * NFS_CALL(getattr, inode, (fattr));
788 * NFS_PROTO(inode)->getattr(fattr);
790 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
793 * Function vectors etc. for the NFS client
795 extern struct nfs_rpc_ops nfs_v2_clientops;
796 extern struct nfs_rpc_ops nfs_v3_clientops;
797 extern struct nfs_rpc_ops nfs_v4_clientops;
798 extern struct rpc_version nfs_version2;
799 extern struct rpc_version nfs_version3;
800 extern struct rpc_version nfs_version4;
802 extern struct rpc_version nfsacl_version3;
803 extern struct rpc_program nfsacl_program;