xref: /linux/fs/nfsd/xdr4.h (revision aadc3bbea163b6caaaebfdd2b6c4667fbc726752)
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 
4951100d2bSOlga Kornievskaia #define SET_CSTATE_FLAG(c, f) ((c)->sid_flags |= (f))
5051100d2bSOlga Kornievskaia #define HAS_CSTATE_FLAG(c, f) ((c)->sid_flags & (f))
5151100d2bSOlga Kornievskaia #define CLEAR_CSTATE_FLAG(c, f) ((c)->sid_flags &= ~(f))
5237c593c5STigran Mkrtchyan 
536cc58291SChuck Lever /**
546cc58291SChuck Lever  * nfsd4_encode_bool - Encode an XDR bool type result
556cc58291SChuck Lever  * @xdr: target XDR stream
566cc58291SChuck Lever  * @val: boolean value to encode
576cc58291SChuck Lever  *
586cc58291SChuck Lever  * Return values:
596cc58291SChuck Lever  *    %nfs_ok: @val encoded; @xdr advanced to next position
606cc58291SChuck Lever  *    %nfserr_resource: stream buffer space exhausted
616cc58291SChuck Lever  */
626cc58291SChuck Lever static __always_inline __be32
636cc58291SChuck Lever nfsd4_encode_bool(struct xdr_stream *xdr, bool val)
646cc58291SChuck Lever {
656cc58291SChuck Lever 	__be32 *p = xdr_reserve_space(xdr, XDR_UNIT);
666cc58291SChuck Lever 
676cc58291SChuck Lever 	if (unlikely(p == NULL))
686cc58291SChuck Lever 		return nfserr_resource;
696cc58291SChuck Lever 	*p = val ? xdr_one : xdr_zero;
706cc58291SChuck Lever 	return nfs_ok;
716cc58291SChuck Lever }
726cc58291SChuck Lever 
736cc58291SChuck Lever /**
746cc58291SChuck Lever  * nfsd4_encode_uint32_t - Encode an XDR uint32_t type result
756cc58291SChuck Lever  * @xdr: target XDR stream
766cc58291SChuck Lever  * @val: integer value to encode
776cc58291SChuck Lever  *
786cc58291SChuck Lever  * Return values:
796cc58291SChuck Lever  *    %nfs_ok: @val encoded; @xdr advanced to next position
806cc58291SChuck Lever  *    %nfserr_resource: stream buffer space exhausted
816cc58291SChuck Lever  */
826cc58291SChuck Lever static __always_inline __be32
836cc58291SChuck Lever nfsd4_encode_uint32_t(struct xdr_stream *xdr, u32 val)
846cc58291SChuck Lever {
856cc58291SChuck Lever 	__be32 *p = xdr_reserve_space(xdr, XDR_UNIT);
866cc58291SChuck Lever 
876cc58291SChuck Lever 	if (unlikely(p == NULL))
886cc58291SChuck Lever 		return nfserr_resource;
896cc58291SChuck Lever 	*p = cpu_to_be32(val);
906cc58291SChuck Lever 	return nfs_ok;
916cc58291SChuck Lever }
926cc58291SChuck Lever 
930207ee08SChuck Lever #define nfsd4_encode_aceflag4(x, v)	nfsd4_encode_uint32_t(x, v)
940207ee08SChuck Lever #define nfsd4_encode_acemask4(x, v)	nfsd4_encode_uint32_t(x, v)
950207ee08SChuck Lever #define nfsd4_encode_acetype4(x, v)	nfsd4_encode_uint32_t(x, v)
9676bebcc7SChuck Lever #define nfsd4_encode_count4(x, v)	nfsd4_encode_uint32_t(x, v)
97f4cf5042SChuck Lever #define nfsd4_encode_mode4(x, v)	nfsd4_encode_uint32_t(x, v)
981252b283SChuck Lever #define nfsd4_encode_nfs_lease4(x, v)	nfsd4_encode_uint32_t(x, v)
9991c7a905SChuck Lever #define nfsd4_encode_qop4(x, v)		nfsd4_encode_uint32_t(x, v)
100b0c1b1baSChuck Lever #define nfsd4_encode_sequenceid4(x, v)	nfsd4_encode_uint32_t(x, v)
1016621b88bSChuck Lever #define nfsd4_encode_slotid4(x, v)	nfsd4_encode_uint32_t(x, v)
1021252b283SChuck Lever 
1036cc58291SChuck Lever /**
1046cc58291SChuck Lever  * nfsd4_encode_uint64_t - Encode an XDR uint64_t type result
1056cc58291SChuck Lever  * @xdr: target XDR stream
1066cc58291SChuck Lever  * @val: integer value to encode
1076cc58291SChuck Lever  *
1086cc58291SChuck Lever  * Return values:
1096cc58291SChuck Lever  *    %nfs_ok: @val encoded; @xdr advanced to next position
1106cc58291SChuck Lever  *    %nfserr_resource: stream buffer space exhausted
1116cc58291SChuck Lever  */
1126cc58291SChuck Lever static __always_inline __be32
1136cc58291SChuck Lever nfsd4_encode_uint64_t(struct xdr_stream *xdr, u64 val)
1146cc58291SChuck Lever {
1156cc58291SChuck Lever 	__be32 *p = xdr_reserve_space(xdr, XDR_UNIT * 2);
1166cc58291SChuck Lever 
1176cc58291SChuck Lever 	if (unlikely(p == NULL))
1186cc58291SChuck Lever 		return nfserr_resource;
1196cc58291SChuck Lever 	put_unaligned_be64(val, p);
1206cc58291SChuck Lever 	return nfs_ok;
1216cc58291SChuck Lever }
1226cc58291SChuck Lever 
123263453d9SChuck Lever #define nfsd4_encode_changeid4(x, v)	nfsd4_encode_uint64_t(x, v)
124a1aee9aaSChuck Lever #define nfsd4_encode_nfs_cookie4(x, v)	nfsd4_encode_uint64_t(x, v)
12569f5f019SChuck Lever #define nfsd4_encode_length4(x, v)	nfsd4_encode_uint64_t(x, v)
12669f5f019SChuck Lever #define nfsd4_encode_offset4(x, v)	nfsd4_encode_uint64_t(x, v)
127263453d9SChuck Lever 
1286cc58291SChuck Lever /**
1296cc58291SChuck Lever  * nfsd4_encode_opaque_fixed - Encode a fixed-length XDR opaque type result
1306cc58291SChuck Lever  * @xdr: target XDR stream
1316cc58291SChuck Lever  * @data: pointer to data
1326cc58291SChuck Lever  * @size: length of data in bytes
1336cc58291SChuck Lever  *
1346cc58291SChuck Lever  * Return values:
1356cc58291SChuck Lever  *    %nfs_ok: @data encoded; @xdr advanced to next position
1366cc58291SChuck Lever  *    %nfserr_resource: stream buffer space exhausted
1376cc58291SChuck Lever  */
1386cc58291SChuck Lever static __always_inline __be32
1396cc58291SChuck Lever nfsd4_encode_opaque_fixed(struct xdr_stream *xdr, const void *data,
1406cc58291SChuck Lever 			  size_t size)
1416cc58291SChuck Lever {
1426cc58291SChuck Lever 	__be32 *p = xdr_reserve_space(xdr, xdr_align_size(size));
1436cc58291SChuck Lever 	size_t pad = xdr_pad_size(size);
1446cc58291SChuck Lever 
1456cc58291SChuck Lever 	if (unlikely(p == NULL))
1466cc58291SChuck Lever 		return nfserr_resource;
1476cc58291SChuck Lever 	memcpy(p, data, size);
1486cc58291SChuck Lever 	if (pad)
1496cc58291SChuck Lever 		memset((char *)p + size, 0, pad);
1506cc58291SChuck Lever 	return nfs_ok;
1516cc58291SChuck Lever }
1526cc58291SChuck Lever 
1536cc58291SChuck Lever /**
1546cc58291SChuck Lever  * nfsd4_encode_opaque - Encode a variable-length XDR opaque type result
1556cc58291SChuck Lever  * @xdr: target XDR stream
1566cc58291SChuck Lever  * @data: pointer to data
1576cc58291SChuck Lever  * @size: length of data in bytes
1586cc58291SChuck Lever  *
1596cc58291SChuck Lever  * Return values:
1606cc58291SChuck Lever  *    %nfs_ok: @data encoded; @xdr advanced to next position
1616cc58291SChuck Lever  *    %nfserr_resource: stream buffer space exhausted
1626cc58291SChuck Lever  */
1636cc58291SChuck Lever static __always_inline __be32
1646cc58291SChuck Lever nfsd4_encode_opaque(struct xdr_stream *xdr, const void *data, size_t size)
1656cc58291SChuck Lever {
1666cc58291SChuck Lever 	size_t pad = xdr_pad_size(size);
1676cc58291SChuck Lever 	__be32 *p;
1686cc58291SChuck Lever 
1696cc58291SChuck Lever 	p = xdr_reserve_space(xdr, XDR_UNIT + xdr_align_size(size));
1706cc58291SChuck Lever 	if (unlikely(p == NULL))
1716cc58291SChuck Lever 		return nfserr_resource;
1726cc58291SChuck Lever 	*p++ = cpu_to_be32(size);
1736cc58291SChuck Lever 	memcpy(p, data, size);
1746cc58291SChuck Lever 	if (pad)
1756cc58291SChuck Lever 		memset((char *)p + size, 0, pad);
1766cc58291SChuck Lever 	return nfs_ok;
1776cc58291SChuck Lever }
1786cc58291SChuck Lever 
179a1aee9aaSChuck Lever #define nfsd4_encode_component4(x, d, s)	nfsd4_encode_opaque(x, d, s)
180a1aee9aaSChuck Lever 
1819a74af21SBoaz Harrosh struct nfsd4_compound_state {
1829a74af21SBoaz Harrosh 	struct svc_fh		current_fh;
1839a74af21SBoaz Harrosh 	struct svc_fh		save_fh;
1849a74af21SBoaz Harrosh 	struct nfs4_stateowner	*replay_owner;
1854b24ca7dSJeff Layton 	struct nfs4_client	*clp;
1869a74af21SBoaz Harrosh 	/* For sessions DRC */
1879a74af21SBoaz Harrosh 	struct nfsd4_session	*session;
1889a74af21SBoaz Harrosh 	struct nfsd4_slot	*slot;
189f5236013SJ. Bruce Fields 	int			data_offset;
190ed941643SAndrew Elble 	bool                    spo_must_allowed;
1919a74af21SBoaz Harrosh 	size_t			iovlen;
1929a74af21SBoaz Harrosh 	u32			minorversion;
19357b7b43bSJ. Bruce Fields 	__be32			status;
19437c593c5STigran Mkrtchyan 	stateid_t	current_stateid;
19537c593c5STigran Mkrtchyan 	stateid_t	save_stateid;
19637c593c5STigran Mkrtchyan 	/* to indicate current and saved state id presents */
19737c593c5STigran Mkrtchyan 	u32		sid_flags;
1989a74af21SBoaz Harrosh };
1999a74af21SBoaz Harrosh 
2009a74af21SBoaz Harrosh static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs)
2019a74af21SBoaz Harrosh {
2029a74af21SBoaz Harrosh 	return cs->slot != NULL;
2039a74af21SBoaz Harrosh }
2049a74af21SBoaz Harrosh 
2059a74af21SBoaz Harrosh struct nfsd4_change_info {
2069a74af21SBoaz Harrosh 	u32		atomic;
2079a74af21SBoaz Harrosh 	u64		before_change;
2089a74af21SBoaz Harrosh 	u64		after_change;
2099a74af21SBoaz Harrosh };
2109a74af21SBoaz Harrosh 
2119a74af21SBoaz Harrosh struct nfsd4_access {
2129a74af21SBoaz Harrosh 	u32		ac_req_access;      /* request */
2139a74af21SBoaz Harrosh 	u32		ac_supported;       /* response */
2149a74af21SBoaz Harrosh 	u32		ac_resp_access;     /* response */
2159a74af21SBoaz Harrosh };
2169a74af21SBoaz Harrosh 
2179a74af21SBoaz Harrosh struct nfsd4_close {
2189a74af21SBoaz Harrosh 	u32		cl_seqid;           /* request */
2199a74af21SBoaz Harrosh 	stateid_t	cl_stateid;         /* request+response */
2209a74af21SBoaz Harrosh };
2219a74af21SBoaz Harrosh 
2229a74af21SBoaz Harrosh struct nfsd4_commit {
2239a74af21SBoaz Harrosh 	u64		co_offset;          /* request */
2249a74af21SBoaz Harrosh 	u32		co_count;           /* request */
2259a74af21SBoaz Harrosh 	nfs4_verifier	co_verf;            /* response */
2269a74af21SBoaz Harrosh };
2279a74af21SBoaz Harrosh 
2289a74af21SBoaz Harrosh struct nfsd4_create {
2299a74af21SBoaz Harrosh 	u32		cr_namelen;         /* request */
2309a74af21SBoaz Harrosh 	char *		cr_name;            /* request */
2319a74af21SBoaz Harrosh 	u32		cr_type;            /* request */
2329a74af21SBoaz Harrosh 	union {                             /* request */
2339a74af21SBoaz Harrosh 		struct {
2347fb84306SJ. Bruce Fields 			u32 datalen;
2357fb84306SJ. Bruce Fields 			char *data;
23638a70315SChuck Lever 			struct kvec first;
2379a74af21SBoaz Harrosh 		} link;   /* NF4LNK */
2389a74af21SBoaz Harrosh 		struct {
2399a74af21SBoaz Harrosh 			u32 specdata1;
2409a74af21SBoaz Harrosh 			u32 specdata2;
2419a74af21SBoaz Harrosh 		} dev;    /* NF4BLK, NF4CHR */
2429a74af21SBoaz Harrosh 	} u;
2439a74af21SBoaz Harrosh 	u32		cr_bmval[3];        /* request */
2449a74af21SBoaz Harrosh 	struct iattr	cr_iattr;           /* request */
245880a3a53SJ. Bruce Fields 	int		cr_umask;           /* request */
2469a74af21SBoaz Harrosh 	struct nfsd4_change_info  cr_cinfo; /* response */
2479a74af21SBoaz Harrosh 	struct nfs4_acl *cr_acl;
24818032ca0SDavid Quigley 	struct xdr_netobj cr_label;
2499a74af21SBoaz Harrosh };
2507fb84306SJ. Bruce Fields #define cr_datalen	u.link.datalen
2517fb84306SJ. Bruce Fields #define cr_data		u.link.data
25238a70315SChuck Lever #define cr_first	u.link.first
2539a74af21SBoaz Harrosh #define cr_specdata1	u.dev.specdata1
2549a74af21SBoaz Harrosh #define cr_specdata2	u.dev.specdata2
2559a74af21SBoaz Harrosh 
2569a74af21SBoaz Harrosh struct nfsd4_delegreturn {
2579a74af21SBoaz Harrosh 	stateid_t	dr_stateid;
2589a74af21SBoaz Harrosh };
2599a74af21SBoaz Harrosh 
2609a74af21SBoaz Harrosh struct nfsd4_getattr {
2619a74af21SBoaz Harrosh 	u32		ga_bmval[3];        /* request */
2629a74af21SBoaz Harrosh 	struct svc_fh	*ga_fhp;            /* response */
2639a74af21SBoaz Harrosh };
2649a74af21SBoaz Harrosh 
2659a74af21SBoaz Harrosh struct nfsd4_link {
2669a74af21SBoaz Harrosh 	u32		li_namelen;         /* request */
2679a74af21SBoaz Harrosh 	char *		li_name;            /* request */
2689a74af21SBoaz Harrosh 	struct nfsd4_change_info  li_cinfo; /* response */
2699a74af21SBoaz Harrosh };
2709a74af21SBoaz Harrosh 
2719a74af21SBoaz Harrosh struct nfsd4_lock_denied {
2729a74af21SBoaz Harrosh 	clientid_t	ld_clientid;
2737c13f344SJ. Bruce Fields 	struct xdr_netobj	ld_owner;
2749a74af21SBoaz Harrosh 	u64             ld_start;
2759a74af21SBoaz Harrosh 	u64             ld_length;
2769a74af21SBoaz Harrosh 	u32             ld_type;
2779a74af21SBoaz Harrosh };
2789a74af21SBoaz Harrosh 
2799a74af21SBoaz Harrosh struct nfsd4_lock {
2809a74af21SBoaz Harrosh 	/* request */
2819a74af21SBoaz Harrosh 	u32             lk_type;
2829a74af21SBoaz Harrosh 	u32             lk_reclaim;         /* boolean */
2839a74af21SBoaz Harrosh 	u64             lk_offset;
2849a74af21SBoaz Harrosh 	u64             lk_length;
2859a74af21SBoaz Harrosh 	u32             lk_is_new;
2869a74af21SBoaz Harrosh 	union {
2879a74af21SBoaz Harrosh 		struct {
2889a74af21SBoaz Harrosh 			u32             open_seqid;
2899a74af21SBoaz Harrosh 			stateid_t       open_stateid;
2909a74af21SBoaz Harrosh 			u32             lock_seqid;
2919a74af21SBoaz Harrosh 			clientid_t      clientid;
2929a74af21SBoaz Harrosh 			struct xdr_netobj owner;
2939a74af21SBoaz Harrosh 		} new;
2949a74af21SBoaz Harrosh 		struct {
2959a74af21SBoaz Harrosh 			stateid_t       lock_stateid;
2969a74af21SBoaz Harrosh 			u32             lock_seqid;
2979a74af21SBoaz Harrosh 		} old;
2989a74af21SBoaz Harrosh 	} v;
2999a74af21SBoaz Harrosh 
3009a74af21SBoaz Harrosh 	/* response */
30192d82e99SChuck Lever 	stateid_t			lk_resp_stateid;
30292d82e99SChuck Lever 	struct nfsd4_lock_denied        lk_denied;
3039a74af21SBoaz Harrosh };
3049a74af21SBoaz Harrosh #define lk_new_open_seqid       v.new.open_seqid
3059a74af21SBoaz Harrosh #define lk_new_open_stateid     v.new.open_stateid
3069a74af21SBoaz Harrosh #define lk_new_lock_seqid       v.new.lock_seqid
3079a74af21SBoaz Harrosh #define lk_new_clientid         v.new.clientid
3089a74af21SBoaz Harrosh #define lk_new_owner            v.new.owner
3099a74af21SBoaz Harrosh #define lk_old_lock_stateid     v.old.lock_stateid
3109a74af21SBoaz Harrosh #define lk_old_lock_seqid       v.old.lock_seqid
3119a74af21SBoaz Harrosh 
3129a74af21SBoaz Harrosh struct nfsd4_lockt {
3139a74af21SBoaz Harrosh 	u32				lt_type;
3149a74af21SBoaz Harrosh 	clientid_t			lt_clientid;
3159a74af21SBoaz Harrosh 	struct xdr_netobj		lt_owner;
3169a74af21SBoaz Harrosh 	u64				lt_offset;
3179a74af21SBoaz Harrosh 	u64				lt_length;
3189a74af21SBoaz Harrosh 	struct nfsd4_lock_denied	lt_denied;
3199a74af21SBoaz Harrosh };
3209a74af21SBoaz Harrosh 
3219a74af21SBoaz Harrosh struct nfsd4_locku {
3229a74af21SBoaz Harrosh 	u32             lu_type;
3239a74af21SBoaz Harrosh 	u32             lu_seqid;
3249a74af21SBoaz Harrosh 	stateid_t       lu_stateid;
3259a74af21SBoaz Harrosh 	u64             lu_offset;
3269a74af21SBoaz Harrosh 	u64             lu_length;
3279a74af21SBoaz Harrosh };
3289a74af21SBoaz Harrosh 
3299a74af21SBoaz Harrosh 
3309a74af21SBoaz Harrosh struct nfsd4_lookup {
3319a74af21SBoaz Harrosh 	u32		lo_len;             /* request */
3329a74af21SBoaz Harrosh 	char *		lo_name;            /* request */
3339a74af21SBoaz Harrosh };
3349a74af21SBoaz Harrosh 
3359a74af21SBoaz Harrosh struct nfsd4_putfh {
3369a74af21SBoaz Harrosh 	u32		pf_fhlen;           /* request */
3379a74af21SBoaz Harrosh 	char		*pf_fhval;          /* request */
338b9e8638eSOlga Kornievskaia 	bool		no_verify;	    /* represents foreigh fh */
3399a74af21SBoaz Harrosh };
3409a74af21SBoaz Harrosh 
3416178713bSFrank van der Linden struct nfsd4_getxattr {
3426178713bSFrank van der Linden 	char		*getxa_name;		/* request */
3436178713bSFrank van der Linden 	u32		getxa_len;		/* request */
3446178713bSFrank van der Linden 	void		*getxa_buf;
3456178713bSFrank van der Linden };
3466178713bSFrank van der Linden 
3476178713bSFrank van der Linden struct nfsd4_setxattr {
3486178713bSFrank van der Linden 	u32		setxa_flags;		/* request */
3496178713bSFrank van der Linden 	char		*setxa_name;		/* request */
3506178713bSFrank van der Linden 	char		*setxa_buf;		/* request */
3516178713bSFrank van der Linden 	u32		setxa_len;		/* request */
3526178713bSFrank van der Linden 	struct nfsd4_change_info  setxa_cinfo;	/* response */
3536178713bSFrank van der Linden };
3546178713bSFrank van der Linden 
3556178713bSFrank van der Linden struct nfsd4_removexattr {
3566178713bSFrank van der Linden 	char		*rmxa_name;		/* request */
3576178713bSFrank van der Linden 	struct nfsd4_change_info  rmxa_cinfo;	/* response */
3586178713bSFrank van der Linden };
3596178713bSFrank van der Linden 
3606178713bSFrank van der Linden struct nfsd4_listxattrs {
3616178713bSFrank van der Linden 	u64		lsxa_cookie;		/* request */
3626178713bSFrank van der Linden 	u32		lsxa_maxcount;		/* request */
3636178713bSFrank van der Linden 	char		*lsxa_buf;		/* unfiltered buffer (reply) */
3646178713bSFrank van der Linden 	u32		lsxa_len;		/* unfiltered len (reply) */
3656178713bSFrank van der Linden };
3666178713bSFrank van der Linden 
3679a74af21SBoaz Harrosh struct nfsd4_open {
3689a74af21SBoaz Harrosh 	u32		op_claim_type;      /* request */
3691708e50bSChuck Lever 	u32		op_fnamelen;
3701708e50bSChuck Lever 	char *		op_fname;	    /* request - everything but CLAIM_PREV */
3719a74af21SBoaz Harrosh 	u32		op_delegate_type;   /* request - CLAIM_PREV only */
3729a74af21SBoaz Harrosh 	stateid_t       op_delegate_stateid; /* request - response */
373d24433cdSBenny Halevy 	u32		op_why_no_deleg;    /* response - DELEG_NONE_EXT only */
3749a74af21SBoaz Harrosh 	u32		op_create;     	    /* request */
3759a74af21SBoaz Harrosh 	u32		op_createmode;      /* request */
376880a3a53SJ. Bruce Fields 	int		op_umask;           /* request */
3779a74af21SBoaz Harrosh 	u32		op_bmval[3];        /* request */
3783ff69309SKinglong Mee 	struct iattr	op_iattr;           /* UNCHECKED4, GUARDED4, EXCLUSIVE4_1 */
379ab4684d1SChuck Lever 	nfs4_verifier	op_verf __attribute__((aligned(32)));
380ab4684d1SChuck Lever 					    /* EXCLUSIVE4 */
3819a74af21SBoaz Harrosh 	clientid_t	op_clientid;        /* request */
3829a74af21SBoaz Harrosh 	struct xdr_netobj op_owner;           /* request */
3839a74af21SBoaz Harrosh 	u32		op_seqid;           /* request */
3849a74af21SBoaz Harrosh 	u32		op_share_access;    /* request */
3859a74af21SBoaz Harrosh 	u32		op_share_deny;      /* request */
3862c8bd7e0SBenny Halevy 	u32		op_deleg_want;      /* request */
3879a74af21SBoaz Harrosh 	stateid_t	op_stateid;         /* response */
3889d313b17SJ. Bruce Fields 	__be32		op_xdr_error;       /* see nfsd4_open_omfg() */
3899a74af21SBoaz Harrosh 	struct nfsd4_change_info  op_cinfo; /* response */
3909a74af21SBoaz Harrosh 	u32		op_rflags;          /* response */
391e4ad7ce7SChuck Lever 	bool		op_recall;          /* response */
392856121b2SJ. Bruce Fields 	bool		op_truncate;        /* used during processing */
393856121b2SJ. Bruce Fields 	bool		op_created;         /* used during processing */
394fe0750e5SJ. Bruce Fields 	struct nfs4_openowner *op_openowner; /* used during processing */
395fb70bf12SChuck Lever 	struct file	*op_filp;           /* used during processing */
39632513b40SJ. Bruce Fields 	struct nfs4_file *op_file;          /* used during processing */
3974cdc951bSJ. Bruce Fields 	struct nfs4_ol_stateid *op_stp;	    /* used during processing */
3988287f009SSachin Bhamare 	struct nfs4_clnt_odstate *op_odstate; /* used during processing */
3999a74af21SBoaz Harrosh 	struct nfs4_acl *op_acl;
40018032ca0SDavid Quigley 	struct xdr_netobj op_label;
401876c553cSJeff Layton 	struct svc_rqst *op_rqstp;
4029a74af21SBoaz Harrosh };
4039a74af21SBoaz Harrosh 
4049a74af21SBoaz Harrosh struct nfsd4_open_confirm {
4059a74af21SBoaz Harrosh 	stateid_t	oc_req_stateid		/* request */;
4069a74af21SBoaz Harrosh 	u32		oc_seqid    		/* request */;
4079a74af21SBoaz Harrosh 	stateid_t	oc_resp_stateid		/* response */;
4089a74af21SBoaz Harrosh };
4099a74af21SBoaz Harrosh 
4109a74af21SBoaz Harrosh struct nfsd4_open_downgrade {
4119a74af21SBoaz Harrosh 	stateid_t       od_stateid;
4129a74af21SBoaz Harrosh 	u32             od_seqid;
4132c8bd7e0SBenny Halevy 	u32             od_share_access;	/* request */
4142c8bd7e0SBenny Halevy 	u32		od_deleg_want;		/* request */
4152c8bd7e0SBenny Halevy 	u32             od_share_deny;		/* request */
4169a74af21SBoaz Harrosh };
4179a74af21SBoaz Harrosh 
4189a74af21SBoaz Harrosh 
4199a74af21SBoaz Harrosh struct nfsd4_read {
4209a74af21SBoaz Harrosh 	stateid_t		rd_stateid;         /* request */
4219a74af21SBoaz Harrosh 	u64			rd_offset;          /* request */
4229a74af21SBoaz Harrosh 	u32			rd_length;          /* request */
4239a74af21SBoaz Harrosh 	int			rd_vlen;
4245c4583b2SJeff Layton 	struct nfsd_file	*rd_nf;
4259a74af21SBoaz Harrosh 
4269a74af21SBoaz Harrosh 	struct svc_rqst		*rd_rqstp;          /* response */
4279a74af21SBoaz Harrosh 	struct svc_fh		*rd_fhp;            /* response */
42824c7fb85SChuck Lever 	u32			rd_eof;             /* response */
4299a74af21SBoaz Harrosh };
4309a74af21SBoaz Harrosh 
4319a74af21SBoaz Harrosh struct nfsd4_readdir {
4329a74af21SBoaz Harrosh 	u64		rd_cookie;          /* request */
4339a74af21SBoaz Harrosh 	nfs4_verifier	rd_verf;            /* request */
4349a74af21SBoaz Harrosh 	u32		rd_dircount;        /* request */
4359a74af21SBoaz Harrosh 	u32		rd_maxcount;        /* request */
4369a74af21SBoaz Harrosh 	u32		rd_bmval[3];        /* request */
4379a74af21SBoaz Harrosh 	struct svc_rqst *rd_rqstp;          /* response */
4389a74af21SBoaz Harrosh 	struct svc_fh * rd_fhp;             /* response */
4399a74af21SBoaz Harrosh 
4409a74af21SBoaz Harrosh 	struct readdir_cd	common;
441561f0ed4SJ. Bruce Fields 	struct xdr_stream	*xdr;
442561f0ed4SJ. Bruce Fields 	int			cookie_offset;
4439a74af21SBoaz Harrosh };
4449a74af21SBoaz Harrosh 
4459a74af21SBoaz Harrosh struct nfsd4_release_lockowner {
4469a74af21SBoaz Harrosh 	clientid_t        rl_clientid;
4479a74af21SBoaz Harrosh 	struct xdr_netobj rl_owner;
4489a74af21SBoaz Harrosh };
4499a74af21SBoaz Harrosh struct nfsd4_readlink {
4509a74af21SBoaz Harrosh 	struct svc_rqst *rl_rqstp;          /* request */
4519a74af21SBoaz Harrosh 	struct svc_fh *	rl_fhp;             /* request */
4529a74af21SBoaz Harrosh };
4539a74af21SBoaz Harrosh 
4549a74af21SBoaz Harrosh struct nfsd4_remove {
4559a74af21SBoaz Harrosh 	u32		rm_namelen;         /* request */
4569a74af21SBoaz Harrosh 	char *		rm_name;            /* request */
4579a74af21SBoaz Harrosh 	struct nfsd4_change_info  rm_cinfo; /* response */
4589a74af21SBoaz Harrosh };
4599a74af21SBoaz Harrosh 
4609a74af21SBoaz Harrosh struct nfsd4_rename {
4619a74af21SBoaz Harrosh 	u32		rn_snamelen;        /* request */
4629a74af21SBoaz Harrosh 	char *		rn_sname;           /* request */
4639a74af21SBoaz Harrosh 	u32		rn_tnamelen;        /* request */
4649a74af21SBoaz Harrosh 	char *		rn_tname;           /* request */
4659a74af21SBoaz Harrosh 	struct nfsd4_change_info  rn_sinfo; /* response */
4669a74af21SBoaz Harrosh 	struct nfsd4_change_info  rn_tinfo; /* response */
4679a74af21SBoaz Harrosh };
4689a74af21SBoaz Harrosh 
4699a74af21SBoaz Harrosh struct nfsd4_secinfo {
4709a74af21SBoaz Harrosh 	u32 si_namelen;					/* request */
4719a74af21SBoaz Harrosh 	char *si_name;					/* request */
4729a74af21SBoaz Harrosh 	struct svc_export *si_exp;			/* response */
4739a74af21SBoaz Harrosh };
4749a74af21SBoaz Harrosh 
47504f4ad16SJ. Bruce Fields struct nfsd4_secinfo_no_name {
47604f4ad16SJ. Bruce Fields 	u32 sin_style;					/* request */
47704f4ad16SJ. Bruce Fields 	struct svc_export *sin_exp;			/* response */
47804f4ad16SJ. Bruce Fields };
47904f4ad16SJ. Bruce Fields 
4809a74af21SBoaz Harrosh struct nfsd4_setattr {
4819a74af21SBoaz Harrosh 	stateid_t	sa_stateid;         /* request */
4829a74af21SBoaz Harrosh 	u32		sa_bmval[3];        /* request */
4839a74af21SBoaz Harrosh 	struct iattr	sa_iattr;           /* request */
4849a74af21SBoaz Harrosh 	struct nfs4_acl *sa_acl;
48518032ca0SDavid Quigley 	struct xdr_netobj sa_label;
4869a74af21SBoaz Harrosh };
4879a74af21SBoaz Harrosh 
4889a74af21SBoaz Harrosh struct nfsd4_setclientid {
4899a74af21SBoaz Harrosh 	nfs4_verifier	se_verf;            /* request */
490a084daf5SJ. Bruce Fields 	struct xdr_netobj se_name;
4919a74af21SBoaz Harrosh 	u32		se_callback_prog;   /* request */
4929a74af21SBoaz Harrosh 	u32		se_callback_netid_len;  /* request */
4939a74af21SBoaz Harrosh 	char *		se_callback_netid_val;  /* request */
4949a74af21SBoaz Harrosh 	u32		se_callback_addr_len;   /* request */
4959a74af21SBoaz Harrosh 	char *		se_callback_addr_val;   /* request */
4969a74af21SBoaz Harrosh 	u32		se_callback_ident;  /* request */
4979a74af21SBoaz Harrosh 	clientid_t	se_clientid;        /* response */
4989a74af21SBoaz Harrosh 	nfs4_verifier	se_confirm;         /* response */
4999a74af21SBoaz Harrosh };
5009a74af21SBoaz Harrosh 
5019a74af21SBoaz Harrosh struct nfsd4_setclientid_confirm {
5029a74af21SBoaz Harrosh 	clientid_t	sc_clientid;
5039a74af21SBoaz Harrosh 	nfs4_verifier	sc_confirm;
5049a74af21SBoaz Harrosh };
5059a74af21SBoaz Harrosh 
50603cfb420SBryan Schumaker struct nfsd4_test_stateid_id {
50703cfb420SBryan Schumaker 	__be32			ts_id_status;
50803cfb420SBryan Schumaker 	stateid_t		ts_id_stateid;
50903cfb420SBryan Schumaker 	struct list_head	ts_id_list;
51003cfb420SBryan Schumaker };
51103cfb420SBryan Schumaker 
51217456804SBryan Schumaker struct nfsd4_test_stateid {
51357b7b43bSJ. Bruce Fields 	u32		ts_num_ids;
51403cfb420SBryan Schumaker 	struct list_head ts_stateid_list;
51517456804SBryan Schumaker };
51617456804SBryan Schumaker 
517e1ca12dfSBryan Schumaker struct nfsd4_free_stateid {
518e1ca12dfSBryan Schumaker 	stateid_t	fr_stateid;         /* request */
519e1ca12dfSBryan Schumaker };
520e1ca12dfSBryan Schumaker 
52133a1e6eaSJeff Layton struct nfsd4_get_dir_delegation {
52233a1e6eaSJeff Layton 	/* request */
52333a1e6eaSJeff Layton 	u32			gdda_signal_deleg_avail;
52433a1e6eaSJeff Layton 	u32			gdda_notification_types[1];
52533a1e6eaSJeff Layton 	struct timespec64	gdda_child_attr_delay;
52633a1e6eaSJeff Layton 	struct timespec64	gdda_dir_attr_delay;
52733a1e6eaSJeff Layton 	u32			gdda_child_attributes[3];
52833a1e6eaSJeff Layton 	u32			gdda_dir_attributes[3];
52933a1e6eaSJeff Layton 	/* response */
53033a1e6eaSJeff Layton 	u32			gddrnf_status;
53133a1e6eaSJeff Layton 	nfs4_verifier		gddr_cookieverf;
53233a1e6eaSJeff Layton 	stateid_t		gddr_stateid;
53333a1e6eaSJeff Layton 	u32			gddr_notification[1];
53433a1e6eaSJeff Layton 	u32			gddr_child_attributes[3];
53533a1e6eaSJeff Layton 	u32			gddr_dir_attributes[3];
53633a1e6eaSJeff Layton 	bool			gddrnf_will_signal_deleg_avail;
53733a1e6eaSJeff Layton };
53833a1e6eaSJeff Layton 
5399a74af21SBoaz Harrosh /* also used for NVERIFY */
5409a74af21SBoaz Harrosh struct nfsd4_verify {
5419a74af21SBoaz Harrosh 	u32		ve_bmval[3];        /* request */
5429a74af21SBoaz Harrosh 	u32		ve_attrlen;         /* request */
5439a74af21SBoaz Harrosh 	char *		ve_attrval;         /* request */
5449a74af21SBoaz Harrosh };
5459a74af21SBoaz Harrosh 
5469a74af21SBoaz Harrosh struct nfsd4_write {
5479a74af21SBoaz Harrosh 	stateid_t	wr_stateid;         /* request */
5489a74af21SBoaz Harrosh 	u64		wr_offset;          /* request */
5499a74af21SBoaz Harrosh 	u32		wr_stable_how;      /* request */
5509a74af21SBoaz Harrosh 	u32		wr_buflen;          /* request */
551c1346a12SChuck Lever 	struct xdr_buf	wr_payload;         /* request */
5529a74af21SBoaz Harrosh 
5539a74af21SBoaz Harrosh 	u32		wr_bytes_written;   /* response */
5549a74af21SBoaz Harrosh 	u32		wr_how_written;     /* response */
5559a74af21SBoaz Harrosh 	nfs4_verifier	wr_verifier;        /* response */
5569a74af21SBoaz Harrosh };
5579a74af21SBoaz Harrosh 
5589a74af21SBoaz Harrosh struct nfsd4_exchange_id {
5599a74af21SBoaz Harrosh 	nfs4_verifier	verifier;
5609a74af21SBoaz Harrosh 	struct xdr_netobj clname;
5619a74af21SBoaz Harrosh 	u32		flags;
5629a74af21SBoaz Harrosh 	clientid_t	clientid;
5639a74af21SBoaz Harrosh 	u32		seqid;
564523ec6edSChuck Lever 	u32		spa_how;
565ed941643SAndrew Elble 	u32             spo_must_enforce[3];
566ed941643SAndrew Elble 	u32             spo_must_allow[3];
56779123444SJ. Bruce Fields 	struct xdr_netobj nii_domain;
56879123444SJ. Bruce Fields 	struct xdr_netobj nii_name;
56979123444SJ. Bruce Fields 	struct timespec64 nii_time;
5709a74af21SBoaz Harrosh };
5719a74af21SBoaz Harrosh 
5729a74af21SBoaz Harrosh struct nfsd4_sequence {
5739a74af21SBoaz Harrosh 	struct nfs4_sessionid	sessionid;		/* request/response */
5749a74af21SBoaz Harrosh 	u32			seqid;			/* request/response */
5759a74af21SBoaz Harrosh 	u32			slotid;			/* request/response */
5769a74af21SBoaz Harrosh 	u32			maxslots;		/* request/response */
5779a74af21SBoaz Harrosh 	u32			cachethis;		/* request */
5789a74af21SBoaz Harrosh #if 0
5799a74af21SBoaz Harrosh 	u32			target_maxslots;	/* response */
5809a74af21SBoaz Harrosh #endif /* not yet */
5810d7bb719SJ. Bruce Fields 	u32			status_flags;		/* response */
5829a74af21SBoaz Harrosh };
5839a74af21SBoaz Harrosh 
5849a74af21SBoaz Harrosh struct nfsd4_destroy_session {
5859a74af21SBoaz Harrosh 	struct nfs4_sessionid	sessionid;
5869a74af21SBoaz Harrosh };
5879a74af21SBoaz Harrosh 
588345c2842SMi Jinlong struct nfsd4_destroy_clientid {
589345c2842SMi Jinlong 	clientid_t clientid;
590345c2842SMi Jinlong };
591345c2842SMi Jinlong 
5924dc6ec00SJ. Bruce Fields struct nfsd4_reclaim_complete {
5934dc6ec00SJ. Bruce Fields 	u32 rca_one_fs;
5944dc6ec00SJ. Bruce Fields };
5954dc6ec00SJ. Bruce Fields 
5969cf514ccSChristoph Hellwig struct nfsd4_deviceid {
5979cf514ccSChristoph Hellwig 	u64			fsid_idx;
5989cf514ccSChristoph Hellwig 	u32			generation;
5999cf514ccSChristoph Hellwig 	u32			pad;
6009cf514ccSChristoph Hellwig };
6019cf514ccSChristoph Hellwig 
6029cf514ccSChristoph Hellwig struct nfsd4_layout_seg {
6039cf514ccSChristoph Hellwig 	u32			iomode;
6049cf514ccSChristoph Hellwig 	u64			offset;
6059cf514ccSChristoph Hellwig 	u64			length;
6069cf514ccSChristoph Hellwig };
6079cf514ccSChristoph Hellwig 
6089cf514ccSChristoph Hellwig struct nfsd4_getdeviceinfo {
6099cf514ccSChristoph Hellwig 	struct nfsd4_deviceid	gd_devid;	/* request */
6109cf514ccSChristoph Hellwig 	u32			gd_layout_type;	/* request */
6119cf514ccSChristoph Hellwig 	u32			gd_maxcount;	/* request */
6129cf514ccSChristoph Hellwig 	u32			gd_notify_types;/* request - response */
6139cf514ccSChristoph Hellwig 	void			*gd_device;	/* response */
6149cf514ccSChristoph Hellwig };
6159cf514ccSChristoph Hellwig 
6169cf514ccSChristoph Hellwig struct nfsd4_layoutget {
6179cf514ccSChristoph Hellwig 	u64			lg_minlength;	/* request */
6189cf514ccSChristoph Hellwig 	u32			lg_signal;	/* request */
6199cf514ccSChristoph Hellwig 	u32			lg_layout_type;	/* request */
6209cf514ccSChristoph Hellwig 	u32			lg_maxcount;	/* request */
6219cf514ccSChristoph Hellwig 	stateid_t		lg_sid;		/* request/response */
6229cf514ccSChristoph Hellwig 	struct nfsd4_layout_seg	lg_seg;		/* request/response */
6239cf514ccSChristoph Hellwig 	void			*lg_content;	/* response */
6249cf514ccSChristoph Hellwig };
6259cf514ccSChristoph Hellwig 
6269cf514ccSChristoph Hellwig struct nfsd4_layoutcommit {
6279cf514ccSChristoph Hellwig 	stateid_t		lc_sid;		/* request */
6289cf514ccSChristoph Hellwig 	struct nfsd4_layout_seg	lc_seg;		/* request */
6299cf514ccSChristoph Hellwig 	u32			lc_reclaim;	/* request */
6309cf514ccSChristoph Hellwig 	u32			lc_newoffset;	/* request */
6319cf514ccSChristoph Hellwig 	u64			lc_last_wr;	/* request */
632bdba5368SJ. Bruce Fields 	struct timespec64	lc_mtime;	/* request */
6339cf514ccSChristoph Hellwig 	u32			lc_layout_type;	/* request */
6349cf514ccSChristoph Hellwig 	u32			lc_up_len;	/* layout length */
6359cf514ccSChristoph Hellwig 	void			*lc_up_layout;	/* decoded by callback */
636cc313f80SChuck Lever 	bool			lc_size_chg;	/* response */
6379cf514ccSChristoph Hellwig 	u64			lc_newsize;	/* response */
6389cf514ccSChristoph Hellwig };
6399cf514ccSChristoph Hellwig 
6409cf514ccSChristoph Hellwig struct nfsd4_layoutreturn {
6419cf514ccSChristoph Hellwig 	u32			lr_return_type;	/* request */
6429cf514ccSChristoph Hellwig 	u32			lr_layout_type;	/* request */
6439cf514ccSChristoph Hellwig 	struct nfsd4_layout_seg	lr_seg;		/* request */
6449cf514ccSChristoph Hellwig 	u32			lr_reclaim;	/* request */
6459cf514ccSChristoph Hellwig 	u32			lrf_body_len;	/* request */
6469cf514ccSChristoph Hellwig 	void			*lrf_body;	/* request */
6479cf514ccSChristoph Hellwig 	stateid_t		lr_sid;		/* request/response */
64885dbc978SChuck Lever 	bool			lrs_present;	/* response */
6499cf514ccSChristoph Hellwig };
6509cf514ccSChristoph Hellwig 
65195d871f0SAnna Schumaker struct nfsd4_fallocate {
65295d871f0SAnna Schumaker 	/* request */
65395d871f0SAnna Schumaker 	stateid_t	falloc_stateid;
65495d871f0SAnna Schumaker 	loff_t		falloc_offset;
65595d871f0SAnna Schumaker 	u64		falloc_length;
65695d871f0SAnna Schumaker };
65795d871f0SAnna Schumaker 
658ffa0160aSChristoph Hellwig struct nfsd4_clone {
659ffa0160aSChristoph Hellwig 	/* request */
660ffa0160aSChristoph Hellwig 	stateid_t	cl_src_stateid;
661ffa0160aSChristoph Hellwig 	stateid_t	cl_dst_stateid;
662ffa0160aSChristoph Hellwig 	u64		cl_src_pos;
663ffa0160aSChristoph Hellwig 	u64		cl_dst_pos;
664ffa0160aSChristoph Hellwig 	u64		cl_count;
665ffa0160aSChristoph Hellwig };
666ffa0160aSChristoph Hellwig 
66729ae7f9dSAnna Schumaker struct nfsd42_write_res {
66829ae7f9dSAnna Schumaker 	u64			wr_bytes_written;
66929ae7f9dSAnna Schumaker 	u32			wr_stable_how;
67029ae7f9dSAnna Schumaker 	nfs4_verifier		wr_verifier;
6719eb190fcSOlga Kornievskaia 	stateid_t		cb_stateid;
67229ae7f9dSAnna Schumaker };
67329ae7f9dSAnna Schumaker 
674a11ada99SChuck Lever struct nfsd4_cb_offload {
675a11ada99SChuck Lever 	struct nfsd4_callback	co_cb;
676a11ada99SChuck Lever 	struct nfsd42_write_res	co_res;
677a11ada99SChuck Lever 	__be32			co_nfserr;
678a11ada99SChuck Lever 	struct knfsd_fh		co_fh;
679a11ada99SChuck Lever };
680a11ada99SChuck Lever 
68129ae7f9dSAnna Schumaker struct nfsd4_copy {
68229ae7f9dSAnna Schumaker 	/* request */
68329ae7f9dSAnna Schumaker 	stateid_t		cp_src_stateid;
68429ae7f9dSAnna Schumaker 	stateid_t		cp_dst_stateid;
68529ae7f9dSAnna Schumaker 	u64			cp_src_pos;
68629ae7f9dSAnna Schumaker 	u64			cp_dst_pos;
68729ae7f9dSAnna Schumaker 	u64			cp_count;
68887689df6SChuck Lever 	struct nl4_server	*cp_src;
68929ae7f9dSAnna Schumaker 
6901913cdf5SChuck Lever 	unsigned long		cp_flags;
6911913cdf5SChuck Lever #define NFSD4_COPY_F_STOPPED		(0)
6921913cdf5SChuck Lever #define NFSD4_COPY_F_INTRA		(1)
6931913cdf5SChuck Lever #define NFSD4_COPY_F_SYNCHRONOUS	(2)
6941913cdf5SChuck Lever #define NFSD4_COPY_F_COMMITTED		(3)
695cc63c216SChuck Lever #define NFSD4_COPY_F_COMPLETED		(4)
69629ae7f9dSAnna Schumaker 
69729ae7f9dSAnna Schumaker 	/* response */
698a8483b9aSChuck Lever 	__be32			nfserr;
69929ae7f9dSAnna Schumaker 	struct nfsd42_write_res	cp_res;
7009eb190fcSOlga Kornievskaia 	struct knfsd_fh		fh;
701e0639dc5SOlga Kornievskaia 
702e0639dc5SOlga Kornievskaia 	struct nfs4_client      *cp_clp;
703e0639dc5SOlga Kornievskaia 
7045c4583b2SJeff Layton 	struct nfsd_file        *nf_src;
7055c4583b2SJeff Layton 	struct nfsd_file        *nf_dst;
706e0639dc5SOlga Kornievskaia 
707624322f1SOlga Kornievskaia 	copy_stateid_t		cp_stateid;
708e0639dc5SOlga Kornievskaia 
709e0639dc5SOlga Kornievskaia 	struct list_head	copies;
710e0639dc5SOlga Kornievskaia 	struct task_struct	*copy_task;
711e0639dc5SOlga Kornievskaia 	refcount_t		refcount;
712ce0887acSOlga Kornievskaia 
713df24ac7aSDai Ngo 	struct nfsd4_ssc_umount_item *ss_nsui;
714ce0887acSOlga Kornievskaia 	struct nfs_fh		c_fh;
715ce0887acSOlga Kornievskaia 	nfs4_stateid		stateid;
716*aadc3bbeSChuck Lever 	struct nfsd_net		*cp_nn;
71729ae7f9dSAnna Schumaker };
71829ae7f9dSAnna Schumaker 
7191913cdf5SChuck Lever static inline void nfsd4_copy_set_sync(struct nfsd4_copy *copy, bool sync)
7201913cdf5SChuck Lever {
7211913cdf5SChuck Lever 	if (sync)
7221913cdf5SChuck Lever 		set_bit(NFSD4_COPY_F_SYNCHRONOUS, &copy->cp_flags);
7231913cdf5SChuck Lever 	else
7241913cdf5SChuck Lever 		clear_bit(NFSD4_COPY_F_SYNCHRONOUS, &copy->cp_flags);
7251913cdf5SChuck Lever }
7261913cdf5SChuck Lever 
7271913cdf5SChuck Lever static inline bool nfsd4_copy_is_sync(const struct nfsd4_copy *copy)
7281913cdf5SChuck Lever {
7291913cdf5SChuck Lever 	return test_bit(NFSD4_COPY_F_SYNCHRONOUS, &copy->cp_flags);
7301913cdf5SChuck Lever }
7311913cdf5SChuck Lever 
7321913cdf5SChuck Lever static inline bool nfsd4_copy_is_async(const struct nfsd4_copy *copy)
7331913cdf5SChuck Lever {
7341913cdf5SChuck Lever 	return !test_bit(NFSD4_COPY_F_SYNCHRONOUS, &copy->cp_flags);
7351913cdf5SChuck Lever }
7361913cdf5SChuck Lever 
7371913cdf5SChuck Lever static inline bool nfsd4_ssc_is_inter(const struct nfsd4_copy *copy)
7381913cdf5SChuck Lever {
7391913cdf5SChuck Lever 	return !test_bit(NFSD4_COPY_F_INTRA, &copy->cp_flags);
7401913cdf5SChuck Lever }
7411913cdf5SChuck Lever 
74224bab491SAnna Schumaker struct nfsd4_seek {
74324bab491SAnna Schumaker 	/* request */
74424bab491SAnna Schumaker 	stateid_t	seek_stateid;
74524bab491SAnna Schumaker 	loff_t		seek_offset;
74624bab491SAnna Schumaker 	u32		seek_whence;
74724bab491SAnna Schumaker 
74824bab491SAnna Schumaker 	/* response */
74924bab491SAnna Schumaker 	u32		seek_eof;
75024bab491SAnna Schumaker 	loff_t		seek_pos;
75124bab491SAnna Schumaker };
75224bab491SAnna Schumaker 
7536308bc98SOlga Kornievskaia struct nfsd4_offload_status {
7546308bc98SOlga Kornievskaia 	/* request */
7556308bc98SOlga Kornievskaia 	stateid_t	stateid;
7566308bc98SOlga Kornievskaia 
7576308bc98SOlga Kornievskaia 	/* response */
7586308bc98SOlga Kornievskaia 	u64		count;
759cc63c216SChuck Lever 	__be32		status;
760cc63c216SChuck Lever 	bool		completed;
7616308bc98SOlga Kornievskaia };
7626308bc98SOlga Kornievskaia 
76351911868SOlga Kornievskaia struct nfsd4_copy_notify {
76451911868SOlga Kornievskaia 	/* request */
76551911868SOlga Kornievskaia 	stateid_t		cpn_src_stateid;
76609426ef2SChuck Lever 	struct nl4_server	*cpn_dst;
76751911868SOlga Kornievskaia 
76851911868SOlga Kornievskaia 	/* response */
76951911868SOlga Kornievskaia 	stateid_t		cpn_cnr_stateid;
77021d316a7SChuck Lever 	struct timespec64	cpn_lease_time;
77109426ef2SChuck Lever 	struct nl4_server	*cpn_src;
77251911868SOlga Kornievskaia };
77351911868SOlga Kornievskaia 
7749a74af21SBoaz Harrosh struct nfsd4_op {
7753a237b4aSChuck Lever 	u32					opnum;
7769a74af21SBoaz Harrosh 	__be32					status;
777d3143094SChuck Lever 	const struct nfsd4_operation		*opdesc;
778d3143094SChuck Lever 	struct nfs4_replay			*replay;
779b60e9859SChristoph Hellwig 	union nfsd4_op_u {
7809a74af21SBoaz Harrosh 		struct nfsd4_access		access;
7819a74af21SBoaz Harrosh 		struct nfsd4_close		close;
7829a74af21SBoaz Harrosh 		struct nfsd4_commit		commit;
7839a74af21SBoaz Harrosh 		struct nfsd4_create		create;
7849a74af21SBoaz Harrosh 		struct nfsd4_delegreturn	delegreturn;
7859a74af21SBoaz Harrosh 		struct nfsd4_getattr		getattr;
7869a74af21SBoaz Harrosh 		struct svc_fh *			getfh;
7879a74af21SBoaz Harrosh 		struct nfsd4_link		link;
7889a74af21SBoaz Harrosh 		struct nfsd4_lock		lock;
7899a74af21SBoaz Harrosh 		struct nfsd4_lockt		lockt;
7909a74af21SBoaz Harrosh 		struct nfsd4_locku		locku;
7919a74af21SBoaz Harrosh 		struct nfsd4_lookup		lookup;
7929a74af21SBoaz Harrosh 		struct nfsd4_verify		nverify;
7939a74af21SBoaz Harrosh 		struct nfsd4_open		open;
7949a74af21SBoaz Harrosh 		struct nfsd4_open_confirm	open_confirm;
7959a74af21SBoaz Harrosh 		struct nfsd4_open_downgrade	open_downgrade;
7969a74af21SBoaz Harrosh 		struct nfsd4_putfh		putfh;
7979a74af21SBoaz Harrosh 		struct nfsd4_read		read;
7989a74af21SBoaz Harrosh 		struct nfsd4_readdir		readdir;
7999a74af21SBoaz Harrosh 		struct nfsd4_readlink		readlink;
8009a74af21SBoaz Harrosh 		struct nfsd4_remove		remove;
8019a74af21SBoaz Harrosh 		struct nfsd4_rename		rename;
8029a74af21SBoaz Harrosh 		clientid_t			renew;
8039a74af21SBoaz Harrosh 		struct nfsd4_secinfo		secinfo;
8049a74af21SBoaz Harrosh 		struct nfsd4_setattr		setattr;
8059a74af21SBoaz Harrosh 		struct nfsd4_setclientid	setclientid;
8069a74af21SBoaz Harrosh 		struct nfsd4_setclientid_confirm setclientid_confirm;
8079a74af21SBoaz Harrosh 		struct nfsd4_verify		verify;
8089a74af21SBoaz Harrosh 		struct nfsd4_write		write;
8099a74af21SBoaz Harrosh 		struct nfsd4_release_lockowner	release_lockowner;
8109a74af21SBoaz Harrosh 
8119a74af21SBoaz Harrosh 		/* NFSv4.1 */
8129a74af21SBoaz Harrosh 		struct nfsd4_exchange_id	exchange_id;
813cb73a9f4SJ. Bruce Fields 		struct nfsd4_backchannel_ctl	backchannel_ctl;
8141d1bc8f2SJ. Bruce Fields 		struct nfsd4_bind_conn_to_session bind_conn_to_session;
8159a74af21SBoaz Harrosh 		struct nfsd4_create_session	create_session;
8169a74af21SBoaz Harrosh 		struct nfsd4_destroy_session	destroy_session;
817eb69853dSChristoph Hellwig 		struct nfsd4_destroy_clientid	destroy_clientid;
8189a74af21SBoaz Harrosh 		struct nfsd4_sequence		sequence;
8194dc6ec00SJ. Bruce Fields 		struct nfsd4_reclaim_complete	reclaim_complete;
82017456804SBryan Schumaker 		struct nfsd4_test_stateid	test_stateid;
821e1ca12dfSBryan Schumaker 		struct nfsd4_free_stateid	free_stateid;
82233a1e6eaSJeff Layton 		struct nfsd4_get_dir_delegation	get_dir_delegation;
8239cf514ccSChristoph Hellwig 		struct nfsd4_getdeviceinfo	getdeviceinfo;
8249cf514ccSChristoph Hellwig 		struct nfsd4_layoutget		layoutget;
8259cf514ccSChristoph Hellwig 		struct nfsd4_layoutcommit	layoutcommit;
8269cf514ccSChristoph Hellwig 		struct nfsd4_layoutreturn	layoutreturn;
827eb69853dSChristoph Hellwig 		struct nfsd4_secinfo_no_name	secinfo_no_name;
82824bab491SAnna Schumaker 
82924bab491SAnna Schumaker 		/* NFSv4.2 */
83095d871f0SAnna Schumaker 		struct nfsd4_fallocate		allocate;
831b0cb9085SAnna Schumaker 		struct nfsd4_fallocate		deallocate;
832ffa0160aSChristoph Hellwig 		struct nfsd4_clone		clone;
83329ae7f9dSAnna Schumaker 		struct nfsd4_copy		copy;
8346308bc98SOlga Kornievskaia 		struct nfsd4_offload_status	offload_status;
83551911868SOlga Kornievskaia 		struct nfsd4_copy_notify	copy_notify;
83624bab491SAnna Schumaker 		struct nfsd4_seek		seek;
8376178713bSFrank van der Linden 
8386178713bSFrank van der Linden 		struct nfsd4_getxattr		getxattr;
8396178713bSFrank van der Linden 		struct nfsd4_setxattr		setxattr;
8406178713bSFrank van der Linden 		struct nfsd4_listxattrs		listxattrs;
8416178713bSFrank van der Linden 		struct nfsd4_removexattr	removexattr;
8429a74af21SBoaz Harrosh 	} u;
8439a74af21SBoaz Harrosh };
8449a74af21SBoaz Harrosh 
8451091006cSJ. Bruce Fields bool nfsd4_cache_this_op(struct nfsd4_op *);
8461091006cSJ. Bruce Fields 
847d5e23383SJ. Bruce Fields /*
848d5e23383SJ. Bruce Fields  * Memory needed just for the duration of processing one compound:
849d5e23383SJ. Bruce Fields  */
850d5e23383SJ. Bruce Fields struct svcxdr_tmpbuf {
851d5e23383SJ. Bruce Fields 	struct svcxdr_tmpbuf *next;
852d5e23383SJ. Bruce Fields 	char buf[];
853d5e23383SJ. Bruce Fields };
854d5e23383SJ. Bruce Fields 
8559a74af21SBoaz Harrosh struct nfsd4_compoundargs {
8569a74af21SBoaz Harrosh 	/* scratch variables for XDR decode */
857c1346a12SChuck Lever 	struct xdr_stream		*xdr;
858d5e23383SJ. Bruce Fields 	struct svcxdr_tmpbuf		*to_free;
8599a74af21SBoaz Harrosh 	struct svc_rqst			*rqstp;
8609a74af21SBoaz Harrosh 
8619a74af21SBoaz Harrosh 	char *				tag;
8627518a3dcSChuck Lever 	u32				taglen;
8639a74af21SBoaz Harrosh 	u32				minorversion;
8647518a3dcSChuck Lever 	u32				client_opcnt;
8659a74af21SBoaz Harrosh 	u32				opcnt;
866a2c91753SChuck Lever 	bool				splice_ok;
8679a74af21SBoaz Harrosh 	struct nfsd4_op			*ops;
8689a74af21SBoaz Harrosh 	struct nfsd4_op			iops[8];
8699a74af21SBoaz Harrosh };
8709a74af21SBoaz Harrosh 
8719a74af21SBoaz Harrosh struct nfsd4_compoundres {
8729a74af21SBoaz Harrosh 	/* scratch variables for XDR encode */
873bddfdbcdSChuck Lever 	struct xdr_stream		*xdr;
8749a74af21SBoaz Harrosh 	struct svc_rqst *		rqstp;
8759a74af21SBoaz Harrosh 
8763b0ebb25SChuck Lever 	__be32				*statusp;
8779a74af21SBoaz Harrosh 	char *				tag;
8789f553e61SChuck Lever 	u32				taglen;
8799a74af21SBoaz Harrosh 	u32				opcnt;
8803b0ebb25SChuck Lever 
8819a74af21SBoaz Harrosh 	struct nfsd4_compound_state	cstate;
8829a74af21SBoaz Harrosh };
8839a74af21SBoaz Harrosh 
8849a74af21SBoaz Harrosh static inline bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp)
8859a74af21SBoaz Harrosh {
8869a74af21SBoaz Harrosh 	struct nfsd4_compoundargs *args = resp->rqstp->rq_argp;
8879a74af21SBoaz Harrosh 	return resp->opcnt == 1 && args->ops[0].opnum == OP_SEQUENCE;
8889a74af21SBoaz Harrosh }
8899a74af21SBoaz Harrosh 
890085def3aSJ. Bruce Fields /*
891085def3aSJ. Bruce Fields  * The session reply cache only needs to cache replies that the client
892085def3aSJ. Bruce Fields  * actually asked us to.  But it's almost free for us to cache compounds
893085def3aSJ. Bruce Fields  * consisting of only a SEQUENCE op, so we may as well cache those too.
894085def3aSJ. Bruce Fields  * Also, the protocol doesn't give us a convenient response in the case
895085def3aSJ. Bruce Fields  * of a replay of a solo SEQUENCE op that wasn't cached
896085def3aSJ. Bruce Fields  * (RETRY_UNCACHED_REP can only be returned in the second op of a
897085def3aSJ. Bruce Fields  * compound).
898085def3aSJ. Bruce Fields  */
899085def3aSJ. Bruce Fields static inline bool nfsd4_cache_this(struct nfsd4_compoundres *resp)
9009a74af21SBoaz Harrosh {
901085def3aSJ. Bruce Fields 	return (resp->cstate.slot->sl_flags & NFSD4_SLOT_CACHETHIS)
90273e79482SJ. Bruce Fields 		|| nfsd4_is_solo_sequence(resp);
9039a74af21SBoaz Harrosh }
9049a74af21SBoaz Harrosh 
9059b3234b9SJ. Bruce Fields static inline bool nfsd4_last_compound_op(struct svc_rqst *rqstp)
9069b3234b9SJ. Bruce Fields {
9079b3234b9SJ. Bruce Fields 	struct nfsd4_compoundres *resp = rqstp->rq_resp;
9089b3234b9SJ. Bruce Fields 	struct nfsd4_compoundargs *argp = rqstp->rq_argp;
9099b3234b9SJ. Bruce Fields 
9109b3234b9SJ. Bruce Fields 	return argp->opcnt == resp->opcnt;
9119b3234b9SJ. Bruce Fields }
9129b3234b9SJ. Bruce Fields 
913f4f9ef4aSJ. Bruce Fields const struct nfsd4_operation *OPDESC(struct nfsd4_op *op);
9144f0cefbfSJ. Bruce Fields int nfsd4_max_reply(struct svc_rqst *rqstp, struct nfsd4_op *op);
91507d1f802SJ. Bruce Fields void warn_on_nonidempotent_op(struct nfsd4_op *op);
91607d1f802SJ. Bruce Fields 
9179a74af21SBoaz Harrosh #define NFS4_SVC_XDRSIZE		sizeof(struct nfsd4_compoundargs)
9189a74af21SBoaz Harrosh 
919dedeb13fSAndrew Elble bool nfsd4_mach_creds_match(struct nfs4_client *cl, struct svc_rqst *rqstp);
920c44b31c2SChuck Lever bool nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
921130e2054SChuck Lever bool nfs4svc_encode_compoundres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
92257b7b43bSJ. Bruce Fields __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *, u32);
9239a74af21SBoaz Harrosh void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
924d0a381ddSJ. Bruce Fields void nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op);
925d5184658SJ. Bruce Fields __be32 nfsd4_encode_fattr_to_buf(__be32 **p, int words,
926d5184658SJ. Bruce Fields 		struct svc_fh *fhp, struct svc_export *exp,
927d5184658SJ. Bruce Fields 		struct dentry *dentry,
9289a74af21SBoaz Harrosh 		u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
9299a74af21SBoaz Harrosh extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
930eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *u);
9319a74af21SBoaz Harrosh extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
932eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *u);
9339a74af21SBoaz Harrosh extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
934eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *u);
935eb69853dSChristoph Hellwig extern __be32 nfsd4_backchannel_ctl(struct svc_rqst *,
936eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *u);
937eb69853dSChristoph Hellwig extern __be32 nfsd4_bind_conn_to_session(struct svc_rqst *,
938eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *u);
9399a74af21SBoaz Harrosh extern __be32 nfsd4_create_session(struct svc_rqst *,
940eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *u);
9419a74af21SBoaz Harrosh extern __be32 nfsd4_sequence(struct svc_rqst *,
942eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *u);
943b607664eSTrond Myklebust extern void nfsd4_sequence_done(struct nfsd4_compoundres *resp);
9449a74af21SBoaz Harrosh extern __be32 nfsd4_destroy_session(struct svc_rqst *,
945eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *u);
946eb69853dSChristoph Hellwig extern __be32 nfsd4_destroy_clientid(struct svc_rqst *, struct nfsd4_compound_state *,
947eb69853dSChristoph Hellwig 		union nfsd4_op_u *u);
948eb69853dSChristoph Hellwig __be32 nfsd4_reclaim_complete(struct svc_rqst *, struct nfsd4_compound_state *,
949eb69853dSChristoph Hellwig 		union nfsd4_op_u *u);
9509a74af21SBoaz Harrosh extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *,
9513320fef1SStanislav Kinsbursky 		struct nfsd4_open *open, struct nfsd_net *nn);
9529a74af21SBoaz Harrosh extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
9539a74af21SBoaz Harrosh 		struct svc_fh *current_fh, struct nfsd4_open *open);
95458fb12e6SJeff Layton extern void nfsd4_cstate_clear_replay(struct nfsd4_compound_state *cstate);
95558fb12e6SJeff Layton extern void nfsd4_cleanup_open_state(struct nfsd4_compound_state *cstate,
95642297899SJeff Layton 		struct nfsd4_open *open);
9579a74af21SBoaz Harrosh extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
958eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *u);
959eb69853dSChristoph Hellwig extern __be32 nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
960eb69853dSChristoph Hellwig 		union nfsd4_op_u *u);
9619a74af21SBoaz Harrosh extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
962eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *u);
9639a74af21SBoaz Harrosh extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
964eb69853dSChristoph Hellwig 		union nfsd4_op_u *u);
96592d82e99SChuck Lever extern void nfsd4_lock_release(union nfsd4_op_u *u);
966eb69853dSChristoph Hellwig extern __be32 nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
967eb69853dSChristoph Hellwig 		union nfsd4_op_u *u);
96892d82e99SChuck Lever extern void nfsd4_lockt_release(union nfsd4_op_u *u);
969eb69853dSChristoph Hellwig extern __be32 nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
970eb69853dSChristoph Hellwig 		union nfsd4_op_u *u);
9719a74af21SBoaz Harrosh extern __be32
9729a74af21SBoaz Harrosh nfsd4_release_lockowner(struct svc_rqst *rqstp,
973eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *u);
9748537488bSChristoph Hellwig extern void nfsd4_release_compoundargs(struct svc_rqst *rqstp);
9759a74af21SBoaz Harrosh extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
976eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *u);
977eb69853dSChristoph Hellwig extern __be32 nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
978eb69853dSChristoph Hellwig 		union nfsd4_op_u *u);
97917456804SBryan Schumaker extern __be32 nfsd4_test_stateid(struct svc_rqst *rqstp,
980eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *);
981e1ca12dfSBryan Schumaker extern __be32 nfsd4_free_stateid(struct svc_rqst *rqstp,
982eb69853dSChristoph Hellwig 		struct nfsd4_compound_state *, union nfsd4_op_u *);
9839411b1d4SJ. Bruce Fields extern void nfsd4_bump_seqid(struct nfsd4_compound_state *, __be32 nfserr);
98458fb12e6SJeff Layton 
9850020939fSJ. Bruce Fields enum nfsd4_op_flags {
9860020939fSJ. Bruce Fields 	ALLOWED_WITHOUT_FH = 1 << 0,    /* No current filehandle required */
9870020939fSJ. Bruce Fields 	ALLOWED_ON_ABSENT_FS = 1 << 1,  /* ops processed on absent fs */
9880020939fSJ. Bruce Fields 	ALLOWED_AS_FIRST_OP = 1 << 2,   /* ops reqired first in compound */
9890020939fSJ. Bruce Fields 	/* For rfc 5661 section 2.6.3.1.1: */
9900020939fSJ. Bruce Fields 	OP_HANDLES_WRONGSEC = 1 << 3,
9910020939fSJ. Bruce Fields 	OP_IS_PUTFH_LIKE = 1 << 4,
9920020939fSJ. Bruce Fields 	/*
9930020939fSJ. Bruce Fields 	 * These are the ops whose result size we estimate before
9940020939fSJ. Bruce Fields 	 * encoding, to avoid performing an op then not being able to
9950020939fSJ. Bruce Fields 	 * respond or cache a response.  This includes writes and setattrs
9960020939fSJ. Bruce Fields 	 * as well as the operations usually called "nonidempotent":
9970020939fSJ. Bruce Fields 	 */
9980020939fSJ. Bruce Fields 	OP_MODIFIES_SOMETHING = 1 << 5,
9990020939fSJ. Bruce Fields 	/*
10000020939fSJ. Bruce Fields 	 * Cache compounds containing these ops in the xid-based drc:
10010020939fSJ. Bruce Fields 	 * We use the DRC for compounds containing non-idempotent
10020020939fSJ. Bruce Fields 	 * operations, *except* those that are 4.1-specific (since
10030020939fSJ. Bruce Fields 	 * sessions provide their own EOS), and except for stateful
10040020939fSJ. Bruce Fields 	 * operations other than setclientid and setclientid_confirm
10050020939fSJ. Bruce Fields 	 * (since sequence numbers provide EOS for open, lock, etc in
10060020939fSJ. Bruce Fields 	 * the v4.0 case).
10070020939fSJ. Bruce Fields 	 */
10080020939fSJ. Bruce Fields 	OP_CACHEME = 1 << 6,
10090020939fSJ. Bruce Fields 	/*
10100020939fSJ. Bruce Fields 	 * These are ops which clear current state id.
10110020939fSJ. Bruce Fields 	 */
10120020939fSJ. Bruce Fields 	OP_CLEAR_STATEID = 1 << 7,
1013b7571e4cSJ. Bruce Fields 	/* Most ops return only an error on failure; some may do more: */
1014b7571e4cSJ. Bruce Fields 	OP_NONTRIVIAL_ERROR_ENCODE = 1 << 8,
10150020939fSJ. Bruce Fields };
10160020939fSJ. Bruce Fields 
10170020939fSJ. Bruce Fields struct nfsd4_operation {
10180020939fSJ. Bruce Fields 	__be32 (*op_func)(struct svc_rqst *, struct nfsd4_compound_state *,
10190020939fSJ. Bruce Fields 			union nfsd4_op_u *);
102034b1744cSJ. Bruce Fields 	void (*op_release)(union nfsd4_op_u *);
10210020939fSJ. Bruce Fields 	u32 op_flags;
10220020939fSJ. Bruce Fields 	char *op_name;
10230020939fSJ. Bruce Fields 	/* Try to get response size before operation */
10246604148cSChuck Lever 	u32 (*op_rsize_bop)(const struct svc_rqst *rqstp,
10256604148cSChuck Lever 			const struct nfsd4_op *op);
10260020939fSJ. Bruce Fields 	void (*op_get_currentstateid)(struct nfsd4_compound_state *,
10270020939fSJ. Bruce Fields 			union nfsd4_op_u *);
10280020939fSJ. Bruce Fields 	void (*op_set_currentstateid)(struct nfsd4_compound_state *,
10290020939fSJ. Bruce Fields 			union nfsd4_op_u *);
10300020939fSJ. Bruce Fields };
10310020939fSJ. Bruce Fields 
10323959066bSDai Ngo struct nfsd4_cb_recall_any {
10333959066bSDai Ngo 	struct nfsd4_callback	ra_cb;
10343959066bSDai Ngo 	u32			ra_keep;
10353959066bSDai Ngo 	u32			ra_bmval[1];
10363959066bSDai Ngo };
10370020939fSJ. Bruce Fields 
10389a74af21SBoaz Harrosh #endif
1039