xref: /openbmc/linux/fs/nfsd/xdr4.h (revision 07d1f802)
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 
4318032ca0SDavid Quigley #define NFSD4_MAX_SEC_LABEL_LEN	2048
449a74af21SBoaz Harrosh #define NFSD4_MAX_TAGLEN	128
459a74af21SBoaz Harrosh #define XDR_LEN(n)                     (((n) + 3) & ~3)
469a74af21SBoaz Harrosh 
4737c593c5STigran Mkrtchyan #define CURRENT_STATE_ID_FLAG (1<<0)
4837c593c5STigran Mkrtchyan #define SAVED_STATE_ID_FLAG (1<<1)
4937c593c5STigran Mkrtchyan 
5037c593c5STigran Mkrtchyan #define SET_STATE_ID(c, f) ((c)->sid_flags |= (f))
5137c593c5STigran Mkrtchyan #define HAS_STATE_ID(c, f) ((c)->sid_flags & (f))
5237c593c5STigran Mkrtchyan #define CLEAR_STATE_ID(c, f) ((c)->sid_flags &= ~(f))
5337c593c5STigran Mkrtchyan 
549a74af21SBoaz Harrosh struct nfsd4_compound_state {
559a74af21SBoaz Harrosh 	struct svc_fh		current_fh;
569a74af21SBoaz Harrosh 	struct svc_fh		save_fh;
579a74af21SBoaz Harrosh 	struct nfs4_stateowner	*replay_owner;
589a74af21SBoaz Harrosh 	/* For sessions DRC */
599a74af21SBoaz Harrosh 	struct nfsd4_session	*session;
609a74af21SBoaz Harrosh 	struct nfsd4_slot	*slot;
619a74af21SBoaz Harrosh 	__be32			*datap;
629a74af21SBoaz Harrosh 	size_t			iovlen;
639a74af21SBoaz Harrosh 	u32			minorversion;
6457b7b43bSJ. Bruce Fields 	__be32			status;
6537c593c5STigran Mkrtchyan 	stateid_t	current_stateid;
6637c593c5STigran Mkrtchyan 	stateid_t	save_stateid;
6737c593c5STigran Mkrtchyan 	/* to indicate current and saved state id presents */
6837c593c5STigran Mkrtchyan 	u32		sid_flags;
699a74af21SBoaz Harrosh };
709a74af21SBoaz Harrosh 
719a74af21SBoaz Harrosh static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs)
729a74af21SBoaz Harrosh {
739a74af21SBoaz Harrosh 	return cs->slot != NULL;
749a74af21SBoaz Harrosh }
759a74af21SBoaz Harrosh 
769a74af21SBoaz Harrosh struct nfsd4_change_info {
779a74af21SBoaz Harrosh 	u32		atomic;
789a74af21SBoaz Harrosh 	bool		change_supported;
799a74af21SBoaz Harrosh 	u32		before_ctime_sec;
809a74af21SBoaz Harrosh 	u32		before_ctime_nsec;
819a74af21SBoaz Harrosh 	u64		before_change;
829a74af21SBoaz Harrosh 	u32		after_ctime_sec;
839a74af21SBoaz Harrosh 	u32		after_ctime_nsec;
849a74af21SBoaz Harrosh 	u64		after_change;
859a74af21SBoaz Harrosh };
869a74af21SBoaz Harrosh 
879a74af21SBoaz Harrosh struct nfsd4_access {
889a74af21SBoaz Harrosh 	u32		ac_req_access;      /* request */
899a74af21SBoaz Harrosh 	u32		ac_supported;       /* response */
909a74af21SBoaz Harrosh 	u32		ac_resp_access;     /* response */
919a74af21SBoaz Harrosh };
929a74af21SBoaz Harrosh 
939a74af21SBoaz Harrosh struct nfsd4_close {
949a74af21SBoaz Harrosh 	u32		cl_seqid;           /* request */
959a74af21SBoaz Harrosh 	stateid_t	cl_stateid;         /* request+response */
969a74af21SBoaz Harrosh };
979a74af21SBoaz Harrosh 
989a74af21SBoaz Harrosh struct nfsd4_commit {
999a74af21SBoaz Harrosh 	u64		co_offset;          /* request */
1009a74af21SBoaz Harrosh 	u32		co_count;           /* request */
1019a74af21SBoaz Harrosh 	nfs4_verifier	co_verf;            /* response */
1029a74af21SBoaz Harrosh };
1039a74af21SBoaz Harrosh 
1049a74af21SBoaz Harrosh struct nfsd4_create {
1059a74af21SBoaz Harrosh 	u32		cr_namelen;         /* request */
1069a74af21SBoaz Harrosh 	char *		cr_name;            /* request */
1079a74af21SBoaz Harrosh 	u32		cr_type;            /* request */
1089a74af21SBoaz Harrosh 	union {                             /* request */
1099a74af21SBoaz Harrosh 		struct {
1109a74af21SBoaz Harrosh 			u32 namelen;
1119a74af21SBoaz Harrosh 			char *name;
1129a74af21SBoaz Harrosh 		} link;   /* NF4LNK */
1139a74af21SBoaz Harrosh 		struct {
1149a74af21SBoaz Harrosh 			u32 specdata1;
1159a74af21SBoaz Harrosh 			u32 specdata2;
1169a74af21SBoaz Harrosh 		} dev;    /* NF4BLK, NF4CHR */
1179a74af21SBoaz Harrosh 	} u;
1189a74af21SBoaz Harrosh 	u32		cr_bmval[3];        /* request */
1199a74af21SBoaz Harrosh 	struct iattr	cr_iattr;           /* request */
1209a74af21SBoaz Harrosh 	struct nfsd4_change_info  cr_cinfo; /* response */
1219a74af21SBoaz Harrosh 	struct nfs4_acl *cr_acl;
12218032ca0SDavid Quigley 	struct xdr_netobj cr_label;
1239a74af21SBoaz Harrosh };
1249a74af21SBoaz Harrosh #define cr_linklen	u.link.namelen
1259a74af21SBoaz Harrosh #define cr_linkname	u.link.name
1269a74af21SBoaz Harrosh #define cr_specdata1	u.dev.specdata1
1279a74af21SBoaz Harrosh #define cr_specdata2	u.dev.specdata2
1289a74af21SBoaz Harrosh 
1299a74af21SBoaz Harrosh struct nfsd4_delegreturn {
1309a74af21SBoaz Harrosh 	stateid_t	dr_stateid;
1319a74af21SBoaz Harrosh };
1329a74af21SBoaz Harrosh 
1339a74af21SBoaz Harrosh struct nfsd4_getattr {
1349a74af21SBoaz Harrosh 	u32		ga_bmval[3];        /* request */
1359a74af21SBoaz Harrosh 	struct svc_fh	*ga_fhp;            /* response */
1369a74af21SBoaz Harrosh };
1379a74af21SBoaz Harrosh 
1389a74af21SBoaz Harrosh struct nfsd4_link {
1399a74af21SBoaz Harrosh 	u32		li_namelen;         /* request */
1409a74af21SBoaz Harrosh 	char *		li_name;            /* request */
1419a74af21SBoaz Harrosh 	struct nfsd4_change_info  li_cinfo; /* response */
1429a74af21SBoaz Harrosh };
1439a74af21SBoaz Harrosh 
1449a74af21SBoaz Harrosh struct nfsd4_lock_denied {
1459a74af21SBoaz Harrosh 	clientid_t	ld_clientid;
1467c13f344SJ. Bruce Fields 	struct xdr_netobj	ld_owner;
1479a74af21SBoaz Harrosh 	u64             ld_start;
1489a74af21SBoaz Harrosh 	u64             ld_length;
1499a74af21SBoaz Harrosh 	u32             ld_type;
1509a74af21SBoaz Harrosh };
1519a74af21SBoaz Harrosh 
1529a74af21SBoaz Harrosh struct nfsd4_lock {
1539a74af21SBoaz Harrosh 	/* request */
1549a74af21SBoaz Harrosh 	u32             lk_type;
1559a74af21SBoaz Harrosh 	u32             lk_reclaim;         /* boolean */
1569a74af21SBoaz Harrosh 	u64             lk_offset;
1579a74af21SBoaz Harrosh 	u64             lk_length;
1589a74af21SBoaz Harrosh 	u32             lk_is_new;
1599a74af21SBoaz Harrosh 	union {
1609a74af21SBoaz Harrosh 		struct {
1619a74af21SBoaz Harrosh 			u32             open_seqid;
1629a74af21SBoaz Harrosh 			stateid_t       open_stateid;
1639a74af21SBoaz Harrosh 			u32             lock_seqid;
1649a74af21SBoaz Harrosh 			clientid_t      clientid;
1659a74af21SBoaz Harrosh 			struct xdr_netobj owner;
1669a74af21SBoaz Harrosh 		} new;
1679a74af21SBoaz Harrosh 		struct {
1689a74af21SBoaz Harrosh 			stateid_t       lock_stateid;
1699a74af21SBoaz Harrosh 			u32             lock_seqid;
1709a74af21SBoaz Harrosh 		} old;
1719a74af21SBoaz Harrosh 	} v;
1729a74af21SBoaz Harrosh 
1739a74af21SBoaz Harrosh 	/* response */
1749a74af21SBoaz Harrosh 	union {
1759a74af21SBoaz Harrosh 		struct {
1769a74af21SBoaz Harrosh 			stateid_t               stateid;
1779a74af21SBoaz Harrosh 		} ok;
1789a74af21SBoaz Harrosh 		struct nfsd4_lock_denied        denied;
1799a74af21SBoaz Harrosh 	} u;
1809a74af21SBoaz Harrosh };
1819a74af21SBoaz Harrosh #define lk_new_open_seqid       v.new.open_seqid
1829a74af21SBoaz Harrosh #define lk_new_open_stateid     v.new.open_stateid
1839a74af21SBoaz Harrosh #define lk_new_lock_seqid       v.new.lock_seqid
1849a74af21SBoaz Harrosh #define lk_new_clientid         v.new.clientid
1859a74af21SBoaz Harrosh #define lk_new_owner            v.new.owner
1869a74af21SBoaz Harrosh #define lk_old_lock_stateid     v.old.lock_stateid
1879a74af21SBoaz Harrosh #define lk_old_lock_seqid       v.old.lock_seqid
1889a74af21SBoaz Harrosh 
1899a74af21SBoaz Harrosh #define lk_resp_stateid u.ok.stateid
1909a74af21SBoaz Harrosh #define lk_denied       u.denied
1919a74af21SBoaz Harrosh 
1929a74af21SBoaz Harrosh 
1939a74af21SBoaz Harrosh struct nfsd4_lockt {
1949a74af21SBoaz Harrosh 	u32				lt_type;
1959a74af21SBoaz Harrosh 	clientid_t			lt_clientid;
1969a74af21SBoaz Harrosh 	struct xdr_netobj		lt_owner;
1979a74af21SBoaz Harrosh 	u64				lt_offset;
1989a74af21SBoaz Harrosh 	u64				lt_length;
1999a74af21SBoaz Harrosh 	struct nfsd4_lock_denied  	lt_denied;
2009a74af21SBoaz Harrosh };
2019a74af21SBoaz Harrosh 
2029a74af21SBoaz Harrosh 
2039a74af21SBoaz Harrosh struct nfsd4_locku {
2049a74af21SBoaz Harrosh 	u32             lu_type;
2059a74af21SBoaz Harrosh 	u32             lu_seqid;
2069a74af21SBoaz Harrosh 	stateid_t       lu_stateid;
2079a74af21SBoaz Harrosh 	u64             lu_offset;
2089a74af21SBoaz Harrosh 	u64             lu_length;
2099a74af21SBoaz Harrosh };
2109a74af21SBoaz Harrosh 
2119a74af21SBoaz Harrosh 
2129a74af21SBoaz Harrosh struct nfsd4_lookup {
2139a74af21SBoaz Harrosh 	u32		lo_len;             /* request */
2149a74af21SBoaz Harrosh 	char *		lo_name;            /* request */
2159a74af21SBoaz Harrosh };
2169a74af21SBoaz Harrosh 
2179a74af21SBoaz Harrosh struct nfsd4_putfh {
2189a74af21SBoaz Harrosh 	u32		pf_fhlen;           /* request */
2199a74af21SBoaz Harrosh 	char		*pf_fhval;          /* request */
2209a74af21SBoaz Harrosh };
2219a74af21SBoaz Harrosh 
2229a74af21SBoaz Harrosh struct nfsd4_open {
2239a74af21SBoaz Harrosh 	u32		op_claim_type;      /* request */
2249a74af21SBoaz Harrosh 	struct xdr_netobj op_fname;	    /* request - everything but CLAIM_PREV */
2259a74af21SBoaz Harrosh 	u32		op_delegate_type;   /* request - CLAIM_PREV only */
2269a74af21SBoaz Harrosh 	stateid_t       op_delegate_stateid; /* request - response */
227d24433cdSBenny Halevy 	u32		op_why_no_deleg;    /* response - DELEG_NONE_EXT only */
2289a74af21SBoaz Harrosh 	u32		op_create;     	    /* request */
2299a74af21SBoaz Harrosh 	u32		op_createmode;      /* request */
2309a74af21SBoaz Harrosh 	u32		op_bmval[3];        /* request */
2313ff69309SKinglong Mee 	struct iattr	op_iattr;           /* UNCHECKED4, GUARDED4, EXCLUSIVE4_1 */
232ab4684d1SChuck Lever 	nfs4_verifier	op_verf __attribute__((aligned(32)));
233ab4684d1SChuck Lever 					    /* EXCLUSIVE4 */
2349a74af21SBoaz Harrosh 	clientid_t	op_clientid;        /* request */
2359a74af21SBoaz Harrosh 	struct xdr_netobj op_owner;           /* request */
2369a74af21SBoaz Harrosh 	u32		op_seqid;           /* request */
2379a74af21SBoaz Harrosh 	u32		op_share_access;    /* request */
2389a74af21SBoaz Harrosh 	u32		op_share_deny;      /* request */
2392c8bd7e0SBenny Halevy 	u32		op_deleg_want;      /* request */
2409a74af21SBoaz Harrosh 	stateid_t	op_stateid;         /* response */
2419d313b17SJ. Bruce Fields 	__be32		op_xdr_error;       /* see nfsd4_open_omfg() */
2429a74af21SBoaz Harrosh 	u32		op_recall;          /* recall */
2439a74af21SBoaz Harrosh 	struct nfsd4_change_info  op_cinfo; /* response */
2449a74af21SBoaz Harrosh 	u32		op_rflags;          /* response */
245856121b2SJ. Bruce Fields 	bool		op_truncate;        /* used during processing */
246856121b2SJ. Bruce Fields 	bool		op_created;         /* used during processing */
247fe0750e5SJ. Bruce Fields 	struct nfs4_openowner *op_openowner; /* used during processing */
24832513b40SJ. Bruce Fields 	struct nfs4_file *op_file;          /* used during processing */
2494cdc951bSJ. Bruce Fields 	struct nfs4_ol_stateid *op_stp;	    /* used during processing */
2509a74af21SBoaz Harrosh 	struct nfs4_acl *op_acl;
25118032ca0SDavid Quigley 	struct xdr_netobj op_label;
2529a74af21SBoaz Harrosh };
2539a74af21SBoaz Harrosh 
2549a74af21SBoaz Harrosh struct nfsd4_open_confirm {
2559a74af21SBoaz Harrosh 	stateid_t	oc_req_stateid		/* request */;
2569a74af21SBoaz Harrosh 	u32		oc_seqid    		/* request */;
2579a74af21SBoaz Harrosh 	stateid_t	oc_resp_stateid		/* response */;
2589a74af21SBoaz Harrosh };
2599a74af21SBoaz Harrosh 
2609a74af21SBoaz Harrosh struct nfsd4_open_downgrade {
2619a74af21SBoaz Harrosh 	stateid_t       od_stateid;
2629a74af21SBoaz Harrosh 	u32             od_seqid;
2632c8bd7e0SBenny Halevy 	u32             od_share_access;	/* request */
2642c8bd7e0SBenny Halevy 	u32		od_deleg_want;		/* request */
2652c8bd7e0SBenny Halevy 	u32             od_share_deny;		/* request */
2669a74af21SBoaz Harrosh };
2679a74af21SBoaz Harrosh 
2689a74af21SBoaz Harrosh 
2699a74af21SBoaz Harrosh struct nfsd4_read {
2709a74af21SBoaz Harrosh 	stateid_t	rd_stateid;         /* request */
2719a74af21SBoaz Harrosh 	u64		rd_offset;          /* request */
2729a74af21SBoaz Harrosh 	u32		rd_length;          /* request */
2739a74af21SBoaz Harrosh 	int		rd_vlen;
2749a74af21SBoaz Harrosh 	struct file     *rd_filp;
2759a74af21SBoaz Harrosh 
2769a74af21SBoaz Harrosh 	struct svc_rqst *rd_rqstp;          /* response */
2779a74af21SBoaz Harrosh 	struct svc_fh * rd_fhp;             /* response */
2789a74af21SBoaz Harrosh };
2799a74af21SBoaz Harrosh 
2809a74af21SBoaz Harrosh struct nfsd4_readdir {
2819a74af21SBoaz Harrosh 	u64		rd_cookie;          /* request */
2829a74af21SBoaz Harrosh 	nfs4_verifier	rd_verf;            /* request */
2839a74af21SBoaz Harrosh 	u32		rd_dircount;        /* request */
2849a74af21SBoaz Harrosh 	u32		rd_maxcount;        /* request */
2859a74af21SBoaz Harrosh 	u32		rd_bmval[3];        /* request */
2869a74af21SBoaz Harrosh 	struct svc_rqst *rd_rqstp;          /* response */
2879a74af21SBoaz Harrosh 	struct svc_fh * rd_fhp;             /* response */
2889a74af21SBoaz Harrosh 
2899a74af21SBoaz Harrosh 	struct readdir_cd	common;
2909a74af21SBoaz Harrosh 	__be32 *		buffer;
2919a74af21SBoaz Harrosh 	int			buflen;
2929a74af21SBoaz Harrosh 	__be32 *		offset;
2939a74af21SBoaz Harrosh };
2949a74af21SBoaz Harrosh 
2959a74af21SBoaz Harrosh struct nfsd4_release_lockowner {
2969a74af21SBoaz Harrosh 	clientid_t        rl_clientid;
2979a74af21SBoaz Harrosh 	struct xdr_netobj rl_owner;
2989a74af21SBoaz Harrosh };
2999a74af21SBoaz Harrosh struct nfsd4_readlink {
3009a74af21SBoaz Harrosh 	struct svc_rqst *rl_rqstp;          /* request */
3019a74af21SBoaz Harrosh 	struct svc_fh *	rl_fhp;             /* request */
3029a74af21SBoaz Harrosh };
3039a74af21SBoaz Harrosh 
3049a74af21SBoaz Harrosh struct nfsd4_remove {
3059a74af21SBoaz Harrosh 	u32		rm_namelen;         /* request */
3069a74af21SBoaz Harrosh 	char *		rm_name;            /* request */
3079a74af21SBoaz Harrosh 	struct nfsd4_change_info  rm_cinfo; /* response */
3089a74af21SBoaz Harrosh };
3099a74af21SBoaz Harrosh 
3109a74af21SBoaz Harrosh struct nfsd4_rename {
3119a74af21SBoaz Harrosh 	u32		rn_snamelen;        /* request */
3129a74af21SBoaz Harrosh 	char *		rn_sname;           /* request */
3139a74af21SBoaz Harrosh 	u32		rn_tnamelen;        /* request */
3149a74af21SBoaz Harrosh 	char *		rn_tname;           /* request */
3159a74af21SBoaz Harrosh 	struct nfsd4_change_info  rn_sinfo; /* response */
3169a74af21SBoaz Harrosh 	struct nfsd4_change_info  rn_tinfo; /* response */
3179a74af21SBoaz Harrosh };
3189a74af21SBoaz Harrosh 
3199a74af21SBoaz Harrosh struct nfsd4_secinfo {
3209a74af21SBoaz Harrosh 	u32 si_namelen;					/* request */
3219a74af21SBoaz Harrosh 	char *si_name;					/* request */
3229a74af21SBoaz Harrosh 	struct svc_export *si_exp;			/* response */
3239a74af21SBoaz Harrosh };
3249a74af21SBoaz Harrosh 
32504f4ad16SJ. Bruce Fields struct nfsd4_secinfo_no_name {
32604f4ad16SJ. Bruce Fields 	u32 sin_style;					/* request */
32704f4ad16SJ. Bruce Fields 	struct svc_export *sin_exp;			/* response */
32804f4ad16SJ. Bruce Fields };
32904f4ad16SJ. Bruce Fields 
3309a74af21SBoaz Harrosh struct nfsd4_setattr {
3319a74af21SBoaz Harrosh 	stateid_t	sa_stateid;         /* request */
3329a74af21SBoaz Harrosh 	u32		sa_bmval[3];        /* request */
3339a74af21SBoaz Harrosh 	struct iattr	sa_iattr;           /* request */
3349a74af21SBoaz Harrosh 	struct nfs4_acl *sa_acl;
33518032ca0SDavid Quigley 	struct xdr_netobj sa_label;
3369a74af21SBoaz Harrosh };
3379a74af21SBoaz Harrosh 
3389a74af21SBoaz Harrosh struct nfsd4_setclientid {
3399a74af21SBoaz Harrosh 	nfs4_verifier	se_verf;            /* request */
340a084daf5SJ. Bruce Fields 	struct xdr_netobj se_name;
3419a74af21SBoaz Harrosh 	u32		se_callback_prog;   /* request */
3429a74af21SBoaz Harrosh 	u32		se_callback_netid_len;  /* request */
3439a74af21SBoaz Harrosh 	char *		se_callback_netid_val;  /* request */
3449a74af21SBoaz Harrosh 	u32		se_callback_addr_len;   /* request */
3459a74af21SBoaz Harrosh 	char *		se_callback_addr_val;   /* request */
3469a74af21SBoaz Harrosh 	u32		se_callback_ident;  /* request */
3479a74af21SBoaz Harrosh 	clientid_t	se_clientid;        /* response */
3489a74af21SBoaz Harrosh 	nfs4_verifier	se_confirm;         /* response */
3499a74af21SBoaz Harrosh };
3509a74af21SBoaz Harrosh 
3519a74af21SBoaz Harrosh struct nfsd4_setclientid_confirm {
3529a74af21SBoaz Harrosh 	clientid_t	sc_clientid;
3539a74af21SBoaz Harrosh 	nfs4_verifier	sc_confirm;
3549a74af21SBoaz Harrosh };
3559a74af21SBoaz Harrosh 
35617456804SBryan Schumaker struct nfsd4_saved_compoundargs {
35717456804SBryan Schumaker 	__be32 *p;
35817456804SBryan Schumaker 	__be32 *end;
35917456804SBryan Schumaker 	int pagelen;
36017456804SBryan Schumaker 	struct page **pagelist;
36117456804SBryan Schumaker };
36217456804SBryan Schumaker 
36303cfb420SBryan Schumaker struct nfsd4_test_stateid_id {
36403cfb420SBryan Schumaker 	__be32			ts_id_status;
36503cfb420SBryan Schumaker 	stateid_t		ts_id_stateid;
36603cfb420SBryan Schumaker 	struct list_head	ts_id_list;
36703cfb420SBryan Schumaker };
36803cfb420SBryan Schumaker 
36917456804SBryan Schumaker struct nfsd4_test_stateid {
37057b7b43bSJ. Bruce Fields 	u32		ts_num_ids;
37103cfb420SBryan Schumaker 	struct list_head ts_stateid_list;
37217456804SBryan Schumaker };
37317456804SBryan Schumaker 
374e1ca12dfSBryan Schumaker struct nfsd4_free_stateid {
375e1ca12dfSBryan Schumaker 	stateid_t	fr_stateid;         /* request */
376e1ca12dfSBryan Schumaker };
377e1ca12dfSBryan Schumaker 
3789a74af21SBoaz Harrosh /* also used for NVERIFY */
3799a74af21SBoaz Harrosh struct nfsd4_verify {
3809a74af21SBoaz Harrosh 	u32		ve_bmval[3];        /* request */
3819a74af21SBoaz Harrosh 	u32		ve_attrlen;         /* request */
3829a74af21SBoaz Harrosh 	char *		ve_attrval;         /* request */
3839a74af21SBoaz Harrosh };
3849a74af21SBoaz Harrosh 
3859a74af21SBoaz Harrosh struct nfsd4_write {
3869a74af21SBoaz Harrosh 	stateid_t	wr_stateid;         /* request */
3879a74af21SBoaz Harrosh 	u64		wr_offset;          /* request */
3889a74af21SBoaz Harrosh 	u32		wr_stable_how;      /* request */
3899a74af21SBoaz Harrosh 	u32		wr_buflen;          /* request */
39070cc7f75SJ. Bruce Fields 	struct kvec	wr_head;
39170cc7f75SJ. Bruce Fields 	struct page **	wr_pagelist;        /* request */
3929a74af21SBoaz Harrosh 
3939a74af21SBoaz Harrosh 	u32		wr_bytes_written;   /* response */
3949a74af21SBoaz Harrosh 	u32		wr_how_written;     /* response */
3959a74af21SBoaz Harrosh 	nfs4_verifier	wr_verifier;        /* response */
3969a74af21SBoaz Harrosh };
3979a74af21SBoaz Harrosh 
3989a74af21SBoaz Harrosh struct nfsd4_exchange_id {
3999a74af21SBoaz Harrosh 	nfs4_verifier	verifier;
4009a74af21SBoaz Harrosh 	struct xdr_netobj clname;
4019a74af21SBoaz Harrosh 	u32		flags;
4029a74af21SBoaz Harrosh 	clientid_t	clientid;
4039a74af21SBoaz Harrosh 	u32		seqid;
4049a74af21SBoaz Harrosh 	int		spa_how;
4059a74af21SBoaz Harrosh };
4069a74af21SBoaz Harrosh 
4079a74af21SBoaz Harrosh struct nfsd4_sequence {
4089a74af21SBoaz Harrosh 	struct nfs4_sessionid	sessionid;		/* request/response */
4099a74af21SBoaz Harrosh 	u32			seqid;			/* request/response */
4109a74af21SBoaz Harrosh 	u32			slotid;			/* request/response */
4119a74af21SBoaz Harrosh 	u32			maxslots;		/* request/response */
4129a74af21SBoaz Harrosh 	u32			cachethis;		/* request */
4139a74af21SBoaz Harrosh #if 0
4149a74af21SBoaz Harrosh 	u32			target_maxslots;	/* response */
4159a74af21SBoaz Harrosh #endif /* not yet */
4160d7bb719SJ. Bruce Fields 	u32			status_flags;		/* response */
4179a74af21SBoaz Harrosh };
4189a74af21SBoaz Harrosh 
4199a74af21SBoaz Harrosh struct nfsd4_destroy_session {
4209a74af21SBoaz Harrosh 	struct nfs4_sessionid	sessionid;
4219a74af21SBoaz Harrosh };
4229a74af21SBoaz Harrosh 
423345c2842SMi Jinlong struct nfsd4_destroy_clientid {
424345c2842SMi Jinlong 	clientid_t clientid;
425345c2842SMi Jinlong };
426345c2842SMi Jinlong 
4274dc6ec00SJ. Bruce Fields struct nfsd4_reclaim_complete {
4284dc6ec00SJ. Bruce Fields 	u32 rca_one_fs;
4294dc6ec00SJ. Bruce Fields };
4304dc6ec00SJ. Bruce Fields 
4319a74af21SBoaz Harrosh struct nfsd4_op {
4329a74af21SBoaz Harrosh 	int					opnum;
4339a74af21SBoaz Harrosh 	__be32					status;
4349a74af21SBoaz Harrosh 	union {
4359a74af21SBoaz Harrosh 		struct nfsd4_access		access;
4369a74af21SBoaz Harrosh 		struct nfsd4_close		close;
4379a74af21SBoaz Harrosh 		struct nfsd4_commit		commit;
4389a74af21SBoaz Harrosh 		struct nfsd4_create		create;
4399a74af21SBoaz Harrosh 		struct nfsd4_delegreturn	delegreturn;
4409a74af21SBoaz Harrosh 		struct nfsd4_getattr		getattr;
4419a74af21SBoaz Harrosh 		struct svc_fh *			getfh;
4429a74af21SBoaz Harrosh 		struct nfsd4_link		link;
4439a74af21SBoaz Harrosh 		struct nfsd4_lock		lock;
4449a74af21SBoaz Harrosh 		struct nfsd4_lockt		lockt;
4459a74af21SBoaz Harrosh 		struct nfsd4_locku		locku;
4469a74af21SBoaz Harrosh 		struct nfsd4_lookup		lookup;
4479a74af21SBoaz Harrosh 		struct nfsd4_verify		nverify;
4489a74af21SBoaz Harrosh 		struct nfsd4_open		open;
4499a74af21SBoaz Harrosh 		struct nfsd4_open_confirm	open_confirm;
4509a74af21SBoaz Harrosh 		struct nfsd4_open_downgrade	open_downgrade;
4519a74af21SBoaz Harrosh 		struct nfsd4_putfh		putfh;
4529a74af21SBoaz Harrosh 		struct nfsd4_read		read;
4539a74af21SBoaz Harrosh 		struct nfsd4_readdir		readdir;
4549a74af21SBoaz Harrosh 		struct nfsd4_readlink		readlink;
4559a74af21SBoaz Harrosh 		struct nfsd4_remove		remove;
4569a74af21SBoaz Harrosh 		struct nfsd4_rename		rename;
4579a74af21SBoaz Harrosh 		clientid_t			renew;
4589a74af21SBoaz Harrosh 		struct nfsd4_secinfo		secinfo;
4599a74af21SBoaz Harrosh 		struct nfsd4_setattr		setattr;
4609a74af21SBoaz Harrosh 		struct nfsd4_setclientid	setclientid;
4619a74af21SBoaz Harrosh 		struct nfsd4_setclientid_confirm setclientid_confirm;
4629a74af21SBoaz Harrosh 		struct nfsd4_verify		verify;
4639a74af21SBoaz Harrosh 		struct nfsd4_write		write;
4649a74af21SBoaz Harrosh 		struct nfsd4_release_lockowner	release_lockowner;
4659a74af21SBoaz Harrosh 
4669a74af21SBoaz Harrosh 		/* NFSv4.1 */
4679a74af21SBoaz Harrosh 		struct nfsd4_exchange_id	exchange_id;
468cb73a9f4SJ. Bruce Fields 		struct nfsd4_backchannel_ctl	backchannel_ctl;
4691d1bc8f2SJ. Bruce Fields 		struct nfsd4_bind_conn_to_session bind_conn_to_session;
4709a74af21SBoaz Harrosh 		struct nfsd4_create_session	create_session;
4719a74af21SBoaz Harrosh 		struct nfsd4_destroy_session	destroy_session;
4729a74af21SBoaz Harrosh 		struct nfsd4_sequence		sequence;
4734dc6ec00SJ. Bruce Fields 		struct nfsd4_reclaim_complete	reclaim_complete;
47417456804SBryan Schumaker 		struct nfsd4_test_stateid	test_stateid;
475e1ca12dfSBryan Schumaker 		struct nfsd4_free_stateid	free_stateid;
4769a74af21SBoaz Harrosh 	} u;
4779a74af21SBoaz Harrosh 	struct nfs4_replay *			replay;
4789a74af21SBoaz Harrosh };
4799a74af21SBoaz Harrosh 
4801091006cSJ. Bruce Fields bool nfsd4_cache_this_op(struct nfsd4_op *);
4811091006cSJ. Bruce Fields 
4829a74af21SBoaz Harrosh struct nfsd4_compoundargs {
4839a74af21SBoaz Harrosh 	/* scratch variables for XDR decode */
4849a74af21SBoaz Harrosh 	__be32 *			p;
4859a74af21SBoaz Harrosh 	__be32 *			end;
4869a74af21SBoaz Harrosh 	struct page **			pagelist;
4879a74af21SBoaz Harrosh 	int				pagelen;
4889a74af21SBoaz Harrosh 	__be32				tmp[8];
4899a74af21SBoaz Harrosh 	__be32 *			tmpp;
4909a74af21SBoaz Harrosh 	struct tmpbuf {
4919a74af21SBoaz Harrosh 		struct tmpbuf *next;
4929a74af21SBoaz Harrosh 		void (*release)(const void *);
4939a74af21SBoaz Harrosh 		void *buf;
4949a74af21SBoaz Harrosh 	}				*to_free;
4959a74af21SBoaz Harrosh 
4969a74af21SBoaz Harrosh 	struct svc_rqst			*rqstp;
4979a74af21SBoaz Harrosh 
4989a74af21SBoaz Harrosh 	u32				taglen;
4999a74af21SBoaz Harrosh 	char *				tag;
5009a74af21SBoaz Harrosh 	u32				minorversion;
5019a74af21SBoaz Harrosh 	u32				opcnt;
5029a74af21SBoaz Harrosh 	struct nfsd4_op			*ops;
5039a74af21SBoaz Harrosh 	struct nfsd4_op			iops[8];
5041091006cSJ. Bruce Fields 	int				cachetype;
5059a74af21SBoaz Harrosh };
5069a74af21SBoaz Harrosh 
5079a74af21SBoaz Harrosh struct nfsd4_compoundres {
5089a74af21SBoaz Harrosh 	/* scratch variables for XDR encode */
5094aea24b2SJ. Bruce Fields 	struct xdr_stream		xdr;
5109a74af21SBoaz Harrosh 	struct svc_rqst *		rqstp;
5119a74af21SBoaz Harrosh 
5129a74af21SBoaz Harrosh 	u32				taglen;
5139a74af21SBoaz Harrosh 	char *				tag;
5149a74af21SBoaz Harrosh 	u32				opcnt;
5159a74af21SBoaz Harrosh 	__be32 *			tagp; /* tag, opcount encode location */
5169a74af21SBoaz Harrosh 	struct nfsd4_compound_state	cstate;
5179a74af21SBoaz Harrosh };
5189a74af21SBoaz Harrosh 
5199a74af21SBoaz Harrosh static inline bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp)
5209a74af21SBoaz Harrosh {
5219a74af21SBoaz Harrosh 	struct nfsd4_compoundargs *args = resp->rqstp->rq_argp;
5229a74af21SBoaz Harrosh 	return resp->opcnt == 1 && args->ops[0].opnum == OP_SEQUENCE;
5239a74af21SBoaz Harrosh }
5249a74af21SBoaz Harrosh 
5259a74af21SBoaz Harrosh static inline bool nfsd4_not_cached(struct nfsd4_compoundres *resp)
5269a74af21SBoaz Harrosh {
52773e79482SJ. Bruce Fields 	return !(resp->cstate.slot->sl_flags & NFSD4_SLOT_CACHETHIS)
52873e79482SJ. Bruce Fields 		|| nfsd4_is_solo_sequence(resp);
5299a74af21SBoaz Harrosh }
5309a74af21SBoaz Harrosh 
5319b3234b9SJ. Bruce Fields static inline bool nfsd4_last_compound_op(struct svc_rqst *rqstp)
5329b3234b9SJ. Bruce Fields {
5339b3234b9SJ. Bruce Fields 	struct nfsd4_compoundres *resp = rqstp->rq_resp;
5349b3234b9SJ. Bruce Fields 	struct nfsd4_compoundargs *argp = rqstp->rq_argp;
5359b3234b9SJ. Bruce Fields 
5369b3234b9SJ. Bruce Fields 	return argp->opcnt == resp->opcnt;
5379b3234b9SJ. Bruce Fields }
5389b3234b9SJ. Bruce Fields 
53907d1f802SJ. Bruce Fields void warn_on_nonidempotent_op(struct nfsd4_op *op);
54007d1f802SJ. Bruce Fields 
5419a74af21SBoaz Harrosh #define NFS4_SVC_XDRSIZE		sizeof(struct nfsd4_compoundargs)
5429a74af21SBoaz Harrosh 
5439a74af21SBoaz Harrosh static inline void
5449a74af21SBoaz Harrosh set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
5459a74af21SBoaz Harrosh {
546c1ac3ffcSNeil Brown 	BUG_ON(!fhp->fh_pre_saved);
547c1ac3ffcSNeil Brown 	cinfo->atomic = fhp->fh_post_saved;
5489a74af21SBoaz Harrosh 	cinfo->change_supported = IS_I_VERSION(fhp->fh_dentry->d_inode);
549c1ac3ffcSNeil Brown 
5509a74af21SBoaz Harrosh 	cinfo->before_change = fhp->fh_pre_change;
5519a74af21SBoaz Harrosh 	cinfo->after_change = fhp->fh_post_change;
5529a74af21SBoaz Harrosh 	cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
5539a74af21SBoaz Harrosh 	cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
5549a74af21SBoaz Harrosh 	cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
5559a74af21SBoaz Harrosh 	cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
556c1ac3ffcSNeil Brown 
5579a74af21SBoaz Harrosh }
5589a74af21SBoaz Harrosh 
5599a74af21SBoaz Harrosh int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
5609a74af21SBoaz Harrosh int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *,
5619a74af21SBoaz Harrosh 		struct nfsd4_compoundargs *);
5629a74af21SBoaz Harrosh int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *,
5639a74af21SBoaz Harrosh 		struct nfsd4_compoundres *);
56457b7b43bSJ. Bruce Fields __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *, u32);
5659a74af21SBoaz Harrosh void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
5669a74af21SBoaz Harrosh void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
567d5184658SJ. Bruce Fields __be32 nfsd4_encode_fattr_to_buf(__be32 **p, int words,
568d5184658SJ. Bruce Fields 		struct svc_fh *fhp, struct svc_export *exp,
569d5184658SJ. Bruce Fields 		struct dentry *dentry,
5709a74af21SBoaz Harrosh 		u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
5719a74af21SBoaz Harrosh extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
5729a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5739a74af21SBoaz Harrosh 		struct nfsd4_setclientid *setclid);
5749a74af21SBoaz Harrosh extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
5759a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5769a74af21SBoaz Harrosh 		struct nfsd4_setclientid_confirm *setclientid_confirm);
5779a74af21SBoaz Harrosh extern void nfsd4_store_cache_entry(struct nfsd4_compoundres *resp);
5789a74af21SBoaz Harrosh extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
5793c4ab2aaSJ. Bruce Fields 		struct nfsd4_compound_state *, struct nfsd4_exchange_id *);
580cb73a9f4SJ. Bruce Fields extern __be32 nfsd4_backchannel_ctl(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_backchannel_ctl *);
5811d1bc8f2SJ. Bruce Fields extern __be32 nfsd4_bind_conn_to_session(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_bind_conn_to_session *);
5829a74af21SBoaz Harrosh extern __be32 nfsd4_create_session(struct svc_rqst *,
5839a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5849a74af21SBoaz Harrosh 		struct nfsd4_create_session *);
5859a74af21SBoaz Harrosh extern __be32 nfsd4_sequence(struct svc_rqst *,
5869a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5879a74af21SBoaz Harrosh 		struct nfsd4_sequence *);
5889a74af21SBoaz Harrosh extern __be32 nfsd4_destroy_session(struct svc_rqst *,
5899a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5909a74af21SBoaz Harrosh 		struct nfsd4_destroy_session *);
591345c2842SMi Jinlong extern __be32 nfsd4_destroy_clientid(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_destroy_clientid *);
5924dc6ec00SJ. Bruce Fields __be32 nfsd4_reclaim_complete(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_reclaim_complete *);
5939a74af21SBoaz Harrosh extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *,
5943320fef1SStanislav Kinsbursky 		struct nfsd4_open *open, struct nfsd_net *nn);
5959a74af21SBoaz Harrosh extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
5969a74af21SBoaz Harrosh 		struct svc_fh *current_fh, struct nfsd4_open *open);
597d29b20cdSJ. Bruce Fields extern void nfsd4_cleanup_open_state(struct nfsd4_open *open, __be32 status);
5989a74af21SBoaz Harrosh extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
5999a74af21SBoaz Harrosh 		struct nfsd4_compound_state *, struct nfsd4_open_confirm *oc);
6009a74af21SBoaz Harrosh extern __be32 nfsd4_close(struct svc_rqst *rqstp,
6019a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
6029a74af21SBoaz Harrosh 		struct nfsd4_close *close);
6039a74af21SBoaz Harrosh extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
6049a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
6059a74af21SBoaz Harrosh 		struct nfsd4_open_downgrade *od);
6069a74af21SBoaz Harrosh extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
6079a74af21SBoaz Harrosh 		struct nfsd4_lock *lock);
6089a74af21SBoaz Harrosh extern __be32 nfsd4_lockt(struct svc_rqst *rqstp,
6099a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
6109a74af21SBoaz Harrosh 		struct nfsd4_lockt *lockt);
6119a74af21SBoaz Harrosh extern __be32 nfsd4_locku(struct svc_rqst *rqstp,
6129a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
6139a74af21SBoaz Harrosh 		struct nfsd4_locku *locku);
6149a74af21SBoaz Harrosh extern __be32
6159a74af21SBoaz Harrosh nfsd4_release_lockowner(struct svc_rqst *rqstp,
6169a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
6179a74af21SBoaz Harrosh 		struct nfsd4_release_lockowner *rlockowner);
6183e98abffSJ. Bruce Fields extern int nfsd4_release_compoundargs(void *rq, __be32 *p, void *resp);
6199a74af21SBoaz Harrosh extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
6209a74af21SBoaz Harrosh 		struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr);
6219a74af21SBoaz Harrosh extern __be32 nfsd4_renew(struct svc_rqst *rqstp,
6229a74af21SBoaz Harrosh 			  struct nfsd4_compound_state *, clientid_t *clid);
62317456804SBryan Schumaker extern __be32 nfsd4_test_stateid(struct svc_rqst *rqstp,
62417456804SBryan Schumaker 		struct nfsd4_compound_state *, struct nfsd4_test_stateid *test_stateid);
625e1ca12dfSBryan Schumaker extern __be32 nfsd4_free_stateid(struct svc_rqst *rqstp,
626e1ca12dfSBryan Schumaker 		struct nfsd4_compound_state *, struct nfsd4_free_stateid *free_stateid);
6279411b1d4SJ. Bruce Fields extern void nfsd4_bump_seqid(struct nfsd4_compound_state *, __be32 nfserr);
6289a74af21SBoaz Harrosh #endif
6299a74af21SBoaz Harrosh 
6309a74af21SBoaz Harrosh /*
6319a74af21SBoaz Harrosh  * Local variables:
6329a74af21SBoaz Harrosh  *  c-basic-offset: 8
6339a74af21SBoaz Harrosh  * End:
6349a74af21SBoaz Harrosh  */
635