1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_NFS_XDR_H
3 #define _LINUX_NFS_XDR_H
5 #include <linux/nfsacl.h>
6 #include <linux/sunrpc/gss_api.h>
9 * To change the maximum rsize and wsize supported by the NFS client, adjust
10 * NFS_MAX_FILE_IO_SIZE. 64KB is a typical maximum, but some servers can
11 * support a megabyte or more. The default is left at 4096 bytes, which is
12 * reasonable for NFS over UDP.
14 #define NFS_MAX_FILE_IO_SIZE (1048576U)
15 #define NFS_DEF_FILE_IO_SIZE (4096U)
16 #define NFS_MIN_FILE_IO_SIZE (1024U)
29 * Helper for checking equality between 2 fsids.
31 static inline int nfs_fsid_equal(const struct nfs_fsid *a, const struct nfs_fsid *b)
33 return a->major == b->major && a->minor == b->minor;
36 struct nfs4_threshold {
46 unsigned int valid; /* which fields are valid */
64 __u64 mounted_on_fileid;
65 struct timespec64 atime;
66 struct timespec64 mtime;
67 struct timespec64 ctime;
68 __u64 change_attr; /* NFSv4 change attribute */
69 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
70 __u64 pre_size; /* pre_op_attr.size */
71 struct timespec64 pre_mtime; /* pre_op_attr.mtime */
72 struct timespec64 pre_ctime; /* pre_op_attr.ctime */
73 unsigned long time_start;
74 unsigned long gencount;
75 struct nfs4_string *owner_name;
76 struct nfs4_string *group_name;
77 struct nfs4_threshold *mdsthreshold; /* pNFS threshold hints */
78 struct nfs4_label *label;
81 #define NFS_ATTR_FATTR_TYPE (1U << 0)
82 #define NFS_ATTR_FATTR_MODE (1U << 1)
83 #define NFS_ATTR_FATTR_NLINK (1U << 2)
84 #define NFS_ATTR_FATTR_OWNER (1U << 3)
85 #define NFS_ATTR_FATTR_GROUP (1U << 4)
86 #define NFS_ATTR_FATTR_RDEV (1U << 5)
87 #define NFS_ATTR_FATTR_SIZE (1U << 6)
88 #define NFS_ATTR_FATTR_PRESIZE (1U << 7)
89 #define NFS_ATTR_FATTR_BLOCKS_USED (1U << 8)
90 #define NFS_ATTR_FATTR_SPACE_USED (1U << 9)
91 #define NFS_ATTR_FATTR_FSID (1U << 10)
92 #define NFS_ATTR_FATTR_FILEID (1U << 11)
93 #define NFS_ATTR_FATTR_ATIME (1U << 12)
94 #define NFS_ATTR_FATTR_MTIME (1U << 13)
95 #define NFS_ATTR_FATTR_CTIME (1U << 14)
96 #define NFS_ATTR_FATTR_PREMTIME (1U << 15)
97 #define NFS_ATTR_FATTR_PRECTIME (1U << 16)
98 #define NFS_ATTR_FATTR_CHANGE (1U << 17)
99 #define NFS_ATTR_FATTR_PRECHANGE (1U << 18)
100 #define NFS_ATTR_FATTR_V4_LOCATIONS (1U << 19)
101 #define NFS_ATTR_FATTR_V4_REFERRAL (1U << 20)
102 #define NFS_ATTR_FATTR_MOUNTPOINT (1U << 21)
103 #define NFS_ATTR_FATTR_MOUNTED_ON_FILEID (1U << 22)
104 #define NFS_ATTR_FATTR_OWNER_NAME (1U << 23)
105 #define NFS_ATTR_FATTR_GROUP_NAME (1U << 24)
106 #define NFS_ATTR_FATTR_V4_SECURITY_LABEL (1U << 25)
108 #define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \
109 | NFS_ATTR_FATTR_MODE \
110 | NFS_ATTR_FATTR_NLINK \
111 | NFS_ATTR_FATTR_OWNER \
112 | NFS_ATTR_FATTR_GROUP \
113 | NFS_ATTR_FATTR_RDEV \
114 | NFS_ATTR_FATTR_SIZE \
115 | NFS_ATTR_FATTR_FSID \
116 | NFS_ATTR_FATTR_FILEID \
117 | NFS_ATTR_FATTR_ATIME \
118 | NFS_ATTR_FATTR_MTIME \
119 | NFS_ATTR_FATTR_CTIME \
120 | NFS_ATTR_FATTR_CHANGE)
121 #define NFS_ATTR_FATTR_V2 (NFS_ATTR_FATTR \
122 | NFS_ATTR_FATTR_BLOCKS_USED)
123 #define NFS_ATTR_FATTR_V3 (NFS_ATTR_FATTR \
124 | NFS_ATTR_FATTR_SPACE_USED)
125 #define NFS_ATTR_FATTR_V4 (NFS_ATTR_FATTR \
126 | NFS_ATTR_FATTR_SPACE_USED \
127 | NFS_ATTR_FATTR_V4_SECURITY_LABEL)
130 * Maximal number of supported layout drivers.
132 #define NFS_MAX_LAYOUT_TYPES 8
135 * Info on the file system
138 struct nfs_fattr *fattr; /* Post-op attributes */
139 __u32 rtmax; /* max. read transfer size */
140 __u32 rtpref; /* pref. read transfer size */
141 __u32 rtmult; /* reads should be multiple of this */
142 __u32 wtmax; /* max. write transfer size */
143 __u32 wtpref; /* pref. write transfer size */
144 __u32 wtmult; /* writes should be multiple of this */
145 __u32 dtpref; /* pref. readdir transfer size */
147 struct timespec64 time_delta; /* server time granularity */
148 __u32 lease_time; /* in seconds */
149 __u32 nlayouttypes; /* number of layouttypes */
150 __u32 layouttype[NFS_MAX_LAYOUT_TYPES]; /* supported pnfs layout driver */
151 __u32 blksize; /* preferred pnfs io block size */
152 __u32 clone_blksize; /* granularity of a CLONE operation */
156 struct nfs_fattr *fattr; /* Post-op attributes */
157 __u64 tbytes; /* total size in bytes */
158 __u64 fbytes; /* # of free bytes */
159 __u64 abytes; /* # of bytes available to user */
160 __u64 tfiles; /* # of files */
161 __u64 ffiles; /* # of free files */
162 __u64 afiles; /* # of files available to user */
166 __u32 tsize; /* Server transfer size */
167 __u32 bsize; /* Filesystem block size */
168 __u32 blocks; /* No. of "bsize" blocks on filesystem */
169 __u32 bfree; /* No. of free "bsize" blocks */
170 __u32 bavail; /* No. of available "bsize" blocks */
173 struct nfs_pathconf {
174 struct nfs_fattr *fattr; /* Post-op attributes */
175 __u32 max_link; /* max # of hard links */
176 __u32 max_namelen; /* max name length */
179 struct nfs4_change_info {
187 /* nfs41 sessions channel attributes */
188 struct nfs4_channel_attrs {
191 u32 max_resp_sz_cached;
197 struct nfs4_sequence_args {
198 struct nfs4_slot *sa_slot;
199 u8 sa_cache_this : 1,
203 struct nfs4_sequence_res {
204 struct nfs4_slot *sr_slot; /* slot used to send request */
205 unsigned long sr_timestamp;
206 int sr_status; /* sequence operation status */
208 u32 sr_highest_slotid;
209 u32 sr_target_highest_slotid;
212 struct nfs4_get_lease_time_args {
213 struct nfs4_sequence_args la_seq_args;
216 struct nfs4_get_lease_time_res {
217 struct nfs4_sequence_res lr_seq_res;
218 struct nfs_fsinfo *lr_fsinfo;
222 struct nfs4_xdr_opaque_data;
224 struct nfs4_xdr_opaque_ops {
225 void (*encode)(struct xdr_stream *, const void *args,
226 const struct nfs4_xdr_opaque_data *);
227 void (*free)(struct nfs4_xdr_opaque_data *);
230 struct nfs4_xdr_opaque_data {
231 const struct nfs4_xdr_opaque_ops *ops;
235 #define PNFS_LAYOUT_MAXSIZE 4096
237 struct nfs4_layoutdriver_data {
243 struct pnfs_layout_range {
249 struct nfs4_layoutget_args {
250 struct nfs4_sequence_args seq_args;
252 struct pnfs_layout_range range;
256 struct nfs_open_context *ctx;
257 nfs4_stateid stateid;
258 struct nfs4_layoutdriver_data layout;
261 struct nfs4_layoutget_res {
262 struct nfs4_sequence_res seq_res;
264 __u32 return_on_close;
265 struct pnfs_layout_range range;
267 nfs4_stateid stateid;
268 struct nfs4_layoutdriver_data *layoutp;
271 struct nfs4_layoutget {
272 struct nfs4_layoutget_args args;
273 struct nfs4_layoutget_res res;
274 const struct cred *cred;
278 struct nfs4_getdeviceinfo_args {
279 struct nfs4_sequence_args seq_args;
280 struct pnfs_device *pdev;
284 struct nfs4_getdeviceinfo_res {
285 struct nfs4_sequence_res seq_res;
286 struct pnfs_device *pdev;
290 struct nfs4_layoutcommit_args {
291 struct nfs4_sequence_args seq_args;
292 nfs4_stateid stateid;
293 __u64 lastbytewritten;
296 size_t layoutupdate_len;
297 struct page *layoutupdate_page;
298 struct page **layoutupdate_pages;
302 struct nfs4_layoutcommit_res {
303 struct nfs4_sequence_res seq_res;
304 struct nfs_fattr *fattr;
305 const struct nfs_server *server;
309 struct nfs4_layoutcommit_data {
310 struct rpc_task task;
311 struct nfs_fattr fattr;
312 struct list_head lseg_list;
313 const struct cred *cred;
315 struct nfs4_layoutcommit_args args;
316 struct nfs4_layoutcommit_res res;
319 struct nfs4_layoutreturn_args {
320 struct nfs4_sequence_args seq_args;
321 struct pnfs_layout_hdr *layout;
323 struct pnfs_layout_range range;
324 nfs4_stateid stateid;
326 struct nfs4_xdr_opaque_data *ld_private;
329 struct nfs4_layoutreturn_res {
330 struct nfs4_sequence_res seq_res;
332 nfs4_stateid stateid;
335 struct nfs4_layoutreturn {
336 struct nfs4_layoutreturn_args args;
337 struct nfs4_layoutreturn_res res;
338 const struct cred *cred;
339 struct nfs_client *clp;
342 struct nfs4_xdr_opaque_data ld_private;
345 #define PNFS_LAYOUTSTATS_MAXSIZE 256
347 struct nfs42_layoutstat_args;
348 struct nfs42_layoutstat_devinfo;
349 typedef void (*layoutstats_encode_t)(struct xdr_stream *,
350 struct nfs42_layoutstat_args *,
351 struct nfs42_layoutstat_devinfo *);
353 /* Per file per deviceid layoutstats */
354 struct nfs42_layoutstat_devinfo {
355 struct nfs4_deviceid dev_id;
363 struct nfs4_xdr_opaque_data ld_private;
366 struct nfs42_layoutstat_args {
367 struct nfs4_sequence_args seq_args;
370 nfs4_stateid stateid;
372 struct nfs42_layoutstat_devinfo *devinfo;
375 struct nfs42_layoutstat_res {
376 struct nfs4_sequence_res seq_res;
381 struct nfs42_layoutstat_data {
383 struct nfs42_layoutstat_args args;
384 struct nfs42_layoutstat_res res;
387 struct nfs42_device_error {
388 struct nfs4_deviceid dev_id;
390 enum nfs_opnum4 opnum;
393 struct nfs42_layout_error {
396 nfs4_stateid stateid;
397 struct nfs42_device_error errors[1];
400 #define NFS42_LAYOUTERROR_MAX 5
402 struct nfs42_layouterror_args {
403 struct nfs4_sequence_args seq_args;
405 unsigned int num_errors;
406 struct nfs42_layout_error errors[NFS42_LAYOUTERROR_MAX];
409 struct nfs42_layouterror_res {
410 struct nfs4_sequence_res seq_res;
411 unsigned int num_errors;
415 struct nfs42_layouterror_data {
416 struct nfs42_layouterror_args args;
417 struct nfs42_layouterror_res res;
419 struct pnfs_layout_segment *lseg;
422 struct nfs42_clone_args {
423 struct nfs4_sequence_args seq_args;
424 struct nfs_fh *src_fh;
425 struct nfs_fh *dst_fh;
426 nfs4_stateid src_stateid;
427 nfs4_stateid dst_stateid;
431 const u32 *dst_bitmask;
434 struct nfs42_clone_res {
435 struct nfs4_sequence_res seq_res;
436 unsigned int rpc_status;
437 struct nfs_fattr *dst_fattr;
438 const struct nfs_server *server;
441 struct stateowner_id {
447 * Arguments to the open call.
449 struct nfs_openargs {
450 struct nfs4_sequence_args seq_args;
451 const struct nfs_fh * fh;
452 struct nfs_seqid * seqid;
458 struct stateowner_id id;
461 struct iattr * attrs; /* UNCHECKED, GUARDED, EXCLUSIVE4_1 */
462 nfs4_verifier verifier; /* EXCLUSIVE */
464 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
465 fmode_t delegation_type; /* CLAIM_PREVIOUS */
467 const struct qstr * name;
468 const struct nfs_server *server; /* Needed for ID mapping */
470 const u32 * open_bitmap;
471 enum open_claim_type4 claim;
472 enum createmode4 createmode;
473 const struct nfs4_label *label;
475 struct nfs4_layoutget_args *lg_args;
479 struct nfs4_sequence_res seq_res;
480 nfs4_stateid stateid;
482 struct nfs4_change_info cinfo;
484 struct nfs_fattr * f_attr;
485 struct nfs4_label *f_label;
486 struct nfs_seqid * seqid;
487 const struct nfs_server *server;
488 fmode_t delegation_type;
489 nfs4_stateid delegation;
490 unsigned long pagemod_limit;
492 __u32 attrset[NFS4_BITMAP_SIZE];
493 struct nfs4_string *owner;
494 struct nfs4_string *group_owner;
495 __u32 access_request;
496 __u32 access_supported;
498 struct nfs4_layoutget_res *lg_res;
502 * Arguments to the open_confirm call.
504 struct nfs_open_confirmargs {
505 struct nfs4_sequence_args seq_args;
506 const struct nfs_fh * fh;
507 nfs4_stateid * stateid;
508 struct nfs_seqid * seqid;
511 struct nfs_open_confirmres {
512 struct nfs4_sequence_res seq_res;
513 nfs4_stateid stateid;
514 struct nfs_seqid * seqid;
518 * Arguments to the close call.
520 struct nfs_closeargs {
521 struct nfs4_sequence_args seq_args;
523 nfs4_stateid stateid;
524 struct nfs_seqid * seqid;
528 struct nfs4_layoutreturn_args *lr_args;
531 struct nfs_closeres {
532 struct nfs4_sequence_res seq_res;
533 nfs4_stateid stateid;
534 struct nfs_fattr * fattr;
535 struct nfs_seqid * seqid;
536 const struct nfs_server *server;
537 struct nfs4_layoutreturn_res *lr_res;
541 * * Arguments to the lock,lockt, and locku call.
549 struct nfs_lock_args {
550 struct nfs4_sequence_args seq_args;
552 struct file_lock * fl;
553 struct nfs_seqid * lock_seqid;
554 nfs4_stateid lock_stateid;
555 struct nfs_seqid * open_seqid;
556 nfs4_stateid open_stateid;
557 struct nfs_lowner lock_owner;
558 unsigned char block : 1;
559 unsigned char reclaim : 1;
560 unsigned char new_lock : 1;
561 unsigned char new_lock_owner : 1;
564 struct nfs_lock_res {
565 struct nfs4_sequence_res seq_res;
566 nfs4_stateid stateid;
567 struct nfs_seqid * lock_seqid;
568 struct nfs_seqid * open_seqid;
571 struct nfs_locku_args {
572 struct nfs4_sequence_args seq_args;
574 struct file_lock * fl;
575 struct nfs_seqid * seqid;
576 nfs4_stateid stateid;
579 struct nfs_locku_res {
580 struct nfs4_sequence_res seq_res;
581 nfs4_stateid stateid;
582 struct nfs_seqid * seqid;
585 struct nfs_lockt_args {
586 struct nfs4_sequence_args seq_args;
588 struct file_lock * fl;
589 struct nfs_lowner lock_owner;
592 struct nfs_lockt_res {
593 struct nfs4_sequence_res seq_res;
594 struct file_lock * denied; /* LOCK, LOCKT failed */
597 struct nfs_release_lockowner_args {
598 struct nfs4_sequence_args seq_args;
599 struct nfs_lowner lock_owner;
602 struct nfs_release_lockowner_res {
603 struct nfs4_sequence_res seq_res;
606 struct nfs4_delegreturnargs {
607 struct nfs4_sequence_args seq_args;
608 const struct nfs_fh *fhandle;
609 const nfs4_stateid *stateid;
611 struct nfs4_layoutreturn_args *lr_args;
614 struct nfs4_delegreturnres {
615 struct nfs4_sequence_res seq_res;
616 struct nfs_fattr * fattr;
617 struct nfs_server *server;
618 struct nfs4_layoutreturn_res *lr_res;
623 * Arguments to the write call.
625 struct nfs_write_verifier {
629 struct nfs_writeverf {
630 struct nfs_write_verifier verifier;
631 enum nfs3_stable_how committed;
635 * Arguments shared by the read and write call.
637 struct nfs_pgio_args {
638 struct nfs4_sequence_args seq_args;
640 struct nfs_open_context *context;
641 struct nfs_lock_context *lock_context;
642 nfs4_stateid stateid;
646 struct page ** pages;
648 unsigned int replen; /* used by read */
650 const u32 * bitmask; /* used by write */
651 enum nfs3_stable_how stable; /* used by write */
656 struct nfs_pgio_res {
657 struct nfs4_sequence_res seq_res;
658 struct nfs_fattr * fattr;
663 unsigned int replen; /* used by read */
664 int eof; /* used by read */
667 struct nfs_writeverf * verf; /* used by write */
668 const struct nfs_server *server; /* used by write */
674 * Arguments to the commit call.
676 struct nfs_commitargs {
677 struct nfs4_sequence_args seq_args;
684 struct nfs_commitres {
685 struct nfs4_sequence_res seq_res;
687 struct nfs_fattr *fattr;
688 struct nfs_writeverf *verf;
689 const struct nfs_server *server;
693 * Common arguments to the unlink call
695 struct nfs_removeargs {
696 struct nfs4_sequence_args seq_args;
697 const struct nfs_fh *fh;
701 struct nfs_removeres {
702 struct nfs4_sequence_res seq_res;
703 struct nfs_server *server;
704 struct nfs_fattr *dir_attr;
705 struct nfs4_change_info cinfo;
709 * Common arguments to the rename call
711 struct nfs_renameargs {
712 struct nfs4_sequence_args seq_args;
713 const struct nfs_fh *old_dir;
714 const struct nfs_fh *new_dir;
715 const struct qstr *old_name;
716 const struct qstr *new_name;
719 struct nfs_renameres {
720 struct nfs4_sequence_res seq_res;
721 struct nfs_server *server;
722 struct nfs4_change_info old_cinfo;
723 struct nfs_fattr *old_fattr;
724 struct nfs4_change_info new_cinfo;
725 struct nfs_fattr *new_fattr;
728 /* parsed sec= options */
729 #define NFS_AUTH_INFO_MAX_FLAVORS 12 /* see fs/nfs/super.c */
730 struct nfs_auth_info {
731 unsigned int flavor_len;
732 rpc_authflavor_t flavors[NFS_AUTH_INFO_MAX_FLAVORS];
736 * Argument struct for decode_entry function
746 struct nfs_fattr * fattr;
747 struct nfs4_label *label;
748 unsigned char d_type;
749 struct nfs_server * server;
753 * The following types are for NFSv2 only.
755 struct nfs_sattrargs {
757 struct iattr * sattr;
760 struct nfs_diropargs {
766 struct nfs_createargs {
770 struct iattr * sattr;
773 struct nfs_setattrargs {
774 struct nfs4_sequence_args seq_args;
776 nfs4_stateid stateid;
778 const struct nfs_server * server; /* Needed for name mapping */
780 const struct nfs4_label *label;
783 struct nfs_setaclargs {
784 struct nfs4_sequence_args seq_args;
787 struct page ** acl_pages;
790 struct nfs_setaclres {
791 struct nfs4_sequence_res seq_res;
794 struct nfs_getaclargs {
795 struct nfs4_sequence_args seq_args;
798 struct page ** acl_pages;
801 /* getxattr ACL interface flags */
802 #define NFS4_ACL_TRUNC 0x0001 /* ACL was truncated */
803 struct nfs_getaclres {
804 struct nfs4_sequence_res seq_res;
806 size_t acl_data_offset;
808 struct page * acl_scratch;
811 struct nfs_setattrres {
812 struct nfs4_sequence_res seq_res;
813 struct nfs_fattr * fattr;
814 struct nfs4_label *label;
815 const struct nfs_server * server;
818 struct nfs_linkargs {
819 struct nfs_fh * fromfh;
820 struct nfs_fh * tofh;
825 struct nfs_symlinkargs {
826 struct nfs_fh * fromfh;
827 const char * fromname;
828 unsigned int fromlen;
829 struct page ** pages;
830 unsigned int pathlen;
831 struct iattr * sattr;
834 struct nfs_readdirargs {
838 struct page ** pages;
841 struct nfs3_getaclargs {
844 struct page ** pages;
847 struct nfs3_setaclargs {
848 struct inode * inode;
850 struct posix_acl * acl_access;
851 struct posix_acl * acl_default;
854 struct page ** pages;
859 struct nfs_fattr * fattr;
862 struct nfs_readlinkargs {
866 struct page ** pages;
869 struct nfs3_sattrargs {
871 struct iattr * sattr;
873 struct timespec64 guardtime;
876 struct nfs3_diropargs {
882 struct nfs3_accessargs {
887 struct nfs3_createargs {
891 struct iattr * sattr;
892 enum nfs3_createmode createmode;
896 struct nfs3_mkdirargs {
900 struct iattr * sattr;
903 struct nfs3_symlinkargs {
904 struct nfs_fh * fromfh;
905 const char * fromname;
906 unsigned int fromlen;
907 struct page ** pages;
908 unsigned int pathlen;
909 struct iattr * sattr;
912 struct nfs3_mknodargs {
916 enum nfs3_ftype type;
917 struct iattr * sattr;
921 struct nfs3_linkargs {
922 struct nfs_fh * fromfh;
923 struct nfs_fh * tofh;
928 struct nfs3_readdirargs {
934 struct page ** pages;
937 struct nfs3_diropres {
938 struct nfs_fattr * dir_attr;
940 struct nfs_fattr * fattr;
943 struct nfs3_accessres {
944 struct nfs_fattr * fattr;
948 struct nfs3_readlinkargs {
952 struct page ** pages;
955 struct nfs3_linkres {
956 struct nfs_fattr * dir_attr;
957 struct nfs_fattr * fattr;
960 struct nfs3_readdirres {
961 struct nfs_fattr * dir_attr;
966 struct nfs3_getaclres {
967 struct nfs_fattr * fattr;
969 unsigned int acl_access_count;
970 unsigned int acl_default_count;
971 struct posix_acl * acl_access;
972 struct posix_acl * acl_default;
975 #if IS_ENABLED(CONFIG_NFS_V4)
977 typedef u64 clientid4;
979 struct nfs4_accessargs {
980 struct nfs4_sequence_args seq_args;
981 const struct nfs_fh * fh;
986 struct nfs4_accessres {
987 struct nfs4_sequence_res seq_res;
988 const struct nfs_server * server;
989 struct nfs_fattr * fattr;
994 struct nfs4_create_arg {
995 struct nfs4_sequence_args seq_args;
999 struct page ** pages;
1001 } symlink; /* NF4LNK */
1005 } device; /* NF4BLK, NF4CHR */
1007 const struct qstr * name;
1008 const struct nfs_server * server;
1009 const struct iattr * attrs;
1010 const struct nfs_fh * dir_fh;
1011 const u32 * bitmask;
1012 const struct nfs4_label *label;
1016 struct nfs4_create_res {
1017 struct nfs4_sequence_res seq_res;
1018 const struct nfs_server * server;
1020 struct nfs_fattr * fattr;
1021 struct nfs4_label *label;
1022 struct nfs4_change_info dir_cinfo;
1025 struct nfs4_fsinfo_arg {
1026 struct nfs4_sequence_args seq_args;
1027 const struct nfs_fh * fh;
1028 const u32 * bitmask;
1031 struct nfs4_fsinfo_res {
1032 struct nfs4_sequence_res seq_res;
1033 struct nfs_fsinfo *fsinfo;
1036 struct nfs4_getattr_arg {
1037 struct nfs4_sequence_args seq_args;
1038 const struct nfs_fh * fh;
1039 const u32 * bitmask;
1042 struct nfs4_getattr_res {
1043 struct nfs4_sequence_res seq_res;
1044 const struct nfs_server * server;
1045 struct nfs_fattr * fattr;
1046 struct nfs4_label *label;
1049 struct nfs4_link_arg {
1050 struct nfs4_sequence_args seq_args;
1051 const struct nfs_fh * fh;
1052 const struct nfs_fh * dir_fh;
1053 const struct qstr * name;
1054 const u32 * bitmask;
1057 struct nfs4_link_res {
1058 struct nfs4_sequence_res seq_res;
1059 const struct nfs_server * server;
1060 struct nfs_fattr * fattr;
1061 struct nfs4_label *label;
1062 struct nfs4_change_info cinfo;
1063 struct nfs_fattr * dir_attr;
1066 struct nfs4_lookup_arg {
1067 struct nfs4_sequence_args seq_args;
1068 const struct nfs_fh * dir_fh;
1069 const struct qstr * name;
1070 const u32 * bitmask;
1073 struct nfs4_lookup_res {
1074 struct nfs4_sequence_res seq_res;
1075 const struct nfs_server * server;
1076 struct nfs_fattr * fattr;
1078 struct nfs4_label *label;
1081 struct nfs4_lookupp_arg {
1082 struct nfs4_sequence_args seq_args;
1083 const struct nfs_fh *fh;
1087 struct nfs4_lookupp_res {
1088 struct nfs4_sequence_res seq_res;
1089 const struct nfs_server *server;
1090 struct nfs_fattr *fattr;
1092 struct nfs4_label *label;
1095 struct nfs4_lookup_root_arg {
1096 struct nfs4_sequence_args seq_args;
1097 const u32 * bitmask;
1100 struct nfs4_pathconf_arg {
1101 struct nfs4_sequence_args seq_args;
1102 const struct nfs_fh * fh;
1103 const u32 * bitmask;
1106 struct nfs4_pathconf_res {
1107 struct nfs4_sequence_res seq_res;
1108 struct nfs_pathconf *pathconf;
1111 struct nfs4_readdir_arg {
1112 struct nfs4_sequence_args seq_args;
1113 const struct nfs_fh * fh;
1115 nfs4_verifier verifier;
1117 struct page ** pages; /* zero-copy data */
1118 unsigned int pgbase; /* zero-copy data */
1119 const u32 * bitmask;
1123 struct nfs4_readdir_res {
1124 struct nfs4_sequence_res seq_res;
1125 nfs4_verifier verifier;
1126 unsigned int pgbase;
1129 struct nfs4_readlink {
1130 struct nfs4_sequence_args seq_args;
1131 const struct nfs_fh * fh;
1132 unsigned int pgbase;
1133 unsigned int pglen; /* zero-copy data */
1134 struct page ** pages; /* zero-copy data */
1137 struct nfs4_readlink_res {
1138 struct nfs4_sequence_res seq_res;
1141 struct nfs4_setclientid {
1142 const nfs4_verifier * sc_verifier;
1144 unsigned int sc_netid_len;
1145 char sc_netid[RPCBIND_MAXNETIDLEN + 1];
1146 unsigned int sc_uaddr_len;
1147 char sc_uaddr[RPCBIND_MAXUADDRLEN + 1];
1148 struct nfs_client *sc_clnt;
1149 struct rpc_cred *sc_cred;
1152 struct nfs4_setclientid_res {
1154 nfs4_verifier confirm;
1157 struct nfs4_statfs_arg {
1158 struct nfs4_sequence_args seq_args;
1159 const struct nfs_fh * fh;
1160 const u32 * bitmask;
1163 struct nfs4_statfs_res {
1164 struct nfs4_sequence_res seq_res;
1165 struct nfs_fsstat *fsstat;
1168 struct nfs4_server_caps_arg {
1169 struct nfs4_sequence_args seq_args;
1170 struct nfs_fh *fhandle;
1171 const u32 * bitmask;
1174 struct nfs4_server_caps_res {
1175 struct nfs4_sequence_res seq_res;
1176 u32 attr_bitmask[3];
1177 u32 exclcreat_bitmask[3];
1184 #define NFS4_PATHNAME_MAXCOMPONENTS 512
1185 struct nfs4_pathname {
1186 unsigned int ncomponents;
1187 struct nfs4_string components[NFS4_PATHNAME_MAXCOMPONENTS];
1190 #define NFS4_FS_LOCATION_MAXSERVERS 10
1191 struct nfs4_fs_location {
1192 unsigned int nservers;
1193 struct nfs4_string servers[NFS4_FS_LOCATION_MAXSERVERS];
1194 struct nfs4_pathname rootpath;
1197 #define NFS4_FS_LOCATIONS_MAXENTRIES 10
1198 struct nfs4_fs_locations {
1199 struct nfs_fattr fattr;
1200 const struct nfs_server *server;
1201 struct nfs4_pathname fs_path;
1203 struct nfs4_fs_location locations[NFS4_FS_LOCATIONS_MAXENTRIES];
1206 struct nfs4_fs_locations_arg {
1207 struct nfs4_sequence_args seq_args;
1208 const struct nfs_fh *dir_fh;
1209 const struct nfs_fh *fh;
1210 const struct qstr *name;
1214 unsigned char migration:1, renew:1;
1217 struct nfs4_fs_locations_res {
1218 struct nfs4_sequence_res seq_res;
1219 struct nfs4_fs_locations *fs_locations;
1220 unsigned char migration:1, renew:1;
1223 struct nfs4_secinfo4 {
1225 struct rpcsec_gss_info flavor_info;
1228 struct nfs4_secinfo_flavors {
1229 unsigned int num_flavors;
1230 struct nfs4_secinfo4 flavors[0];
1233 struct nfs4_secinfo_arg {
1234 struct nfs4_sequence_args seq_args;
1235 const struct nfs_fh *dir_fh;
1236 const struct qstr *name;
1239 struct nfs4_secinfo_res {
1240 struct nfs4_sequence_res seq_res;
1241 struct nfs4_secinfo_flavors *flavors;
1244 struct nfs4_fsid_present_arg {
1245 struct nfs4_sequence_args seq_args;
1246 const struct nfs_fh *fh;
1248 unsigned char renew:1;
1251 struct nfs4_fsid_present_res {
1252 struct nfs4_sequence_res seq_res;
1254 unsigned char renew:1;
1257 #endif /* CONFIG_NFS_V4 */
1264 #ifdef CONFIG_NFS_V4_1
1266 struct pnfs_commit_bucket {
1267 struct list_head written;
1268 struct list_head committing;
1269 struct pnfs_layout_segment *lseg;
1270 struct nfs_writeverf direct_verf;
1273 struct pnfs_commit_array {
1274 struct list_head cinfo_list;
1275 struct list_head lseg_list;
1276 struct pnfs_layout_segment *lseg;
1277 struct rcu_head rcu;
1278 refcount_t refcount;
1279 unsigned int nbuckets;
1280 struct pnfs_commit_bucket buckets[];
1283 struct pnfs_ds_commit_info {
1284 struct list_head commits;
1285 unsigned int nwritten;
1286 unsigned int ncommitting;
1287 const struct pnfs_commit_ops *ops;
1290 struct nfs41_state_protection {
1292 struct nfs4_op_map enforce;
1293 struct nfs4_op_map allow;
1296 struct nfs41_exchange_id_args {
1297 struct nfs_client *client;
1298 nfs4_verifier verifier;
1300 struct nfs41_state_protection state_protect;
1303 struct nfs41_server_owner {
1305 uint32_t major_id_sz;
1306 char major_id[NFS4_OPAQUE_LIMIT];
1309 struct nfs41_server_scope {
1310 uint32_t server_scope_sz;
1311 char server_scope[NFS4_OPAQUE_LIMIT];
1314 struct nfs41_impl_id {
1315 char domain[NFS4_OPAQUE_LIMIT + 1];
1316 char name[NFS4_OPAQUE_LIMIT + 1];
1317 struct nfstime4 date;
1320 struct nfs41_bind_conn_to_session_args {
1321 struct nfs_client *client;
1322 struct nfs4_sessionid sessionid;
1324 bool use_conn_in_rdma_mode;
1327 struct nfs41_bind_conn_to_session_res {
1328 struct nfs4_sessionid sessionid;
1330 bool use_conn_in_rdma_mode;
1333 struct nfs41_exchange_id_res {
1337 struct nfs41_server_owner *server_owner;
1338 struct nfs41_server_scope *server_scope;
1339 struct nfs41_impl_id *impl_id;
1340 struct nfs41_state_protection state_protect;
1343 struct nfs41_create_session_args {
1344 struct nfs_client *client;
1348 uint32_t cb_program;
1349 struct nfs4_channel_attrs fc_attrs; /* Fore Channel */
1350 struct nfs4_channel_attrs bc_attrs; /* Back Channel */
1353 struct nfs41_create_session_res {
1354 struct nfs4_sessionid sessionid;
1357 struct nfs4_channel_attrs fc_attrs; /* Fore Channel */
1358 struct nfs4_channel_attrs bc_attrs; /* Back Channel */
1361 struct nfs41_reclaim_complete_args {
1362 struct nfs4_sequence_args seq_args;
1363 /* In the future extend to include curr_fh for use with migration */
1364 unsigned char one_fs:1;
1367 struct nfs41_reclaim_complete_res {
1368 struct nfs4_sequence_res seq_res;
1371 #define SECINFO_STYLE_CURRENT_FH 0
1372 #define SECINFO_STYLE_PARENT 1
1373 struct nfs41_secinfo_no_name_args {
1374 struct nfs4_sequence_args seq_args;
1378 struct nfs41_test_stateid_args {
1379 struct nfs4_sequence_args seq_args;
1380 nfs4_stateid *stateid;
1383 struct nfs41_test_stateid_res {
1384 struct nfs4_sequence_res seq_res;
1385 unsigned int status;
1388 struct nfs41_free_stateid_args {
1389 struct nfs4_sequence_args seq_args;
1390 nfs4_stateid stateid;
1393 struct nfs41_free_stateid_res {
1394 struct nfs4_sequence_res seq_res;
1395 unsigned int status;
1400 struct pnfs_ds_commit_info {
1403 #endif /* CONFIG_NFS_V4_1 */
1405 #ifdef CONFIG_NFS_V4_2
1406 struct nfs42_falloc_args {
1407 struct nfs4_sequence_args seq_args;
1409 struct nfs_fh *falloc_fh;
1410 nfs4_stateid falloc_stateid;
1413 const u32 *falloc_bitmask;
1416 struct nfs42_falloc_res {
1417 struct nfs4_sequence_res seq_res;
1418 unsigned int status;
1420 struct nfs_fattr *falloc_fattr;
1421 const struct nfs_server *falloc_server;
1424 struct nfs42_copy_args {
1425 struct nfs4_sequence_args seq_args;
1427 struct nfs_fh *src_fh;
1428 nfs4_stateid src_stateid;
1431 struct nfs_fh *dst_fh;
1432 nfs4_stateid dst_stateid;
1437 struct nl4_server *cp_src;
1440 struct nfs42_write_res {
1441 nfs4_stateid stateid;
1443 struct nfs_writeverf verifier;
1446 struct nfs42_copy_res {
1447 struct nfs4_sequence_res seq_res;
1448 struct nfs42_write_res write_res;
1451 struct nfs_commitres commit_res;
1454 struct nfs42_offload_status_args {
1455 struct nfs4_sequence_args osa_seq_args;
1456 struct nfs_fh *osa_src_fh;
1457 nfs4_stateid osa_stateid;
1460 struct nfs42_offload_status_res {
1461 struct nfs4_sequence_res osr_seq_res;
1466 struct nfs42_copy_notify_args {
1467 struct nfs4_sequence_args cna_seq_args;
1469 struct nfs_fh *cna_src_fh;
1470 nfs4_stateid cna_src_stateid;
1471 struct nl4_server cna_dst;
1474 struct nfs42_copy_notify_res {
1475 struct nfs4_sequence_res cnr_seq_res;
1477 struct nfstime4 cnr_lease_time;
1478 nfs4_stateid cnr_stateid;
1479 struct nl4_server cnr_src;
1482 struct nfs42_seek_args {
1483 struct nfs4_sequence_args seq_args;
1485 struct nfs_fh *sa_fh;
1486 nfs4_stateid sa_stateid;
1491 struct nfs42_seek_res {
1492 struct nfs4_sequence_res seq_res;
1493 unsigned int status;
1502 #define NFS_PAGEVEC_SIZE (8U)
1504 struct nfs_page_array {
1505 struct page **pagevec;
1506 unsigned int npages; /* Max length of pagevec */
1507 struct page *page_array[NFS_PAGEVEC_SIZE];
1510 /* used as flag bits in nfs_pgio_header */
1512 NFS_IOHDR_ERROR = 0,
1516 NFS_IOHDR_RESEND_PNFS,
1517 NFS_IOHDR_RESEND_MDS,
1520 struct nfs_io_completion;
1521 struct nfs_pgio_header {
1522 struct inode *inode;
1523 const struct cred *cred;
1524 struct list_head pages;
1525 struct nfs_page *req;
1526 struct nfs_writeverf verf; /* Used for writes */
1528 struct pnfs_layout_segment *lseg;
1530 const struct rpc_call_ops *mds_ops;
1531 void (*release) (struct nfs_pgio_header *hdr);
1532 const struct nfs_pgio_completion_ops *completion_ops;
1533 const struct nfs_rw_ops *rw_ops;
1534 struct nfs_io_completion *io_completion;
1535 struct nfs_direct_req *dreq;
1538 int error; /* merge with pnfs_error */
1539 unsigned int good_bytes; /* boundary of good data */
1540 unsigned long flags;
1545 struct rpc_task task;
1546 struct nfs_fattr fattr;
1547 struct nfs_pgio_args args; /* argument struct */
1548 struct nfs_pgio_res res; /* result struct */
1549 unsigned long timestamp; /* For lease renewal */
1550 int (*pgio_done_cb)(struct rpc_task *, struct nfs_pgio_header *);
1551 __u64 mds_offset; /* Filelayout dense stripe */
1552 struct nfs_page_array page_array;
1553 struct nfs_client *ds_clp; /* pNFS data server */
1554 int ds_commit_idx; /* ds index if ds_clp is set */
1555 int pgio_mirror_idx;/* mirror index in pgio layer */
1558 struct nfs_mds_commit_info {
1560 atomic_long_t ncommit;
1561 struct list_head list;
1564 struct nfs_commit_info;
1565 struct nfs_commit_data;
1567 struct nfs_commit_completion_ops {
1568 void (*completion) (struct nfs_commit_data *data);
1569 void (*resched_write) (struct nfs_commit_info *, struct nfs_page *);
1572 struct nfs_commit_info {
1573 struct inode *inode; /* Needed for inode->i_lock */
1574 struct nfs_mds_commit_info *mds;
1575 struct pnfs_ds_commit_info *ds;
1576 struct nfs_direct_req *dreq; /* O_DIRECT request */
1577 const struct nfs_commit_completion_ops *completion_ops;
1580 struct nfs_commit_data {
1581 struct rpc_task task;
1582 struct inode *inode;
1583 const struct cred *cred;
1584 struct nfs_fattr fattr;
1585 struct nfs_writeverf verf;
1586 struct list_head pages; /* Coalesced requests we wish to flush */
1587 struct list_head list; /* lists of struct nfs_write_data */
1588 struct nfs_direct_req *dreq; /* O_DIRECT request */
1589 struct nfs_commitargs args; /* argument struct */
1590 struct nfs_commitres res; /* result struct */
1591 struct nfs_open_context *context;
1592 struct pnfs_layout_segment *lseg;
1593 struct nfs_client *ds_clp; /* pNFS data server */
1594 int ds_commit_index;
1596 const struct rpc_call_ops *mds_ops;
1597 const struct nfs_commit_completion_ops *completion_ops;
1598 int (*commit_done_cb) (struct rpc_task *task, struct nfs_commit_data *data);
1599 unsigned long flags;
1602 struct nfs_pgio_completion_ops {
1603 void (*error_cleanup)(struct list_head *head, int);
1604 void (*init_hdr)(struct nfs_pgio_header *hdr);
1605 void (*completion)(struct nfs_pgio_header *hdr);
1606 void (*reschedule_io)(struct nfs_pgio_header *hdr);
1609 struct nfs_unlinkdata {
1610 struct nfs_removeargs args;
1611 struct nfs_removeres res;
1612 struct dentry *dentry;
1613 wait_queue_head_t wq;
1614 const struct cred *cred;
1615 struct nfs_fattr dir_attr;
1619 struct nfs_renamedata {
1620 struct nfs_renameargs args;
1621 struct nfs_renameres res;
1622 const struct cred *cred;
1623 struct inode *old_dir;
1624 struct dentry *old_dentry;
1625 struct nfs_fattr old_fattr;
1626 struct inode *new_dir;
1627 struct dentry *new_dentry;
1628 struct nfs_fattr new_fattr;
1629 void (*complete)(struct rpc_task *, struct nfs_renamedata *);
1634 struct nfs_access_entry;
1637 struct nfs_subversion;
1638 struct nfs_mount_info;
1639 struct nfs_client_initdata;
1640 struct nfs_pageio_descriptor;
1644 * RPC procedure vector for NFSv2/NFSv3 demuxing
1646 struct nfs_rpc_ops {
1647 u32 version; /* Protocol version */
1648 const struct dentry_operations *dentry_ops;
1649 const struct inode_operations *dir_inode_ops;
1650 const struct inode_operations *file_inode_ops;
1651 const struct file_operations *file_ops;
1652 const struct nlmclnt_operations *nlmclnt_ops;
1654 int (*getroot) (struct nfs_server *, struct nfs_fh *,
1655 struct nfs_fsinfo *);
1656 int (*submount) (struct fs_context *, struct nfs_server *);
1657 int (*try_get_tree) (struct fs_context *);
1658 int (*getattr) (struct nfs_server *, struct nfs_fh *,
1659 struct nfs_fattr *, struct nfs4_label *,
1661 int (*setattr) (struct dentry *, struct nfs_fattr *,
1663 int (*lookup) (struct inode *, struct dentry *,
1664 struct nfs_fh *, struct nfs_fattr *,
1665 struct nfs4_label *);
1666 int (*lookupp) (struct inode *, struct nfs_fh *,
1667 struct nfs_fattr *, struct nfs4_label *);
1668 int (*access) (struct inode *, struct nfs_access_entry *);
1669 int (*readlink)(struct inode *, struct page *, unsigned int,
1671 int (*create) (struct inode *, struct dentry *,
1672 struct iattr *, int);
1673 int (*remove) (struct inode *, struct dentry *);
1674 void (*unlink_setup) (struct rpc_message *, struct dentry *, struct inode *);
1675 void (*unlink_rpc_prepare) (struct rpc_task *, struct nfs_unlinkdata *);
1676 int (*unlink_done) (struct rpc_task *, struct inode *);
1677 void (*rename_setup) (struct rpc_message *msg,
1678 struct dentry *old_dentry,
1679 struct dentry *new_dentry);
1680 void (*rename_rpc_prepare)(struct rpc_task *task, struct nfs_renamedata *);
1681 int (*rename_done) (struct rpc_task *task, struct inode *old_dir, struct inode *new_dir);
1682 int (*link) (struct inode *, struct inode *, const struct qstr *);
1683 int (*symlink) (struct inode *, struct dentry *, struct page *,
1684 unsigned int, struct iattr *);
1685 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
1686 int (*rmdir) (struct inode *, const struct qstr *);
1687 int (*readdir) (struct dentry *, const struct cred *,
1688 u64, struct page **, unsigned int, bool);
1689 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
1691 int (*statfs) (struct nfs_server *, struct nfs_fh *,
1692 struct nfs_fsstat *);
1693 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
1694 struct nfs_fsinfo *);
1695 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
1696 struct nfs_pathconf *);
1697 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
1698 int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, bool);
1699 int (*pgio_rpc_prepare)(struct rpc_task *,
1700 struct nfs_pgio_header *);
1701 void (*read_setup)(struct nfs_pgio_header *, struct rpc_message *);
1702 int (*read_done)(struct rpc_task *, struct nfs_pgio_header *);
1703 void (*write_setup)(struct nfs_pgio_header *, struct rpc_message *,
1704 struct rpc_clnt **);
1705 int (*write_done)(struct rpc_task *, struct nfs_pgio_header *);
1706 void (*commit_setup) (struct nfs_commit_data *, struct rpc_message *,
1707 struct rpc_clnt **);
1708 void (*commit_rpc_prepare)(struct rpc_task *, struct nfs_commit_data *);
1709 int (*commit_done) (struct rpc_task *, struct nfs_commit_data *);
1710 int (*lock)(struct file *, int, struct file_lock *);
1711 int (*lock_check_bounds)(const struct file_lock *);
1712 void (*clear_acl_cache)(struct inode *);
1713 void (*close_context)(struct nfs_open_context *ctx, int);
1714 struct inode * (*open_context) (struct inode *dir,
1715 struct nfs_open_context *ctx,
1717 struct iattr *iattr,
1719 int (*have_delegation)(struct inode *, fmode_t);
1720 struct nfs_client *(*alloc_client) (const struct nfs_client_initdata *);
1721 struct nfs_client *(*init_client) (struct nfs_client *,
1722 const struct nfs_client_initdata *);
1723 void (*free_client) (struct nfs_client *);
1724 struct nfs_server *(*create_server)(struct fs_context *);
1725 struct nfs_server *(*clone_server)(struct nfs_server *, struct nfs_fh *,
1726 struct nfs_fattr *, rpc_authflavor_t);
1730 * NFS_CALL(getattr, inode, (fattr));
1732 * NFS_PROTO(inode)->getattr(fattr);
1734 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
1737 * Function vectors etc. for the NFS client
1739 extern const struct nfs_rpc_ops nfs_v2_clientops;
1740 extern const struct nfs_rpc_ops nfs_v3_clientops;
1741 extern const struct nfs_rpc_ops nfs_v4_clientops;
1742 extern const struct rpc_version nfs_version2;
1743 extern const struct rpc_version nfs_version3;
1744 extern const struct rpc_version nfs_version4;
1746 extern const struct rpc_version nfsacl_version3;
1747 extern const struct rpc_program nfsacl_program;