xref: /openbmc/linux/fs/nfsd/xdr4.h (revision 1d1bc8f2)
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 
469a74af21SBoaz Harrosh struct nfsd4_compound_state {
479a74af21SBoaz Harrosh 	struct svc_fh		current_fh;
489a74af21SBoaz Harrosh 	struct svc_fh		save_fh;
499a74af21SBoaz Harrosh 	struct nfs4_stateowner	*replay_owner;
509a74af21SBoaz Harrosh 	/* For sessions DRC */
519a74af21SBoaz Harrosh 	struct nfsd4_session	*session;
529a74af21SBoaz Harrosh 	struct nfsd4_slot	*slot;
539a74af21SBoaz Harrosh 	__be32			*datap;
549a74af21SBoaz Harrosh 	size_t			iovlen;
559a74af21SBoaz Harrosh 	u32			minorversion;
569a74af21SBoaz Harrosh 	u32			status;
579a74af21SBoaz Harrosh };
589a74af21SBoaz Harrosh 
599a74af21SBoaz Harrosh static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs)
609a74af21SBoaz Harrosh {
619a74af21SBoaz Harrosh 	return cs->slot != NULL;
629a74af21SBoaz Harrosh }
639a74af21SBoaz Harrosh 
649a74af21SBoaz Harrosh struct nfsd4_change_info {
659a74af21SBoaz Harrosh 	u32		atomic;
669a74af21SBoaz Harrosh 	bool		change_supported;
679a74af21SBoaz Harrosh 	u32		before_ctime_sec;
689a74af21SBoaz Harrosh 	u32		before_ctime_nsec;
699a74af21SBoaz Harrosh 	u64		before_change;
709a74af21SBoaz Harrosh 	u32		after_ctime_sec;
719a74af21SBoaz Harrosh 	u32		after_ctime_nsec;
729a74af21SBoaz Harrosh 	u64		after_change;
739a74af21SBoaz Harrosh };
749a74af21SBoaz Harrosh 
759a74af21SBoaz Harrosh struct nfsd4_access {
769a74af21SBoaz Harrosh 	u32		ac_req_access;      /* request */
779a74af21SBoaz Harrosh 	u32		ac_supported;       /* response */
789a74af21SBoaz Harrosh 	u32		ac_resp_access;     /* response */
799a74af21SBoaz Harrosh };
809a74af21SBoaz Harrosh 
819a74af21SBoaz Harrosh struct nfsd4_close {
829a74af21SBoaz Harrosh 	u32		cl_seqid;           /* request */
839a74af21SBoaz Harrosh 	stateid_t	cl_stateid;         /* request+response */
849a74af21SBoaz Harrosh 	struct nfs4_stateowner * cl_stateowner;	/* response */
859a74af21SBoaz Harrosh };
869a74af21SBoaz Harrosh 
879a74af21SBoaz Harrosh struct nfsd4_commit {
889a74af21SBoaz Harrosh 	u64		co_offset;          /* request */
899a74af21SBoaz Harrosh 	u32		co_count;           /* request */
909a74af21SBoaz Harrosh 	nfs4_verifier	co_verf;            /* response */
919a74af21SBoaz Harrosh };
929a74af21SBoaz Harrosh 
939a74af21SBoaz Harrosh struct nfsd4_create {
949a74af21SBoaz Harrosh 	u32		cr_namelen;         /* request */
959a74af21SBoaz Harrosh 	char *		cr_name;            /* request */
969a74af21SBoaz Harrosh 	u32		cr_type;            /* request */
979a74af21SBoaz Harrosh 	union {                             /* request */
989a74af21SBoaz Harrosh 		struct {
999a74af21SBoaz Harrosh 			u32 namelen;
1009a74af21SBoaz Harrosh 			char *name;
1019a74af21SBoaz Harrosh 		} link;   /* NF4LNK */
1029a74af21SBoaz Harrosh 		struct {
1039a74af21SBoaz Harrosh 			u32 specdata1;
1049a74af21SBoaz Harrosh 			u32 specdata2;
1059a74af21SBoaz Harrosh 		} dev;    /* NF4BLK, NF4CHR */
1069a74af21SBoaz Harrosh 	} u;
1079a74af21SBoaz Harrosh 	u32		cr_bmval[3];        /* request */
1089a74af21SBoaz Harrosh 	struct iattr	cr_iattr;           /* request */
1099a74af21SBoaz Harrosh 	struct nfsd4_change_info  cr_cinfo; /* response */
1109a74af21SBoaz Harrosh 	struct nfs4_acl *cr_acl;
1119a74af21SBoaz Harrosh };
1129a74af21SBoaz Harrosh #define cr_linklen	u.link.namelen
1139a74af21SBoaz Harrosh #define cr_linkname	u.link.name
1149a74af21SBoaz Harrosh #define cr_specdata1	u.dev.specdata1
1159a74af21SBoaz Harrosh #define cr_specdata2	u.dev.specdata2
1169a74af21SBoaz Harrosh 
1179a74af21SBoaz Harrosh struct nfsd4_delegreturn {
1189a74af21SBoaz Harrosh 	stateid_t	dr_stateid;
1199a74af21SBoaz Harrosh };
1209a74af21SBoaz Harrosh 
1219a74af21SBoaz Harrosh struct nfsd4_getattr {
1229a74af21SBoaz Harrosh 	u32		ga_bmval[3];        /* request */
1239a74af21SBoaz Harrosh 	struct svc_fh	*ga_fhp;            /* response */
1249a74af21SBoaz Harrosh };
1259a74af21SBoaz Harrosh 
1269a74af21SBoaz Harrosh struct nfsd4_link {
1279a74af21SBoaz Harrosh 	u32		li_namelen;         /* request */
1289a74af21SBoaz Harrosh 	char *		li_name;            /* request */
1299a74af21SBoaz Harrosh 	struct nfsd4_change_info  li_cinfo; /* response */
1309a74af21SBoaz Harrosh };
1319a74af21SBoaz Harrosh 
1329a74af21SBoaz Harrosh struct nfsd4_lock_denied {
1339a74af21SBoaz Harrosh 	clientid_t	ld_clientid;
1349a74af21SBoaz Harrosh 	struct nfs4_stateowner   *ld_sop;
1359a74af21SBoaz Harrosh 	u64             ld_start;
1369a74af21SBoaz Harrosh 	u64             ld_length;
1379a74af21SBoaz Harrosh 	u32             ld_type;
1389a74af21SBoaz Harrosh };
1399a74af21SBoaz Harrosh 
1409a74af21SBoaz Harrosh struct nfsd4_lock {
1419a74af21SBoaz Harrosh 	/* request */
1429a74af21SBoaz Harrosh 	u32             lk_type;
1439a74af21SBoaz Harrosh 	u32             lk_reclaim;         /* boolean */
1449a74af21SBoaz Harrosh 	u64             lk_offset;
1459a74af21SBoaz Harrosh 	u64             lk_length;
1469a74af21SBoaz Harrosh 	u32             lk_is_new;
1479a74af21SBoaz Harrosh 	union {
1489a74af21SBoaz Harrosh 		struct {
1499a74af21SBoaz Harrosh 			u32             open_seqid;
1509a74af21SBoaz Harrosh 			stateid_t       open_stateid;
1519a74af21SBoaz Harrosh 			u32             lock_seqid;
1529a74af21SBoaz Harrosh 			clientid_t      clientid;
1539a74af21SBoaz Harrosh 			struct xdr_netobj owner;
1549a74af21SBoaz Harrosh 		} new;
1559a74af21SBoaz Harrosh 		struct {
1569a74af21SBoaz Harrosh 			stateid_t       lock_stateid;
1579a74af21SBoaz Harrosh 			u32             lock_seqid;
1589a74af21SBoaz Harrosh 		} old;
1599a74af21SBoaz Harrosh 	} v;
1609a74af21SBoaz Harrosh 
1619a74af21SBoaz Harrosh 	/* response */
1629a74af21SBoaz Harrosh 	union {
1639a74af21SBoaz Harrosh 		struct {
1649a74af21SBoaz Harrosh 			stateid_t               stateid;
1659a74af21SBoaz Harrosh 		} ok;
1669a74af21SBoaz Harrosh 		struct nfsd4_lock_denied        denied;
1679a74af21SBoaz Harrosh 	} u;
1689a74af21SBoaz Harrosh 	/* The lk_replay_owner is the open owner in the open_to_lock_owner
1699a74af21SBoaz Harrosh 	 * case and the lock owner otherwise: */
1709a74af21SBoaz Harrosh 	struct nfs4_stateowner *lk_replay_owner;
1719a74af21SBoaz Harrosh };
1729a74af21SBoaz Harrosh #define lk_new_open_seqid       v.new.open_seqid
1739a74af21SBoaz Harrosh #define lk_new_open_stateid     v.new.open_stateid
1749a74af21SBoaz Harrosh #define lk_new_lock_seqid       v.new.lock_seqid
1759a74af21SBoaz Harrosh #define lk_new_clientid         v.new.clientid
1769a74af21SBoaz Harrosh #define lk_new_owner            v.new.owner
1779a74af21SBoaz Harrosh #define lk_old_lock_stateid     v.old.lock_stateid
1789a74af21SBoaz Harrosh #define lk_old_lock_seqid       v.old.lock_seqid
1799a74af21SBoaz Harrosh 
1809a74af21SBoaz Harrosh #define lk_rflags       u.ok.rflags
1819a74af21SBoaz Harrosh #define lk_resp_stateid u.ok.stateid
1829a74af21SBoaz Harrosh #define lk_denied       u.denied
1839a74af21SBoaz Harrosh 
1849a74af21SBoaz Harrosh 
1859a74af21SBoaz Harrosh struct nfsd4_lockt {
1869a74af21SBoaz Harrosh 	u32				lt_type;
1879a74af21SBoaz Harrosh 	clientid_t			lt_clientid;
1889a74af21SBoaz Harrosh 	struct xdr_netobj		lt_owner;
1899a74af21SBoaz Harrosh 	u64				lt_offset;
1909a74af21SBoaz Harrosh 	u64				lt_length;
1919a74af21SBoaz Harrosh 	struct nfs4_stateowner * 	lt_stateowner;
1929a74af21SBoaz Harrosh 	struct nfsd4_lock_denied  	lt_denied;
1939a74af21SBoaz Harrosh };
1949a74af21SBoaz Harrosh 
1959a74af21SBoaz Harrosh 
1969a74af21SBoaz Harrosh struct nfsd4_locku {
1979a74af21SBoaz Harrosh 	u32             lu_type;
1989a74af21SBoaz Harrosh 	u32             lu_seqid;
1999a74af21SBoaz Harrosh 	stateid_t       lu_stateid;
2009a74af21SBoaz Harrosh 	u64             lu_offset;
2019a74af21SBoaz Harrosh 	u64             lu_length;
2029a74af21SBoaz Harrosh 	struct nfs4_stateowner  *lu_stateowner;
2039a74af21SBoaz Harrosh };
2049a74af21SBoaz Harrosh 
2059a74af21SBoaz Harrosh 
2069a74af21SBoaz Harrosh struct nfsd4_lookup {
2079a74af21SBoaz Harrosh 	u32		lo_len;             /* request */
2089a74af21SBoaz Harrosh 	char *		lo_name;            /* request */
2099a74af21SBoaz Harrosh };
2109a74af21SBoaz Harrosh 
2119a74af21SBoaz Harrosh struct nfsd4_putfh {
2129a74af21SBoaz Harrosh 	u32		pf_fhlen;           /* request */
2139a74af21SBoaz Harrosh 	char		*pf_fhval;          /* request */
2149a74af21SBoaz Harrosh };
2159a74af21SBoaz Harrosh 
2169a74af21SBoaz Harrosh struct nfsd4_open {
2179a74af21SBoaz Harrosh 	u32		op_claim_type;      /* request */
2189a74af21SBoaz Harrosh 	struct xdr_netobj op_fname;	    /* request - everything but CLAIM_PREV */
2199a74af21SBoaz Harrosh 	u32		op_delegate_type;   /* request - CLAIM_PREV only */
2209a74af21SBoaz Harrosh 	stateid_t       op_delegate_stateid; /* request - response */
2219a74af21SBoaz Harrosh 	u32		op_create;     	    /* request */
2229a74af21SBoaz Harrosh 	u32		op_createmode;      /* request */
2239a74af21SBoaz Harrosh 	u32		op_bmval[3];        /* request */
2249a74af21SBoaz Harrosh 	struct iattr	iattr;              /* UNCHECKED4, GUARDED4, EXCLUSIVE4_1 */
2259a74af21SBoaz Harrosh 	nfs4_verifier	verf;               /* EXCLUSIVE4 */
2269a74af21SBoaz Harrosh 	clientid_t	op_clientid;        /* request */
2279a74af21SBoaz Harrosh 	struct xdr_netobj op_owner;           /* request */
2289a74af21SBoaz Harrosh 	u32		op_seqid;           /* request */
2299a74af21SBoaz Harrosh 	u32		op_share_access;    /* request */
2309a74af21SBoaz Harrosh 	u32		op_share_deny;      /* request */
2319a74af21SBoaz Harrosh 	stateid_t	op_stateid;         /* response */
2329a74af21SBoaz Harrosh 	u32		op_recall;          /* recall */
2339a74af21SBoaz Harrosh 	struct nfsd4_change_info  op_cinfo; /* response */
2349a74af21SBoaz Harrosh 	u32		op_rflags;          /* response */
2359a74af21SBoaz Harrosh 	int		op_truncate;        /* used during processing */
2369a74af21SBoaz Harrosh 	struct nfs4_stateowner *op_stateowner; /* used during processing */
2379a74af21SBoaz Harrosh 	struct nfs4_acl *op_acl;
2389a74af21SBoaz Harrosh };
2399a74af21SBoaz Harrosh #define op_iattr	iattr
2409a74af21SBoaz Harrosh #define op_verf		verf
2419a74af21SBoaz Harrosh 
2429a74af21SBoaz Harrosh struct nfsd4_open_confirm {
2439a74af21SBoaz Harrosh 	stateid_t	oc_req_stateid		/* request */;
2449a74af21SBoaz Harrosh 	u32		oc_seqid    		/* request */;
2459a74af21SBoaz Harrosh 	stateid_t	oc_resp_stateid		/* response */;
2469a74af21SBoaz Harrosh 	struct nfs4_stateowner * oc_stateowner;	/* response */
2479a74af21SBoaz Harrosh };
2489a74af21SBoaz Harrosh 
2499a74af21SBoaz Harrosh struct nfsd4_open_downgrade {
2509a74af21SBoaz Harrosh 	stateid_t       od_stateid;
2519a74af21SBoaz Harrosh 	u32             od_seqid;
2529a74af21SBoaz Harrosh 	u32             od_share_access;
2539a74af21SBoaz Harrosh 	u32             od_share_deny;
2549a74af21SBoaz Harrosh 	struct nfs4_stateowner *od_stateowner;
2559a74af21SBoaz Harrosh };
2569a74af21SBoaz Harrosh 
2579a74af21SBoaz Harrosh 
2589a74af21SBoaz Harrosh struct nfsd4_read {
2599a74af21SBoaz Harrosh 	stateid_t	rd_stateid;         /* request */
2609a74af21SBoaz Harrosh 	u64		rd_offset;          /* request */
2619a74af21SBoaz Harrosh 	u32		rd_length;          /* request */
2629a74af21SBoaz Harrosh 	int		rd_vlen;
2639a74af21SBoaz Harrosh 	struct file     *rd_filp;
2649a74af21SBoaz Harrosh 
2659a74af21SBoaz Harrosh 	struct svc_rqst *rd_rqstp;          /* response */
2669a74af21SBoaz Harrosh 	struct svc_fh * rd_fhp;             /* response */
2679a74af21SBoaz Harrosh };
2689a74af21SBoaz Harrosh 
2699a74af21SBoaz Harrosh struct nfsd4_readdir {
2709a74af21SBoaz Harrosh 	u64		rd_cookie;          /* request */
2719a74af21SBoaz Harrosh 	nfs4_verifier	rd_verf;            /* request */
2729a74af21SBoaz Harrosh 	u32		rd_dircount;        /* request */
2739a74af21SBoaz Harrosh 	u32		rd_maxcount;        /* request */
2749a74af21SBoaz Harrosh 	u32		rd_bmval[3];        /* request */
2759a74af21SBoaz Harrosh 	struct svc_rqst *rd_rqstp;          /* response */
2769a74af21SBoaz Harrosh 	struct svc_fh * rd_fhp;             /* response */
2779a74af21SBoaz Harrosh 
2789a74af21SBoaz Harrosh 	struct readdir_cd	common;
2799a74af21SBoaz Harrosh 	__be32 *		buffer;
2809a74af21SBoaz Harrosh 	int			buflen;
2819a74af21SBoaz Harrosh 	__be32 *		offset;
2829a74af21SBoaz Harrosh };
2839a74af21SBoaz Harrosh 
2849a74af21SBoaz Harrosh struct nfsd4_release_lockowner {
2859a74af21SBoaz Harrosh 	clientid_t        rl_clientid;
2869a74af21SBoaz Harrosh 	struct xdr_netobj rl_owner;
2879a74af21SBoaz Harrosh };
2889a74af21SBoaz Harrosh struct nfsd4_readlink {
2899a74af21SBoaz Harrosh 	struct svc_rqst *rl_rqstp;          /* request */
2909a74af21SBoaz Harrosh 	struct svc_fh *	rl_fhp;             /* request */
2919a74af21SBoaz Harrosh };
2929a74af21SBoaz Harrosh 
2939a74af21SBoaz Harrosh struct nfsd4_remove {
2949a74af21SBoaz Harrosh 	u32		rm_namelen;         /* request */
2959a74af21SBoaz Harrosh 	char *		rm_name;            /* request */
2969a74af21SBoaz Harrosh 	struct nfsd4_change_info  rm_cinfo; /* response */
2979a74af21SBoaz Harrosh };
2989a74af21SBoaz Harrosh 
2999a74af21SBoaz Harrosh struct nfsd4_rename {
3009a74af21SBoaz Harrosh 	u32		rn_snamelen;        /* request */
3019a74af21SBoaz Harrosh 	char *		rn_sname;           /* request */
3029a74af21SBoaz Harrosh 	u32		rn_tnamelen;        /* request */
3039a74af21SBoaz Harrosh 	char *		rn_tname;           /* request */
3049a74af21SBoaz Harrosh 	struct nfsd4_change_info  rn_sinfo; /* response */
3059a74af21SBoaz Harrosh 	struct nfsd4_change_info  rn_tinfo; /* response */
3069a74af21SBoaz Harrosh };
3079a74af21SBoaz Harrosh 
3089a74af21SBoaz Harrosh struct nfsd4_secinfo {
3099a74af21SBoaz Harrosh 	u32 si_namelen;					/* request */
3109a74af21SBoaz Harrosh 	char *si_name;					/* request */
3119a74af21SBoaz Harrosh 	struct svc_export *si_exp;			/* response */
3129a74af21SBoaz Harrosh };
3139a74af21SBoaz Harrosh 
31404f4ad16SJ. Bruce Fields struct nfsd4_secinfo_no_name {
31504f4ad16SJ. Bruce Fields 	u32 sin_style;					/* request */
31604f4ad16SJ. Bruce Fields 	struct svc_export *sin_exp;			/* response */
31704f4ad16SJ. Bruce Fields };
31804f4ad16SJ. Bruce Fields 
3199a74af21SBoaz Harrosh struct nfsd4_setattr {
3209a74af21SBoaz Harrosh 	stateid_t	sa_stateid;         /* request */
3219a74af21SBoaz Harrosh 	u32		sa_bmval[3];        /* request */
3229a74af21SBoaz Harrosh 	struct iattr	sa_iattr;           /* request */
3239a74af21SBoaz Harrosh 	struct nfs4_acl *sa_acl;
3249a74af21SBoaz Harrosh };
3259a74af21SBoaz Harrosh 
3269a74af21SBoaz Harrosh struct nfsd4_setclientid {
3279a74af21SBoaz Harrosh 	nfs4_verifier	se_verf;            /* request */
3289a74af21SBoaz Harrosh 	u32		se_namelen;         /* request */
3299a74af21SBoaz Harrosh 	char *		se_name;            /* request */
3309a74af21SBoaz Harrosh 	u32		se_callback_prog;   /* request */
3319a74af21SBoaz Harrosh 	u32		se_callback_netid_len;  /* request */
3329a74af21SBoaz Harrosh 	char *		se_callback_netid_val;  /* request */
3339a74af21SBoaz Harrosh 	u32		se_callback_addr_len;   /* request */
3349a74af21SBoaz Harrosh 	char *		se_callback_addr_val;   /* request */
3359a74af21SBoaz Harrosh 	u32		se_callback_ident;  /* request */
3369a74af21SBoaz Harrosh 	clientid_t	se_clientid;        /* response */
3379a74af21SBoaz Harrosh 	nfs4_verifier	se_confirm;         /* response */
3389a74af21SBoaz Harrosh };
3399a74af21SBoaz Harrosh 
3409a74af21SBoaz Harrosh struct nfsd4_setclientid_confirm {
3419a74af21SBoaz Harrosh 	clientid_t	sc_clientid;
3429a74af21SBoaz Harrosh 	nfs4_verifier	sc_confirm;
3439a74af21SBoaz Harrosh };
3449a74af21SBoaz Harrosh 
3459a74af21SBoaz Harrosh /* also used for NVERIFY */
3469a74af21SBoaz Harrosh struct nfsd4_verify {
3479a74af21SBoaz Harrosh 	u32		ve_bmval[3];        /* request */
3489a74af21SBoaz Harrosh 	u32		ve_attrlen;         /* request */
3499a74af21SBoaz Harrosh 	char *		ve_attrval;         /* request */
3509a74af21SBoaz Harrosh };
3519a74af21SBoaz Harrosh 
3529a74af21SBoaz Harrosh struct nfsd4_write {
3539a74af21SBoaz Harrosh 	stateid_t	wr_stateid;         /* request */
3549a74af21SBoaz Harrosh 	u64		wr_offset;          /* request */
3559a74af21SBoaz Harrosh 	u32		wr_stable_how;      /* request */
3569a74af21SBoaz Harrosh 	u32		wr_buflen;          /* request */
3579a74af21SBoaz Harrosh 	int		wr_vlen;
3589a74af21SBoaz Harrosh 
3599a74af21SBoaz Harrosh 	u32		wr_bytes_written;   /* response */
3609a74af21SBoaz Harrosh 	u32		wr_how_written;     /* response */
3619a74af21SBoaz Harrosh 	nfs4_verifier	wr_verifier;        /* response */
3629a74af21SBoaz Harrosh };
3639a74af21SBoaz Harrosh 
3649a74af21SBoaz Harrosh struct nfsd4_exchange_id {
3659a74af21SBoaz Harrosh 	nfs4_verifier	verifier;
3669a74af21SBoaz Harrosh 	struct xdr_netobj clname;
3679a74af21SBoaz Harrosh 	u32		flags;
3689a74af21SBoaz Harrosh 	clientid_t	clientid;
3699a74af21SBoaz Harrosh 	u32		seqid;
3709a74af21SBoaz Harrosh 	int		spa_how;
3719a74af21SBoaz Harrosh };
3729a74af21SBoaz Harrosh 
3739a74af21SBoaz Harrosh struct nfsd4_sequence {
3749a74af21SBoaz Harrosh 	struct nfs4_sessionid	sessionid;		/* request/response */
3759a74af21SBoaz Harrosh 	u32			seqid;			/* request/response */
3769a74af21SBoaz Harrosh 	u32			slotid;			/* request/response */
3779a74af21SBoaz Harrosh 	u32			maxslots;		/* request/response */
3789a74af21SBoaz Harrosh 	u32			cachethis;		/* request */
3799a74af21SBoaz Harrosh #if 0
3809a74af21SBoaz Harrosh 	u32			target_maxslots;	/* response */
3819a74af21SBoaz Harrosh 	u32			status_flags;		/* response */
3829a74af21SBoaz Harrosh #endif /* not yet */
3839a74af21SBoaz Harrosh };
3849a74af21SBoaz Harrosh 
3859a74af21SBoaz Harrosh struct nfsd4_destroy_session {
3869a74af21SBoaz Harrosh 	struct nfs4_sessionid	sessionid;
3879a74af21SBoaz Harrosh };
3889a74af21SBoaz Harrosh 
3894dc6ec00SJ. Bruce Fields struct nfsd4_reclaim_complete {
3904dc6ec00SJ. Bruce Fields 	u32 rca_one_fs;
3914dc6ec00SJ. Bruce Fields };
3924dc6ec00SJ. Bruce Fields 
3939a74af21SBoaz Harrosh struct nfsd4_op {
3949a74af21SBoaz Harrosh 	int					opnum;
3959a74af21SBoaz Harrosh 	__be32					status;
3969a74af21SBoaz Harrosh 	union {
3979a74af21SBoaz Harrosh 		struct nfsd4_access		access;
3989a74af21SBoaz Harrosh 		struct nfsd4_close		close;
3999a74af21SBoaz Harrosh 		struct nfsd4_commit		commit;
4009a74af21SBoaz Harrosh 		struct nfsd4_create		create;
4019a74af21SBoaz Harrosh 		struct nfsd4_delegreturn	delegreturn;
4029a74af21SBoaz Harrosh 		struct nfsd4_getattr		getattr;
4039a74af21SBoaz Harrosh 		struct svc_fh *			getfh;
4049a74af21SBoaz Harrosh 		struct nfsd4_link		link;
4059a74af21SBoaz Harrosh 		struct nfsd4_lock		lock;
4069a74af21SBoaz Harrosh 		struct nfsd4_lockt		lockt;
4079a74af21SBoaz Harrosh 		struct nfsd4_locku		locku;
4089a74af21SBoaz Harrosh 		struct nfsd4_lookup		lookup;
4099a74af21SBoaz Harrosh 		struct nfsd4_verify		nverify;
4109a74af21SBoaz Harrosh 		struct nfsd4_open		open;
4119a74af21SBoaz Harrosh 		struct nfsd4_open_confirm	open_confirm;
4129a74af21SBoaz Harrosh 		struct nfsd4_open_downgrade	open_downgrade;
4139a74af21SBoaz Harrosh 		struct nfsd4_putfh		putfh;
4149a74af21SBoaz Harrosh 		struct nfsd4_read		read;
4159a74af21SBoaz Harrosh 		struct nfsd4_readdir		readdir;
4169a74af21SBoaz Harrosh 		struct nfsd4_readlink		readlink;
4179a74af21SBoaz Harrosh 		struct nfsd4_remove		remove;
4189a74af21SBoaz Harrosh 		struct nfsd4_rename		rename;
4199a74af21SBoaz Harrosh 		clientid_t			renew;
4209a74af21SBoaz Harrosh 		struct nfsd4_secinfo		secinfo;
4219a74af21SBoaz Harrosh 		struct nfsd4_setattr		setattr;
4229a74af21SBoaz Harrosh 		struct nfsd4_setclientid	setclientid;
4239a74af21SBoaz Harrosh 		struct nfsd4_setclientid_confirm setclientid_confirm;
4249a74af21SBoaz Harrosh 		struct nfsd4_verify		verify;
4259a74af21SBoaz Harrosh 		struct nfsd4_write		write;
4269a74af21SBoaz Harrosh 		struct nfsd4_release_lockowner	release_lockowner;
4279a74af21SBoaz Harrosh 
4289a74af21SBoaz Harrosh 		/* NFSv4.1 */
4299a74af21SBoaz Harrosh 		struct nfsd4_exchange_id	exchange_id;
4301d1bc8f2SJ. Bruce Fields 		struct nfsd4_bind_conn_to_session bind_conn_to_session;
4319a74af21SBoaz Harrosh 		struct nfsd4_create_session	create_session;
4329a74af21SBoaz Harrosh 		struct nfsd4_destroy_session	destroy_session;
4339a74af21SBoaz Harrosh 		struct nfsd4_sequence		sequence;
4344dc6ec00SJ. Bruce Fields 		struct nfsd4_reclaim_complete	reclaim_complete;
4359a74af21SBoaz Harrosh 	} u;
4369a74af21SBoaz Harrosh 	struct nfs4_replay *			replay;
4379a74af21SBoaz Harrosh };
4389a74af21SBoaz Harrosh 
4399a74af21SBoaz Harrosh struct nfsd4_compoundargs {
4409a74af21SBoaz Harrosh 	/* scratch variables for XDR decode */
4419a74af21SBoaz Harrosh 	__be32 *			p;
4429a74af21SBoaz Harrosh 	__be32 *			end;
4439a74af21SBoaz Harrosh 	struct page **			pagelist;
4449a74af21SBoaz Harrosh 	int				pagelen;
4459a74af21SBoaz Harrosh 	__be32				tmp[8];
4469a74af21SBoaz Harrosh 	__be32 *			tmpp;
4479a74af21SBoaz Harrosh 	struct tmpbuf {
4489a74af21SBoaz Harrosh 		struct tmpbuf *next;
4499a74af21SBoaz Harrosh 		void (*release)(const void *);
4509a74af21SBoaz Harrosh 		void *buf;
4519a74af21SBoaz Harrosh 	}				*to_free;
4529a74af21SBoaz Harrosh 
4539a74af21SBoaz Harrosh 	struct svc_rqst			*rqstp;
4549a74af21SBoaz Harrosh 
4559a74af21SBoaz Harrosh 	u32				taglen;
4569a74af21SBoaz Harrosh 	char *				tag;
4579a74af21SBoaz Harrosh 	u32				minorversion;
4589a74af21SBoaz Harrosh 	u32				opcnt;
4599a74af21SBoaz Harrosh 	struct nfsd4_op			*ops;
4609a74af21SBoaz Harrosh 	struct nfsd4_op			iops[8];
4619a74af21SBoaz Harrosh };
4629a74af21SBoaz Harrosh 
4639a74af21SBoaz Harrosh struct nfsd4_compoundres {
4649a74af21SBoaz Harrosh 	/* scratch variables for XDR encode */
4659a74af21SBoaz Harrosh 	__be32 *			p;
4669a74af21SBoaz Harrosh 	__be32 *			end;
4679a74af21SBoaz Harrosh 	struct xdr_buf *		xbuf;
4689a74af21SBoaz Harrosh 	struct svc_rqst *		rqstp;
4699a74af21SBoaz Harrosh 
4709a74af21SBoaz Harrosh 	u32				taglen;
4719a74af21SBoaz Harrosh 	char *				tag;
4729a74af21SBoaz Harrosh 	u32				opcnt;
4739a74af21SBoaz Harrosh 	__be32 *			tagp; /* tag, opcount encode location */
4749a74af21SBoaz Harrosh 	struct nfsd4_compound_state	cstate;
4759a74af21SBoaz Harrosh };
4769a74af21SBoaz Harrosh 
4779a74af21SBoaz Harrosh static inline bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp)
4789a74af21SBoaz Harrosh {
4799a74af21SBoaz Harrosh 	struct nfsd4_compoundargs *args = resp->rqstp->rq_argp;
4809a74af21SBoaz Harrosh 	return resp->opcnt == 1 && args->ops[0].opnum == OP_SEQUENCE;
4819a74af21SBoaz Harrosh }
4829a74af21SBoaz Harrosh 
4839a74af21SBoaz Harrosh static inline bool nfsd4_not_cached(struct nfsd4_compoundres *resp)
4849a74af21SBoaz Harrosh {
4859a74af21SBoaz Harrosh 	return !resp->cstate.slot->sl_cachethis || nfsd4_is_solo_sequence(resp);
4869a74af21SBoaz Harrosh }
4879a74af21SBoaz Harrosh 
4889a74af21SBoaz Harrosh #define NFS4_SVC_XDRSIZE		sizeof(struct nfsd4_compoundargs)
4899a74af21SBoaz Harrosh 
4909a74af21SBoaz Harrosh static inline void
4919a74af21SBoaz Harrosh set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
4929a74af21SBoaz Harrosh {
493c1ac3ffcSNeil Brown 	BUG_ON(!fhp->fh_pre_saved);
494c1ac3ffcSNeil Brown 	cinfo->atomic = fhp->fh_post_saved;
4959a74af21SBoaz Harrosh 	cinfo->change_supported = IS_I_VERSION(fhp->fh_dentry->d_inode);
496c1ac3ffcSNeil Brown 
4979a74af21SBoaz Harrosh 	cinfo->before_change = fhp->fh_pre_change;
4989a74af21SBoaz Harrosh 	cinfo->after_change = fhp->fh_post_change;
4999a74af21SBoaz Harrosh 	cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
5009a74af21SBoaz Harrosh 	cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
5019a74af21SBoaz Harrosh 	cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
5029a74af21SBoaz Harrosh 	cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
503c1ac3ffcSNeil Brown 
5049a74af21SBoaz Harrosh }
5059a74af21SBoaz Harrosh 
5069a74af21SBoaz Harrosh int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
5079a74af21SBoaz Harrosh int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *,
5089a74af21SBoaz Harrosh 		struct nfsd4_compoundargs *);
5099a74af21SBoaz Harrosh int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *,
5109a74af21SBoaz Harrosh 		struct nfsd4_compoundres *);
5119a74af21SBoaz Harrosh void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
5129a74af21SBoaz Harrosh void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
5139a74af21SBoaz Harrosh __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
5149a74af21SBoaz Harrosh 		       struct dentry *dentry, __be32 *buffer, int *countp,
5159a74af21SBoaz Harrosh 		       u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
5169a74af21SBoaz Harrosh extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
5179a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5189a74af21SBoaz Harrosh 		struct nfsd4_setclientid *setclid);
5199a74af21SBoaz Harrosh extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
5209a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5219a74af21SBoaz Harrosh 		struct nfsd4_setclientid_confirm *setclientid_confirm);
5229a74af21SBoaz Harrosh extern void nfsd4_store_cache_entry(struct nfsd4_compoundres *resp);
5239a74af21SBoaz Harrosh extern __be32 nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp,
5249a74af21SBoaz Harrosh 		struct nfsd4_sequence *seq);
5259a74af21SBoaz Harrosh extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
5263c4ab2aaSJ. Bruce Fields 		struct nfsd4_compound_state *, struct nfsd4_exchange_id *);
5271d1bc8f2SJ. Bruce Fields extern __be32 nfsd4_bind_conn_to_session(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_bind_conn_to_session *);
5289a74af21SBoaz Harrosh extern __be32 nfsd4_create_session(struct svc_rqst *,
5299a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5309a74af21SBoaz Harrosh 		struct nfsd4_create_session *);
5319a74af21SBoaz Harrosh extern __be32 nfsd4_sequence(struct svc_rqst *,
5329a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5339a74af21SBoaz Harrosh 		struct nfsd4_sequence *);
5349a74af21SBoaz Harrosh extern __be32 nfsd4_destroy_session(struct svc_rqst *,
5359a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5369a74af21SBoaz Harrosh 		struct nfsd4_destroy_session *);
5374dc6ec00SJ. Bruce Fields __be32 nfsd4_reclaim_complete(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_reclaim_complete *);
5389a74af21SBoaz Harrosh extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *,
5399a74af21SBoaz Harrosh 		struct nfsd4_open *open);
5409a74af21SBoaz Harrosh extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
5419a74af21SBoaz Harrosh 		struct svc_fh *current_fh, struct nfsd4_open *open);
5429a74af21SBoaz Harrosh extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
5439a74af21SBoaz Harrosh 		struct nfsd4_compound_state *, struct nfsd4_open_confirm *oc);
5449a74af21SBoaz Harrosh extern __be32 nfsd4_close(struct svc_rqst *rqstp,
5459a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5469a74af21SBoaz Harrosh 		struct nfsd4_close *close);
5479a74af21SBoaz Harrosh extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
5489a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5499a74af21SBoaz Harrosh 		struct nfsd4_open_downgrade *od);
5509a74af21SBoaz Harrosh extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
5519a74af21SBoaz Harrosh 		struct nfsd4_lock *lock);
5529a74af21SBoaz Harrosh extern __be32 nfsd4_lockt(struct svc_rqst *rqstp,
5539a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5549a74af21SBoaz Harrosh 		struct nfsd4_lockt *lockt);
5559a74af21SBoaz Harrosh extern __be32 nfsd4_locku(struct svc_rqst *rqstp,
5569a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5579a74af21SBoaz Harrosh 		struct nfsd4_locku *locku);
5589a74af21SBoaz Harrosh extern __be32
5599a74af21SBoaz Harrosh nfsd4_release_lockowner(struct svc_rqst *rqstp,
5609a74af21SBoaz Harrosh 		struct nfsd4_compound_state *,
5619a74af21SBoaz Harrosh 		struct nfsd4_release_lockowner *rlockowner);
5629a74af21SBoaz Harrosh extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *);
5639a74af21SBoaz Harrosh extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
5649a74af21SBoaz Harrosh 		struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr);
5659a74af21SBoaz Harrosh extern __be32 nfsd4_renew(struct svc_rqst *rqstp,
5669a74af21SBoaz Harrosh 			  struct nfsd4_compound_state *, clientid_t *clid);
5679a74af21SBoaz Harrosh #endif
5689a74af21SBoaz Harrosh 
5699a74af21SBoaz Harrosh /*
5709a74af21SBoaz Harrosh  * Local variables:
5719a74af21SBoaz Harrosh  *  c-basic-offset: 8
5729a74af21SBoaz Harrosh  * End:
5739a74af21SBoaz Harrosh  */
574