xref: /openbmc/linux/fs/nfsd/xdr4.h (revision 70cc7f75)
19a74af21SBoaz Harrosh /*
29a74af21SBoaz Harrosh  *  Server-side types for NFSv4.
39a74af21SBoaz Harrosh  *
49a74af21SBoaz Harrosh  *  Copyright (c) 2002 The Regents of the University of Michigan.
59a74af21SBoaz Harrosh  *  All rights reserved.
69a74af21SBoaz Harrosh  *
79a74af21SBoaz Harrosh  *  Kendrick Smith <kmsmith@umich.edu>
89a74af21SBoaz Harrosh  *  Andy Adamson   <andros@umich.edu>
99a74af21SBoaz Harrosh  *
109a74af21SBoaz Harrosh  *  Redistribution and use in source and binary forms, with or without
119a74af21SBoaz Harrosh  *  modification, are permitted provided that the following conditions
129a74af21SBoaz Harrosh  *  are met:
139a74af21SBoaz Harrosh  *
149a74af21SBoaz Harrosh  *  1. Redistributions of source code must retain the above copyright
159a74af21SBoaz Harrosh  *     notice, this list of conditions and the following disclaimer.
169a74af21SBoaz Harrosh  *  2. Redistributions in binary form must reproduce the above copyright
179a74af21SBoaz Harrosh  *     notice, this list of conditions and the following disclaimer in the
189a74af21SBoaz Harrosh  *     documentation and/or other materials provided with the distribution.
199a74af21SBoaz Harrosh  *  3. Neither the name of the University nor the names of its
209a74af21SBoaz Harrosh  *     contributors may be used to endorse or promote products derived
219a74af21SBoaz Harrosh  *     from this software without specific prior written permission.
229a74af21SBoaz Harrosh  *
239a74af21SBoaz Harrosh  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
249a74af21SBoaz Harrosh  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
259a74af21SBoaz Harrosh  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
269a74af21SBoaz Harrosh  *  DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
279a74af21SBoaz Harrosh  *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
289a74af21SBoaz Harrosh  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
299a74af21SBoaz Harrosh  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
309a74af21SBoaz Harrosh  *  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
319a74af21SBoaz Harrosh  *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
329a74af21SBoaz Harrosh  *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
339a74af21SBoaz Harrosh  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
349a74af21SBoaz Harrosh  *
359a74af21SBoaz Harrosh  */
369a74af21SBoaz Harrosh 
379a74af21SBoaz Harrosh #ifndef _LINUX_NFSD_XDR4_H
389a74af21SBoaz Harrosh #define _LINUX_NFSD_XDR4_H
399a74af21SBoaz Harrosh 
409a74af21SBoaz Harrosh #include "state.h"
419a74af21SBoaz Harrosh #include "nfsd.h"
429a74af21SBoaz Harrosh 
439a74af21SBoaz Harrosh #define NFSD4_MAX_TAGLEN	128
449a74af21SBoaz Harrosh #define XDR_LEN(n)                     (((n) + 3) & ~3)
459a74af21SBoaz Harrosh 
4637c593c5STigran Mkrtchyan #define CURRENT_STATE_ID_FLAG (1<<0)
4737c593c5STigran Mkrtchyan #define SAVED_STATE_ID_FLAG (1<<1)
4837c593c5STigran Mkrtchyan 
4937c593c5STigran Mkrtchyan #define SET_STATE_ID(c, f) ((c)->sid_flags |= (f))
5037c593c5STigran Mkrtchyan #define HAS_STATE_ID(c, f) ((c)->sid_flags & (f))
5137c593c5STigran Mkrtchyan #define CLEAR_STATE_ID(c, f) ((c)->sid_flags &= ~(f))
5237c593c5STigran Mkrtchyan 
539a74af21SBoaz Harrosh struct nfsd4_compound_state {
549a74af21SBoaz Harrosh 	struct svc_fh		current_fh;
559a74af21SBoaz Harrosh 	struct svc_fh		save_fh;
569a74af21SBoaz Harrosh 	struct nfs4_stateowner	*replay_owner;
579a74af21SBoaz Harrosh 	/* For sessions DRC */
589a74af21SBoaz Harrosh 	struct nfsd4_session	*session;
599a74af21SBoaz Harrosh 	struct nfsd4_slot	*slot;
609a74af21SBoaz Harrosh 	__be32			*datap;
619a74af21SBoaz Harrosh 	size_t			iovlen;
629a74af21SBoaz Harrosh 	u32			minorversion;
6357b7b43bSJ. Bruce Fields 	__be32			status;
6437c593c5STigran Mkrtchyan 	stateid_t	current_stateid;
6537c593c5STigran Mkrtchyan 	stateid_t	save_stateid;
6637c593c5STigran Mkrtchyan 	/* to indicate current and saved state id presents */
6737c593c5STigran Mkrtchyan 	u32		sid_flags;
689a74af21SBoaz Harrosh };
699a74af21SBoaz Harrosh 
709a74af21SBoaz Harrosh static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs)
719a74af21SBoaz Harrosh {
729a74af21SBoaz Harrosh 	return cs->slot != NULL;
739a74af21SBoaz Harrosh }
749a74af21SBoaz Harrosh 
759a74af21SBoaz Harrosh struct nfsd4_change_info {
769a74af21SBoaz Harrosh 	u32		atomic;
779a74af21SBoaz Harrosh 	bool		change_supported;
789a74af21SBoaz Harrosh 	u32		before_ctime_sec;
799a74af21SBoaz Harrosh 	u32		before_ctime_nsec;
809a74af21SBoaz Harrosh 	u64		before_change;
819a74af21SBoaz Harrosh 	u32		after_ctime_sec;
829a74af21SBoaz Harrosh 	u32		after_ctime_nsec;
839a74af21SBoaz Harrosh 	u64		after_change;
849a74af21SBoaz Harrosh };
859a74af21SBoaz Harrosh 
869a74af21SBoaz Harrosh struct nfsd4_access {
879a74af21SBoaz Harrosh 	u32		ac_req_access;      /* request */
889a74af21SBoaz Harrosh 	u32		ac_supported;       /* response */
899a74af21SBoaz Harrosh 	u32		ac_resp_access;     /* response */
909a74af21SBoaz Harrosh };
919a74af21SBoaz Harrosh 
929a74af21SBoaz Harrosh struct nfsd4_close {
939a74af21SBoaz Harrosh 	u32		cl_seqid;           /* request */
949a74af21SBoaz Harrosh 	stateid_t	cl_stateid;         /* request+response */
959a74af21SBoaz Harrosh };
969a74af21SBoaz Harrosh 
979a74af21SBoaz Harrosh struct nfsd4_commit {
989a74af21SBoaz Harrosh 	u64		co_offset;          /* request */
999a74af21SBoaz Harrosh 	u32		co_count;           /* request */
1009a74af21SBoaz Harrosh 	nfs4_verifier	co_verf;            /* response */
1019a74af21SBoaz Harrosh };
1029a74af21SBoaz Harrosh 
1039a74af21SBoaz Harrosh struct nfsd4_create {
1049a74af21SBoaz Harrosh 	u32		cr_namelen;         /* request */
1059a74af21SBoaz Harrosh 	char *		cr_name;            /* request */
1069a74af21SBoaz Harrosh 	u32		cr_type;            /* request */
1079a74af21SBoaz Harrosh 	union {                             /* request */
1089a74af21SBoaz Harrosh 		struct {
1099a74af21SBoaz Harrosh 			u32 namelen;
1109a74af21SBoaz Harrosh 			char *name;
1119a74af21SBoaz Harrosh 		} link;   /* NF4LNK */
1129a74af21SBoaz Harrosh 		struct {
1139a74af21SBoaz Harrosh 			u32 specdata1;
1149a74af21SBoaz Harrosh 			u32 specdata2;
1159a74af21SBoaz Harrosh 		} dev;    /* NF4BLK, NF4CHR */
1169a74af21SBoaz Harrosh 	} u;
1179a74af21SBoaz Harrosh 	u32		cr_bmval[3];        /* request */
1189a74af21SBoaz Harrosh 	struct iattr	cr_iattr;           /* request */
1199a74af21SBoaz Harrosh 	struct nfsd4_change_info  cr_cinfo; /* response */
1209a74af21SBoaz Harrosh 	struct nfs4_acl *cr_acl;
1219a74af21SBoaz Harrosh };
1229a74af21SBoaz Harrosh #define cr_linklen	u.link.namelen
1239a74af21SBoaz Harrosh #define cr_linkname	u.link.name
1249a74af21SBoaz Harrosh #define cr_specdata1	u.dev.specdata1
1259a74af21SBoaz Harrosh #define cr_specdata2	u.dev.specdata2
1269a74af21SBoaz Harrosh 
1279a74af21SBoaz Harrosh struct nfsd4_delegreturn {
1289a74af21SBoaz Harrosh 	stateid_t	dr_stateid;
1299a74af21SBoaz Harrosh };
1309a74af21SBoaz Harrosh 
1319a74af21SBoaz Harrosh struct nfsd4_getattr {
1329a74af21SBoaz Harrosh 	u32		ga_bmval[3];        /* request */
1339a74af21SBoaz Harrosh 	struct svc_fh	*ga_fhp;            /* response */
1349a74af21SBoaz Harrosh };
1359a74af21SBoaz Harrosh 
1369a74af21SBoaz Harrosh struct nfsd4_link {
1379a74af21SBoaz Harrosh 	u32		li_namelen;         /* request */
1389a74af21SBoaz Harrosh 	char *		li_name;            /* request */
1399a74af21SBoaz Harrosh 	struct nfsd4_change_info  li_cinfo; /* response */
1409a74af21SBoaz Harrosh };
1419a74af21SBoaz Harrosh 
1429a74af21SBoaz Harrosh struct nfsd4_lock_denied {
1439a74af21SBoaz Harrosh 	clientid_t	ld_clientid;
1447c13f344SJ. Bruce Fields 	struct xdr_netobj	ld_owner;
1459a74af21SBoaz Harrosh 	u64             ld_start;
1469a74af21SBoaz Harrosh 	u64             ld_length;
1479a74af21SBoaz Harrosh 	u32             ld_type;
1489a74af21SBoaz Harrosh };
1499a74af21SBoaz Harrosh 
1509a74af21SBoaz Harrosh struct nfsd4_lock {
1519a74af21SBoaz Harrosh 	/* request */
1529a74af21SBoaz Harrosh 	u32             lk_type;
1539a74af21SBoaz Harrosh 	u32             lk_reclaim;         /* boolean */
1549a74af21SBoaz Harrosh 	u64             lk_offset;
1559a74af21SBoaz Harrosh 	u64             lk_length;
1569a74af21SBoaz Harrosh 	u32             lk_is_new;
1579a74af21SBoaz Harrosh 	union {
1589a74af21SBoaz Harrosh 		struct {
1599a74af21SBoaz Harrosh 			u32             open_seqid;
1609a74af21SBoaz Harrosh 			stateid_t       open_stateid;
1619a74af21SBoaz Harrosh 			u32             lock_seqid;
1629a74af21SBoaz Harrosh 			clientid_t      clientid;
1639a74af21SBoaz Harrosh 			struct xdr_netobj owner;
1649a74af21SBoaz Harrosh 		} new;
1659a74af21SBoaz Harrosh 		struct {
1669a74af21SBoaz Harrosh 			stateid_t       lock_stateid;
1679a74af21SBoaz Harrosh 			u32             lock_seqid;
1689a74af21SBoaz Harrosh 		} old;
1699a74af21SBoaz Harrosh 	} v;
1709a74af21SBoaz Harrosh 
1719a74af21SBoaz Harrosh 	/* response */
1729a74af21SBoaz Harrosh 	union {
1739a74af21SBoaz Harrosh 		struct {
1749a74af21SBoaz Harrosh 			stateid_t               stateid;
1759a74af21SBoaz Harrosh 		} ok;
1769a74af21SBoaz Harrosh 		struct nfsd4_lock_denied        denied;
1779a74af21SBoaz Harrosh 	} u;
1789a74af21SBoaz Harrosh };
1799a74af21SBoaz Harrosh #define lk_new_open_seqid       v.new.open_seqid
1809a74af21SBoaz Harrosh #define lk_new_open_stateid     v.new.open_stateid
1819a74af21SBoaz Harrosh #define lk_new_lock_seqid       v.new.lock_seqid
1829a74af21SBoaz Harrosh #define lk_new_clientid         v.new.clientid
1839a74af21SBoaz Harrosh #define lk_new_owner            v.new.owner
1849a74af21SBoaz Harrosh #define lk_old_lock_stateid     v.old.lock_stateid
1859a74af21SBoaz Harrosh #define lk_old_lock_seqid       v.old.lock_seqid
1869a74af21SBoaz Harrosh 
1879a74af21SBoaz Harrosh #define lk_rflags       u.ok.rflags
1889a74af21SBoaz Harrosh #define lk_resp_stateid u.ok.stateid
1899a74af21SBoaz Harrosh #define lk_denied       u.denied
1909a74af21SBoaz Harrosh 
1919a74af21SBoaz Harrosh 
1929a74af21SBoaz Harrosh struct nfsd4_lockt {
1939a74af21SBoaz Harrosh 	u32				lt_type;
1949a74af21SBoaz Harrosh 	clientid_t			lt_clientid;
1959a74af21SBoaz Harrosh 	struct xdr_netobj		lt_owner;
1969a74af21SBoaz Harrosh 	u64				lt_offset;
1979a74af21SBoaz Harrosh 	u64				lt_length;
1989a74af21SBoaz Harrosh 	struct nfsd4_lock_denied  	lt_denied;
1999a74af21SBoaz Harrosh };
2009a74af21SBoaz Harrosh 
2019a74af21SBoaz Harrosh 
2029a74af21SBoaz Harrosh struct nfsd4_locku {
2039a74af21SBoaz Harrosh 	u32             lu_type;
2049a74af21SBoaz Harrosh 	u32             lu_seqid;
2059a74af21SBoaz Harrosh 	stateid_t       lu_stateid;
2069a74af21SBoaz Harrosh 	u64             lu_offset;
2079a74af21SBoaz Harrosh 	u64             lu_length;
2089a74af21SBoaz Harrosh };
2099a74af21SBoaz Harrosh 
2109a74af21SBoaz Harrosh 
2119a74af21SBoaz Harrosh struct nfsd4_lookup {
2129a74af21SBoaz Harrosh 	u32		lo_len;             /* request */
2139a74af21SBoaz Harrosh 	char *		lo_name;            /* request */
2149a74af21SBoaz Harrosh };
2159a74af21SBoaz Harrosh 
2169a74af21SBoaz Harrosh struct nfsd4_putfh {
2179a74af21SBoaz Harrosh 	u32		pf_fhlen;           /* request */
2189a74af21SBoaz Harrosh 	char		*pf_fhval;          /* request */
2199a74af21SBoaz Harrosh };
2209a74af21SBoaz Harrosh 
2219a74af21SBoaz Harrosh struct nfsd4_open {
2229a74af21SBoaz Harrosh 	u32		op_claim_type;      /* request */
2239a74af21SBoaz Harrosh 	struct xdr_netobj op_fname;	    /* request - everything but CLAIM_PREV */
2249a74af21SBoaz Harrosh 	u32		op_delegate_type;   /* request - CLAIM_PREV only */
2259a74af21SBoaz Harrosh 	stateid_t       op_delegate_stateid; /* request - response */
226d24433cdSBenny Halevy 	u32		op_why_no_deleg;    /* response - DELEG_NONE_EXT only */
2279a74af21SBoaz Harrosh 	u32		op_create;     	    /* request */
2289a74af21SBoaz Harrosh 	u32		op_createmode;      /* request */
2299a74af21SBoaz Harrosh 	u32		op_bmval[3];        /* request */
2309a74af21SBoaz Harrosh 	struct iattr	iattr;              /* UNCHECKED4, GUARDED4, EXCLUSIVE4_1 */
231ab4684d1SChuck Lever 	nfs4_verifier	op_verf __attribute__((aligned(32)));
232ab4684d1SChuck Lever 					    /* EXCLUSIVE4 */
2339a74af21SBoaz Harrosh 	clientid_t	op_clientid;        /* request */
2349a74af21SBoaz Harrosh 	struct xdr_netobj op_owner;           /* request */
2359a74af21SBoaz Harrosh 	u32		op_seqid;           /* request */
2369a74af21SBoaz Harrosh 	u32		op_share_access;    /* request */
2379a74af21SBoaz Harrosh 	u32		op_share_deny;      /* request */
2382c8bd7e0SBenny Halevy 	u32		op_deleg_want;      /* request */
2399a74af21SBoaz Harrosh 	stateid_t	op_stateid;         /* response */
2409a74af21SBoaz Harrosh 	u32		op_recall;          /* recall */
2419a74af21SBoaz Harrosh 	struct nfsd4_change_info  op_cinfo; /* response */
2429a74af21SBoaz Harrosh 	u32		op_rflags;          /* response */
243856121b2SJ. Bruce Fields 	bool		op_truncate;        /* used during processing */
244856121b2SJ. Bruce Fields 	bool		op_created;         /* used during processing */
245fe0750e5SJ. Bruce Fields 	struct nfs4_openowner *op_openowner; /* used during processing */
24632513b40SJ. Bruce Fields 	struct nfs4_file *op_file;          /* used during processing */
2474cdc951bSJ. Bruce Fields 	struct nfs4_ol_stateid *op_stp;	    /* used during processing */
2489a74af21SBoaz Harrosh 	struct nfs4_acl *op_acl;
2499a74af21SBoaz Harrosh };
2509a74af21SBoaz Harrosh #define op_iattr	iattr
2519a74af21SBoaz Harrosh 
2529a74af21SBoaz Harrosh struct nfsd4_open_confirm {
2539a74af21SBoaz Harrosh 	stateid_t	oc_req_stateid		/* request */;
2549a74af21SBoaz Harrosh 	u32		oc_seqid    		/* request */;
2559a74af21SBoaz Harrosh 	stateid_t	oc_resp_stateid		/* response */;
2569a74af21SBoaz Harrosh };
2579a74af21SBoaz Harrosh 
2589a74af21SBoaz Harrosh struct nfsd4_open_downgrade {
2599a74af21SBoaz Harrosh 	stateid_t       od_stateid;
2609a74af21SBoaz Harrosh 	u32             od_seqid;
2612c8bd7e0SBenny Halevy 	u32             od_share_access;	/* request */
2622c8bd7e0SBenny Halevy 	u32		od_deleg_want;		/* request */
2632c8bd7e0SBenny Halevy 	u32             od_share_deny;		/* request */
2649a74af21SBoaz Harrosh };
2659a74af21SBoaz Harrosh 
2669a74af21SBoaz Harrosh 
2679a74af21SBoaz Harrosh struct nfsd4_read {
2689a74af21SBoaz Harrosh 	stateid_t	rd_stateid;         /* request */
2699a74af21SBoaz Harrosh 	u64		rd_offset;          /* request */
2709a74af21SBoaz Harrosh 	u32		rd_length;          /* request */
2719a74af21SBoaz Harrosh 	int		rd_vlen;
2729a74af21SBoaz Harrosh 	struct file     *rd_filp;
2739a74af21SBoaz Harrosh 
2749a74af21SBoaz Harrosh 	struct svc_rqst *rd_rqstp;          /* response */
2759a74af21SBoaz Harrosh 	struct svc_fh * rd_fhp;             /* response */
2769a74af21SBoaz Harrosh };
2779a74af21SBoaz Harrosh 
2789a74af21SBoaz Harrosh struct nfsd4_readdir {
2799a74af21SBoaz Harrosh 	u64		rd_cookie;          /* request */
2809a74af21SBoaz Harrosh 	nfs4_verifier	rd_verf;            /* request */
2819a74af21SBoaz Harrosh 	u32		rd_dircount;        /* request */
2829a74af21SBoaz Harrosh 	u32		rd_maxcount;        /* request */
2839a74af21SBoaz Harrosh 	u32		rd_bmval[3];        /* request */
2849a74af21SBoaz Harrosh 	struct svc_rqst *rd_rqstp;          /* response */
2859a74af21SBoaz Harrosh 	struct svc_fh * rd_fhp;             /* response */
2869a74af21SBoaz Harrosh 
2879a74af21SBoaz Harrosh 	struct readdir_cd	common;
2889a74af21SBoaz Harrosh 	__be32 *		buffer;
2899a74af21SBoaz Harrosh 	int			buflen;
2909a74af21SBoaz Harrosh 	__be32 *		offset;
2919a74af21SBoaz Harrosh };
2929a74af21SBoaz Harrosh 
2939a74af21SBoaz Harrosh struct nfsd4_release_lockowner {
2949a74af21SBoaz Harrosh 	clientid_t        rl_clientid;
2959a74af21SBoaz Harrosh 	struct xdr_netobj rl_owner;
2969a74af21SBoaz Harrosh };
2979a74af21SBoaz Harrosh struct nfsd4_readlink {
2989a74af21SBoaz Harrosh 	struct svc_rqst *rl_rqstp;          /* request */
2999a74af21SBoaz Harrosh 	struct svc_fh *	rl_fhp;             /* request */
3009a74af21SBoaz Harrosh };
3019a74af21SBoaz Harrosh 
3029a74af21SBoaz Harrosh struct nfsd4_remove {
3039a74af21SBoaz Harrosh 	u32		rm_namelen;         /* request */
3049a74af21SBoaz Harrosh 	char *		rm_name;            /* request */
3059a74af21SBoaz Harrosh 	struct nfsd4_change_info  rm_cinfo; /* response */
3069a74af21SBoaz Harrosh };
3079a74af21SBoaz Harrosh 
3089a74af21SBoaz Harrosh struct nfsd4_rename {
3099a74af21SBoaz Harrosh 	u32		rn_snamelen;        /* request */
3109a74af21SBoaz Harrosh 	char *		rn_sname;           /* request */
3119a74af21SBoaz Harrosh 	u32		rn_tnamelen;        /* request */
3129a74af21SBoaz Harrosh 	char *		rn_tname;           /* request */
3139a74af21SBoaz Harrosh 	struct nfsd4_change_info  rn_sinfo; /* response */
3149a74af21SBoaz Harrosh 	struct nfsd4_change_info  rn_tinfo; /* response */
3159a74af21SBoaz Harrosh };
3169a74af21SBoaz Harrosh 
3179a74af21SBoaz Harrosh struct nfsd4_secinfo {
3189a74af21SBoaz Harrosh 	u32 si_namelen;					/* request */
3199a74af21SBoaz Harrosh 	char *si_name;					/* request */
3209a74af21SBoaz Harrosh 	struct svc_export *si_exp;			/* response */
3219a74af21SBoaz Harrosh };
3229a74af21SBoaz Harrosh 
32304f4ad16SJ. Bruce Fields struct nfsd4_secinfo_no_name {
32404f4ad16SJ. Bruce Fields 	u32 sin_style;					/* request */
32504f4ad16SJ. Bruce Fields 	struct svc_export *sin_exp;			/* response */
32604f4ad16SJ. Bruce Fields };
32704f4ad16SJ. Bruce Fields 
3289a74af21SBoaz Harrosh struct nfsd4_setattr {
3299a74af21SBoaz Harrosh 	stateid_t	sa_stateid;         /* request */
3309a74af21SBoaz Harrosh 	u32		sa_bmval[3];        /* request */
3319a74af21SBoaz Harrosh 	struct iattr	sa_iattr;           /* request */
3329a74af21SBoaz Harrosh 	struct nfs4_acl *sa_acl;
3339a74af21SBoaz Harrosh };
3349a74af21SBoaz Harrosh 
3359a74af21SBoaz Harrosh struct nfsd4_setclientid {
3369a74af21SBoaz Harrosh 	nfs4_verifier	se_verf;            /* request */
337a084daf5SJ. Bruce Fields 	struct xdr_netobj se_name;
3389a74af21SBoaz Harrosh 	u32		se_callback_prog;   /* request */
3399a74af21SBoaz Harrosh 	u32		se_callback_netid_len;  /* request */
3409a74af21SBoaz Harrosh 	char *		se_callback_netid_val;  /* request */
3419a74af21SBoaz Harrosh 	u32		se_callback_addr_len;   /* request */
3429a74af21SBoaz Harrosh 	char *		se_callback_addr_val;   /* request */
3439a74af21SBoaz Harrosh 	u32		se_callback_ident;  /* request */
3449a74af21SBoaz Harrosh 	clientid_t	se_clientid;        /* response */
3459a74af21SBoaz Harrosh 	nfs4_verifier	se_confirm;         /* response */
3469a74af21SBoaz Harrosh };
3479a74af21SBoaz Harrosh 
3489a74af21SBoaz Harrosh struct nfsd4_setclientid_confirm {
3499a74af21SBoaz Harrosh 	clientid_t	sc_clientid;
3509a74af21SBoaz Harrosh 	nfs4_verifier	sc_confirm;
3519a74af21SBoaz Harrosh };
3529a74af21SBoaz Harrosh 
35317456804SBryan Schumaker struct nfsd4_saved_compoundargs {
35417456804SBryan Schumaker 	__be32 *p;
35517456804SBryan Schumaker 	__be32 *end;
35617456804SBryan Schumaker 	int pagelen;
35717456804SBryan Schumaker 	struct page **pagelist;
35817456804SBryan Schumaker };
35917456804SBryan Schumaker 
36003cfb420SBryan Schumaker struct nfsd4_test_stateid_id {
36103cfb420SBryan Schumaker 	__be32			ts_id_status;
36203cfb420SBryan Schumaker 	stateid_t		ts_id_stateid;
36303cfb420SBryan Schumaker 	struct list_head	ts_id_list;
36403cfb420SBryan Schumaker };
36503cfb420SBryan Schumaker 
36617456804SBryan Schumaker struct nfsd4_test_stateid {
36757b7b43bSJ. Bruce Fields 	u32		ts_num_ids;
36803cfb420SBryan Schumaker 	struct list_head ts_stateid_list;
36917456804SBryan Schumaker };
37017456804SBryan Schumaker 
371e1ca12dfSBryan Schumaker struct nfsd4_free_stateid {
372e1ca12dfSBryan Schumaker 	stateid_t	fr_stateid;         /* request */
373e1ca12dfSBryan Schumaker 	__be32		fr_status;          /* response */
374e1ca12dfSBryan Schumaker };
375e1ca12dfSBryan Schumaker 
3769a74af21SBoaz Harrosh /* also used for NVERIFY */
3779a74af21SBoaz Harrosh struct nfsd4_verify {
3789a74af21SBoaz Harrosh 	u32		ve_bmval[3];        /* request */
3799a74af21SBoaz Harrosh 	u32		ve_attrlen;         /* request */
3809a74af21SBoaz Harrosh 	char *		ve_attrval;         /* request */
3819a74af21SBoaz Harrosh };
3829a74af21SBoaz Harrosh 
3839a74af21SBoaz Harrosh struct nfsd4_write {
3849a74af21SBoaz Harrosh 	stateid_t	wr_stateid;         /* request */
3859a74af21SBoaz Harrosh 	u64		wr_offset;          /* request */
3869a74af21SBoaz Harrosh 	u32		wr_stable_how;      /* request */
3879a74af21SBoaz Harrosh 	u32		wr_buflen;          /* request */
3889a74af21SBoaz Harrosh 	int		wr_vlen;
38970cc7f75SJ. Bruce Fields 	struct kvec	wr_head;
39070cc7f75SJ. Bruce Fields 	struct page **	wr_pagelist;        /* request */
3919a74af21SBoaz Harrosh 
3929a74af21SBoaz Harrosh 	u32		wr_bytes_written;   /* response */
3939a74af21SBoaz Harrosh 	u32		wr_how_written;     /* response */
3949a74af21SBoaz Harrosh 	nfs4_verifier	wr_verifier;        /* response */
3959a74af21SBoaz Harrosh };
3969a74af21SBoaz Harrosh 
3979a74af21SBoaz Harrosh struct nfsd4_exchange_id {
3989a74af21SBoaz Harrosh 	nfs4_verifier	verifier;
3999a74af21SBoaz Harrosh 	struct xdr_netobj clname;
4009a74af21SBoaz Harrosh 	u32		flags;
4019a74af21SBoaz Harrosh 	clientid_t	clientid;
4029a74af21SBoaz Harrosh 	u32		seqid;
4039a74af21SBoaz Harrosh 	int		spa_how;
4049a74af21SBoaz Harrosh };
4059a74af21SBoaz Harrosh 
4069a74af21SBoaz Harrosh struct nfsd4_sequence {
4079a74af21SBoaz Harrosh 	struct nfs4_sessionid	sessionid;		/* request/response */
4089a74af21SBoaz Harrosh 	u32			seqid;			/* request/response */
4099a74af21SBoaz Harrosh 	u32			slotid;			/* request/response */
4109a74af21SBoaz Harrosh 	u32			maxslots;		/* request/response */
4119a74af21SBoaz Harrosh 	u32			cachethis;		/* request */
4129a74af21SBoaz Harrosh #if 0
4139a74af21SBoaz Harrosh 	u32			target_maxslots;	/* response */
4149a74af21SBoaz Harrosh #endif /* not yet */
4150d7bb719SJ. Bruce Fields 	u32			status_flags;		/* response */
4169a74af21SBoaz Harrosh };
4179a74af21SBoaz Harrosh 
4189a74af21SBoaz Harrosh struct nfsd4_destroy_session {
4199a74af21SBoaz Harrosh 	struct nfs4_sessionid	sessionid;
4209a74af21SBoaz Harrosh };
4219a74af21SBoaz Harrosh 
422345c2842SMi Jinlong struct nfsd4_destroy_clientid {
423345c2842SMi Jinlong 	clientid_t clientid;
424345c2842SMi Jinlong };
425345c2842SMi Jinlong 
4264dc6ec00SJ. Bruce Fields struct nfsd4_reclaim_complete {
4274dc6ec00SJ. Bruce Fields 	u32 rca_one_fs;
4284dc6ec00SJ. Bruce Fields };
4294dc6ec00SJ. Bruce Fields 
4309a74af21SBoaz Harrosh struct nfsd4_op {
4319a74af21SBoaz Harrosh 	int					opnum;
4329a74af21SBoaz Harrosh 	__be32					status;
4339a74af21SBoaz Harrosh 	union {
4349a74af21SBoaz Harrosh 		struct nfsd4_access		access;
4359a74af21SBoaz Harrosh 		struct nfsd4_close		close;
4369a74af21SBoaz Harrosh 		struct nfsd4_commit		commit;
4379a74af21SBoaz Harrosh 		struct nfsd4_create		create;
4389a74af21SBoaz Harrosh 		struct nfsd4_delegreturn	delegreturn;
4399a74af21SBoaz Harrosh 		struct nfsd4_getattr		getattr;
4409a74af21SBoaz Harrosh 		struct svc_fh *			getfh;
4419a74af21SBoaz Harrosh 		struct nfsd4_link		link;
4429a74af21SBoaz Harrosh 		struct nfsd4_lock		lock;
4439a74af21SBoaz Harrosh 		struct nfsd4_lockt		lockt;
4449a74af21SBoaz Harrosh 		struct nfsd4_locku		locku;
4459a74af21SBoaz Harrosh 		struct nfsd4_lookup		lookup;
4469a74af21SBoaz Harrosh 		struct nfsd4_verify		nverify;
4479a74af21SBoaz Harrosh 		struct nfsd4_open		open;
4489a74af21SBoaz Harrosh 		struct nfsd4_open_confirm	open_confirm;
4499a74af21SBoaz Harrosh 		struct nfsd4_open_downgrade	open_downgrade;
4509a74af21SBoaz Harrosh 		struct nfsd4_putfh		putfh;
4519a74af21SBoaz Harrosh 		struct nfsd4_read		read;
4529a74af21SBoaz Harrosh 		struct nfsd4_readdir		readdir;
4539a74af21SBoaz Harrosh 		struct nfsd4_readlink		readlink;
4549a74af21SBoaz Harrosh 		struct nfsd4_remove		remove;
4559a74af21SBoaz Harrosh 		struct nfsd4_rename		rename;
4569a74af21SBoaz Harrosh 		clientid_t			renew;
4579a74af21SBoaz Harrosh 		struct nfsd4_secinfo		secinfo;
4589a74af21SBoaz Harrosh 		struct nfsd4_setattr		setattr;
4599a74af21SBoaz Harrosh 		struct nfsd4_setclientid	setclientid;
4609a74af21SBoaz Harrosh 		struct nfsd4_setclientid_confirm setclientid_confirm;
4619a74af21SBoaz Harrosh 		struct nfsd4_verify		verify;
4629a74af21SBoaz Harrosh 		struct nfsd4_write		write;
4639a74af21SBoaz Harrosh 		struct nfsd4_release_lockowner	release_lockowner;
4649a74af21SBoaz Harrosh 
4659a74af21SBoaz Harrosh 		/* NFSv4.1 */
4669a74af21SBoaz Harrosh 		struct nfsd4_exchange_id	exchange_id;
467cb73a9f4SJ. Bruce Fields 		struct nfsd4_backchannel_ctl	backchannel_ctl;
4681d1bc8f2SJ. Bruce Fields 		struct nfsd4_bind_conn_to_session bind_conn_to_session;
4699a74af21SBoaz Harrosh 		struct nfsd4_create_session	create_session;
4709a74af21SBoaz Harrosh 		struct nfsd4_destroy_session	destroy_session;
4719a74af21SBoaz Harrosh 		struct nfsd4_sequence		sequence;
4724dc6ec00SJ. Bruce Fields 		struct nfsd4_reclaim_complete	reclaim_complete;
47317456804SBryan Schumaker 		struct nfsd4_test_stateid	test_stateid;
474e1ca12dfSBryan Schumaker 		struct nfsd4_free_stateid	free_stateid;
4759a74af21SBoaz Harrosh 	} u;
4769a74af21SBoaz Harrosh 	struct nfs4_replay *			replay;
4779a74af21SBoaz Harrosh };
4789a74af21SBoaz Harrosh 
4791091006cSJ. Bruce Fields bool nfsd4_cache_this_op(struct nfsd4_op *);
4801091006cSJ. Bruce Fields 
4819a74af21SBoaz Harrosh struct nfsd4_compoundargs {
4829a74af21SBoaz Harrosh 	/* scratch variables for XDR decode */
4839a74af21SBoaz Harrosh 	__be32 *			p;
4849a74af21SBoaz Harrosh 	__be32 *			end;
4859a74af21SBoaz Harrosh 	struct page **			pagelist;
4869a74af21SBoaz Harrosh 	int				pagelen;
4879a74af21SBoaz Harrosh 	__be32				tmp[8];
4889a74af21SBoaz Harrosh 	__be32 *			tmpp;
4899a74af21SBoaz Harrosh 	struct tmpbuf {
4909a74af21SBoaz Harrosh 		struct tmpbuf *next;
4919a74af21SBoaz Harrosh 		void (*release)(const void *);
4929a74af21SBoaz Harrosh 		void *buf;
4939a74af21SBoaz Harrosh 	}				*to_free;
4949a74af21SBoaz Harrosh 
4959a74af21SBoaz Harrosh 	struct svc_rqst			*rqstp;
4969a74af21SBoaz Harrosh 
4979a74af21SBoaz Harrosh 	u32				taglen;
4989a74af21SBoaz Harrosh 	char *				tag;
4999a74af21SBoaz Harrosh 	u32				minorversion;
5009a74af21SBoaz Harrosh 	u32				opcnt;
5019a74af21SBoaz Harrosh 	struct nfsd4_op			*ops;
5029a74af21SBoaz Harrosh 	struct nfsd4_op			iops[8];
5031091006cSJ. Bruce Fields 	int				cachetype;
5049a74af21SBoaz Harrosh };
5059a74af21SBoaz Harrosh 
5069a74af21SBoaz Harrosh struct nfsd4_compoundres {
5079a74af21SBoaz Harrosh 	/* scratch variables for XDR encode */
5089a74af21SBoaz Harrosh 	__be32 *			p;
5099a74af21SBoaz Harrosh 	__be32 *			end;
5109a74af21SBoaz Harrosh 	struct xdr_buf *		xbuf;
5119a74af21SBoaz Harrosh 	struct svc_rqst *		rqstp;
5129a74af21SBoaz Harrosh 
5139a74af21SBoaz Harrosh 	u32				taglen;
5149a74af21SBoaz Harrosh 	char *				tag;
5159a74af21SBoaz Harrosh 	u32				opcnt;
5169a74af21SBoaz Harrosh 	__be32 *			tagp; /* tag, opcount encode location */
5179a74af21SBoaz Harrosh 	struct nfsd4_compound_state	cstate;
5189a74af21SBoaz Harrosh };
5199a74af21SBoaz Harrosh 
5209a74af21SBoaz Harrosh static inline bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp)
5219a74af21SBoaz Harrosh {
5229a74af21SBoaz Harrosh 	struct nfsd4_compoundargs *args = resp->rqstp->rq_argp;
5239a74af21SBoaz Harrosh 	return resp->opcnt == 1 && args->ops[0].opnum == OP_SEQUENCE;
5249a74af21SBoaz Harrosh }
5259a74af21SBoaz Harrosh 
5269a74af21SBoaz Harrosh static inline bool nfsd4_not_cached(struct nfsd4_compoundres *resp)
5279a74af21SBoaz Harrosh {
52873e79482SJ. Bruce Fields 	return !(resp->cstate.slot->sl_flags & NFSD4_SLOT_CACHETHIS)
52973e79482SJ. Bruce Fields 		|| nfsd4_is_solo_sequence(resp);
5309a74af21SBoaz Harrosh }
5319a74af21SBoaz Harrosh 
5329a74af21SBoaz Harrosh #define NFS4_SVC_XDRSIZE		sizeof(struct nfsd4_compoundargs)
5339a74af21SBoaz Harrosh 
5349a74af21SBoaz Harrosh static inline void
5359a74af21SBoaz Harrosh set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
5369a74af21SBoaz Harrosh {
537c1ac3ffcSNeil Brown 	BUG_ON(!fhp->fh_pre_saved);
538c1ac3ffcSNeil Brown 	cinfo->atomic = fhp->fh_post_saved;
5399a74af21SBoaz Harrosh 	cinfo->change_supported = IS_I_VERSION(fhp->fh_dentry->d_inode);
540c1ac3ffcSNeil Brown 
5419a74af21SBoaz Harrosh 	cinfo->before_change = fhp->fh_pre_change;
5429a74af21SBoaz Harrosh 	cinfo->after_change = fhp->fh_post_change;
5439a74af21SBoaz Harrosh 	cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
5449a74af21SBoaz Harrosh 	cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
5459a74af21SBoaz Harrosh 	cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
5469a74af21SBoaz Harrosh 	cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
547c1ac3ffcSNeil Brown 
5489a74af21SBoaz Harrosh }
5499a74af21SBoaz Harrosh 
5509a74af21SBoaz Harrosh int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
5519a74af21SBoaz Harrosh int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *,
5529a74af21SBoaz Harrosh 		struct nfsd4_compoundargs *);
5539a74af21SBoaz Harrosh int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *,
5549a74af21SBoaz Harrosh 		struct nfsd4_compoundres *);
55557b7b43bSJ. Bruce Fields __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *, u32);
5569a74af21SBoaz Harrosh void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
5579a74af21SBoaz Harrosh void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
5589a74af21SBoaz Harrosh __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
5599a74af21SBoaz Harrosh 		       struct dentry *dentry, __be32 *buffer, int *countp,
5609a74af21SBoaz Harrosh 		       u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
5619a74af21SBoaz Harrosh extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
5629a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5639a74af21SBoaz Harrosh 		struct nfsd4_setclientid *setclid);
5649a74af21SBoaz Harrosh extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
5659a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5669a74af21SBoaz Harrosh 		struct nfsd4_setclientid_confirm *setclientid_confirm);
5679a74af21SBoaz Harrosh extern void nfsd4_store_cache_entry(struct nfsd4_compoundres *resp);
5689a74af21SBoaz Harrosh extern __be32 nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp,
5699a74af21SBoaz Harrosh 		struct nfsd4_sequence *seq);
5709a74af21SBoaz Harrosh extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
5713c4ab2aaSJ. Bruce Fields 		struct nfsd4_compound_state *, struct nfsd4_exchange_id *);
572cb73a9f4SJ. Bruce Fields extern __be32 nfsd4_backchannel_ctl(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_backchannel_ctl *);
5731d1bc8f2SJ. Bruce Fields extern __be32 nfsd4_bind_conn_to_session(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_bind_conn_to_session *);
5749a74af21SBoaz Harrosh extern __be32 nfsd4_create_session(struct svc_rqst *,
5759a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5769a74af21SBoaz Harrosh 		struct nfsd4_create_session *);
5779a74af21SBoaz Harrosh extern __be32 nfsd4_sequence(struct svc_rqst *,
5789a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5799a74af21SBoaz Harrosh 		struct nfsd4_sequence *);
5809a74af21SBoaz Harrosh extern __be32 nfsd4_destroy_session(struct svc_rqst *,
5819a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5829a74af21SBoaz Harrosh 		struct nfsd4_destroy_session *);
583345c2842SMi Jinlong extern __be32 nfsd4_destroy_clientid(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_destroy_clientid *);
5844dc6ec00SJ. Bruce Fields __be32 nfsd4_reclaim_complete(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_reclaim_complete *);
5859a74af21SBoaz Harrosh extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *,
5863320fef1SStanislav Kinsbursky 		struct nfsd4_open *open, struct nfsd_net *nn);
5879a74af21SBoaz Harrosh extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
5889a74af21SBoaz Harrosh 		struct svc_fh *current_fh, struct nfsd4_open *open);
589d29b20cdSJ. Bruce Fields extern void nfsd4_cleanup_open_state(struct nfsd4_open *open, __be32 status);
5909a74af21SBoaz Harrosh extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
5919a74af21SBoaz Harrosh 		struct nfsd4_compound_state *, struct nfsd4_open_confirm *oc);
5929a74af21SBoaz Harrosh extern __be32 nfsd4_close(struct svc_rqst *rqstp,
5939a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5949a74af21SBoaz Harrosh 		struct nfsd4_close *close);
5959a74af21SBoaz Harrosh extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
5969a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5979a74af21SBoaz Harrosh 		struct nfsd4_open_downgrade *od);
5989a74af21SBoaz Harrosh extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
5999a74af21SBoaz Harrosh 		struct nfsd4_lock *lock);
6009a74af21SBoaz Harrosh extern __be32 nfsd4_lockt(struct svc_rqst *rqstp,
6019a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
6029a74af21SBoaz Harrosh 		struct nfsd4_lockt *lockt);
6039a74af21SBoaz Harrosh extern __be32 nfsd4_locku(struct svc_rqst *rqstp,
6049a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
6059a74af21SBoaz Harrosh 		struct nfsd4_locku *locku);
6069a74af21SBoaz Harrosh extern __be32
6079a74af21SBoaz Harrosh nfsd4_release_lockowner(struct svc_rqst *rqstp,
6089a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
6099a74af21SBoaz Harrosh 		struct nfsd4_release_lockowner *rlockowner);
6103e98abffSJ. Bruce Fields extern int nfsd4_release_compoundargs(void *rq, __be32 *p, void *resp);
6119a74af21SBoaz Harrosh extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
6129a74af21SBoaz Harrosh 		struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr);
6139a74af21SBoaz Harrosh extern __be32 nfsd4_renew(struct svc_rqst *rqstp,
6149a74af21SBoaz Harrosh 			  struct nfsd4_compound_state *, clientid_t *clid);
61517456804SBryan Schumaker extern __be32 nfsd4_test_stateid(struct svc_rqst *rqstp,
61617456804SBryan Schumaker 		struct nfsd4_compound_state *, struct nfsd4_test_stateid *test_stateid);
617e1ca12dfSBryan Schumaker extern __be32 nfsd4_free_stateid(struct svc_rqst *rqstp,
618e1ca12dfSBryan Schumaker 		struct nfsd4_compound_state *, struct nfsd4_free_stateid *free_stateid);
6199a74af21SBoaz Harrosh #endif
6209a74af21SBoaz Harrosh 
6219a74af21SBoaz Harrosh /*
6229a74af21SBoaz Harrosh  * Local variables:
6239a74af21SBoaz Harrosh  *  c-basic-offset: 8
6249a74af21SBoaz Harrosh  * End:
6259a74af21SBoaz Harrosh  */
626