xref: /openbmc/linux/fs/nfs/callback_xdr.c (revision 026fec7e)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * linux/fs/nfs/callback_xdr.c
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Copyright (C) 2004 Trond Myklebust
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  * NFSv4 callback encode/decode procedures
71da177e4SLinus Torvalds  */
81da177e4SLinus Torvalds #include <linux/kernel.h>
91da177e4SLinus Torvalds #include <linux/sunrpc/svc.h>
101da177e4SLinus Torvalds #include <linux/nfs4.h>
111da177e4SLinus Torvalds #include <linux/nfs_fs.h>
129a3ba432STrond Myklebust #include <linux/ratelimit.h>
139a3ba432STrond Myklebust #include <linux/printk.h>
145a0e3ad6STejun Heo #include <linux/slab.h>
15c36fca52SAndy Adamson #include <linux/sunrpc/bc_xprt.h>
164ce79717STrond Myklebust #include "nfs4_fs.h"
171da177e4SLinus Torvalds #include "callback.h"
18c36fca52SAndy Adamson #include "internal.h"
1976e697baSTrond Myklebust #include "nfs4session.h"
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds #define CB_OP_TAGLEN_MAXSZ		(512)
2245724e8aSKinglong Mee #define CB_OP_HDR_RES_MAXSZ		(2 * 4) // opcode, status
2345724e8aSKinglong Mee #define CB_OP_GETATTR_BITMAP_MAXSZ	(4 * 4) // bitmap length, 3 bitmaps
241da177e4SLinus Torvalds #define CB_OP_GETATTR_RES_MAXSZ		(CB_OP_HDR_RES_MAXSZ + \
251da177e4SLinus Torvalds 					 CB_OP_GETATTR_BITMAP_MAXSZ + \
2645724e8aSKinglong Mee 					 /* change, size, ctime, mtime */\
2745724e8aSKinglong Mee 					 (2 + 2 + 3 + 3) * 4)
281da177e4SLinus Torvalds #define CB_OP_RECALL_RES_MAXSZ		(CB_OP_HDR_RES_MAXSZ)
291da177e4SLinus Torvalds 
304aece6a1SBenny Halevy #if defined(CONFIG_NFS_V4_1)
31f2a62561SFred Isaman #define CB_OP_LAYOUTRECALL_RES_MAXSZ	(CB_OP_HDR_RES_MAXSZ)
321be5683bSMarc Eshel #define CB_OP_DEVICENOTIFY_RES_MAXSZ	(CB_OP_HDR_RES_MAXSZ)
334aece6a1SBenny Halevy #define CB_OP_SEQUENCE_RES_MAXSZ	(CB_OP_HDR_RES_MAXSZ + \
3445724e8aSKinglong Mee 					 NFS4_MAX_SESSIONID_LEN + \
3545724e8aSKinglong Mee 					 (1 + 3) * 4) // seqid, 3 slotids
3631f09607SAlexandros Batsakis #define CB_OP_RECALLANY_RES_MAXSZ	(CB_OP_HDR_RES_MAXSZ)
37b9efa1b2SAndy Adamson #define CB_OP_RECALLSLOT_RES_MAXSZ	(CB_OP_HDR_RES_MAXSZ)
38db783688SJeff Layton #define CB_OP_NOTIFY_LOCK_RES_MAXSZ	(CB_OP_HDR_RES_MAXSZ)
394aece6a1SBenny Halevy #endif /* CONFIG_NFS_V4_1 */
404aece6a1SBenny Halevy 
411da177e4SLinus Torvalds #define NFSDBG_FACILITY NFSDBG_CALLBACK
421da177e4SLinus Torvalds 
4331d2b435SAndy Adamson /* Internal error code */
4431d2b435SAndy Adamson #define NFS4ERR_RESOURCE_HDR	11050
4531d2b435SAndy Adamson 
461da177e4SLinus Torvalds struct callback_op {
47f4dac4adSChristoph Hellwig 	__be32 (*process_op)(void *, void *, struct cb_process_state *);
48f4dac4adSChristoph Hellwig 	__be32 (*decode_args)(struct svc_rqst *, struct xdr_stream *, void *);
49f4dac4adSChristoph Hellwig 	__be32 (*encode_res)(struct svc_rqst *, struct xdr_stream *,
50f4dac4adSChristoph Hellwig 			const void *);
511da177e4SLinus Torvalds 	long res_maxsize;
521da177e4SLinus Torvalds };
531da177e4SLinus Torvalds 
541da177e4SLinus Torvalds static struct callback_op callback_ops[];
551da177e4SLinus Torvalds 
56a6beb732SChristoph Hellwig static __be32 nfs4_callback_null(struct svc_rqst *rqstp)
571da177e4SLinus Torvalds {
581da177e4SLinus Torvalds 	return htonl(NFS4_OK);
591da177e4SLinus Torvalds }
601da177e4SLinus Torvalds 
61026fec7eSChristoph Hellwig static int nfs4_decode_void(struct svc_rqst *rqstp, __be32 *p)
621da177e4SLinus Torvalds {
631da177e4SLinus Torvalds 	return xdr_argsize_check(rqstp, p);
641da177e4SLinus Torvalds }
651da177e4SLinus Torvalds 
665704fdebSAl Viro static int nfs4_encode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
671da177e4SLinus Torvalds {
681da177e4SLinus Torvalds 	return xdr_ressize_check(rqstp, p);
691da177e4SLinus Torvalds }
701da177e4SLinus Torvalds 
71b60475c9SJeff Layton static __be32 *read_buf(struct xdr_stream *xdr, size_t nbytes)
721da177e4SLinus Torvalds {
735704fdebSAl Viro 	__be32 *p;
741da177e4SLinus Torvalds 
751da177e4SLinus Torvalds 	p = xdr_inline_decode(xdr, nbytes);
761da177e4SLinus Torvalds 	if (unlikely(p == NULL))
77756b9b37STrond Myklebust 		printk(KERN_WARNING "NFS: NFSv4 callback reply buffer overflowed!\n");
781da177e4SLinus Torvalds 	return p;
791da177e4SLinus Torvalds }
801da177e4SLinus Torvalds 
81c065eeeaSTrond Myklebust static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len,
82c065eeeaSTrond Myklebust 		const char **str, size_t maxlen)
831da177e4SLinus Torvalds {
84c065eeeaSTrond Myklebust 	ssize_t err;
851da177e4SLinus Torvalds 
86c065eeeaSTrond Myklebust 	err = xdr_stream_decode_opaque_inline(xdr, (void **)str, maxlen);
87c065eeeaSTrond Myklebust 	if (err < 0)
88c065eeeaSTrond Myklebust 		return cpu_to_be32(NFS4ERR_RESOURCE);
89c065eeeaSTrond Myklebust 	*len = err;
901da177e4SLinus Torvalds 	return 0;
911da177e4SLinus Torvalds }
921da177e4SLinus Torvalds 
93e6f684f6SAl Viro static __be32 decode_fh(struct xdr_stream *xdr, struct nfs_fh *fh)
941da177e4SLinus Torvalds {
955704fdebSAl Viro 	__be32 *p;
961da177e4SLinus Torvalds 
971da177e4SLinus Torvalds 	p = read_buf(xdr, 4);
981da177e4SLinus Torvalds 	if (unlikely(p == NULL))
991da177e4SLinus Torvalds 		return htonl(NFS4ERR_RESOURCE);
1001da177e4SLinus Torvalds 	fh->size = ntohl(*p);
1011da177e4SLinus Torvalds 	if (fh->size > NFS4_FHSIZE)
1021da177e4SLinus Torvalds 		return htonl(NFS4ERR_BADHANDLE);
1031da177e4SLinus Torvalds 	p = read_buf(xdr, fh->size);
1041da177e4SLinus Torvalds 	if (unlikely(p == NULL))
1051da177e4SLinus Torvalds 		return htonl(NFS4ERR_RESOURCE);
1061da177e4SLinus Torvalds 	memcpy(&fh->data[0], p, fh->size);
1071da177e4SLinus Torvalds 	memset(&fh->data[fh->size], 0, sizeof(fh->data) - fh->size);
1081da177e4SLinus Torvalds 	return 0;
1091da177e4SLinus Torvalds }
1101da177e4SLinus Torvalds 
111e6f684f6SAl Viro static __be32 decode_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
1121da177e4SLinus Torvalds {
1135704fdebSAl Viro 	__be32 *p;
1141da177e4SLinus Torvalds 	unsigned int attrlen;
1151da177e4SLinus Torvalds 
1161da177e4SLinus Torvalds 	p = read_buf(xdr, 4);
1171da177e4SLinus Torvalds 	if (unlikely(p == NULL))
1181da177e4SLinus Torvalds 		return htonl(NFS4ERR_RESOURCE);
1191da177e4SLinus Torvalds 	attrlen = ntohl(*p);
1201da177e4SLinus Torvalds 	p = read_buf(xdr, attrlen << 2);
1211da177e4SLinus Torvalds 	if (unlikely(p == NULL))
1221da177e4SLinus Torvalds 		return htonl(NFS4ERR_RESOURCE);
1231da177e4SLinus Torvalds 	if (likely(attrlen > 0))
1241da177e4SLinus Torvalds 		bitmap[0] = ntohl(*p++);
1251da177e4SLinus Torvalds 	if (attrlen > 1)
1261da177e4SLinus Torvalds 		bitmap[1] = ntohl(*p);
1271da177e4SLinus Torvalds 	return 0;
1281da177e4SLinus Torvalds }
1291da177e4SLinus Torvalds 
130e6f684f6SAl Viro static __be32 decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
1311da177e4SLinus Torvalds {
1325704fdebSAl Viro 	__be32 *p;
1331da177e4SLinus Torvalds 
1342d2f24adSTrond Myklebust 	p = read_buf(xdr, NFS4_STATEID_SIZE);
1351da177e4SLinus Torvalds 	if (unlikely(p == NULL))
1361da177e4SLinus Torvalds 		return htonl(NFS4ERR_RESOURCE);
13793b717fdSTrond Myklebust 	memcpy(stateid->data, p, NFS4_STATEID_SIZE);
1381da177e4SLinus Torvalds 	return 0;
1391da177e4SLinus Torvalds }
1401da177e4SLinus Torvalds 
14193b717fdSTrond Myklebust static __be32 decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
14293b717fdSTrond Myklebust {
14393b717fdSTrond Myklebust 	stateid->type = NFS4_DELEGATION_STATEID_TYPE;
14493b717fdSTrond Myklebust 	return decode_stateid(xdr, stateid);
14593b717fdSTrond Myklebust }
14693b717fdSTrond Myklebust 
147e6f684f6SAl Viro static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound_hdr_arg *hdr)
1481da177e4SLinus Torvalds {
1495704fdebSAl Viro 	__be32 *p;
150e6f684f6SAl Viro 	__be32 status;
1511da177e4SLinus Torvalds 
152c065eeeaSTrond Myklebust 	status = decode_string(xdr, &hdr->taglen, &hdr->tag, CB_OP_TAGLEN_MAXSZ);
1531da177e4SLinus Torvalds 	if (unlikely(status != 0))
1541da177e4SLinus Torvalds 		return status;
1551da177e4SLinus Torvalds 	p = read_buf(xdr, 12);
1561da177e4SLinus Torvalds 	if (unlikely(p == NULL))
1571da177e4SLinus Torvalds 		return htonl(NFS4ERR_RESOURCE);
158b8f2ef84SBenny Halevy 	hdr->minorversion = ntohl(*p++);
159459de2edSBryan Schumaker 	/* Check for minor version support */
160459de2edSBryan Schumaker 	if (hdr->minorversion <= NFS4_MAX_MINOR_VERSION) {
16142c2c424SSteve Dickson 		hdr->cb_ident = ntohl(*p++); /* ignored by v4.1 and v4.2 */
16248a9e2d2SBenny Halevy 	} else {
1639a3ba432STrond Myklebust 		pr_warn_ratelimited("NFS: %s: NFSv4 server callback with "
164b8f2ef84SBenny Halevy 			"illegal minor version %u!\n",
165b8f2ef84SBenny Halevy 			__func__, hdr->minorversion);
1661da177e4SLinus Torvalds 		return htonl(NFS4ERR_MINOR_VERS_MISMATCH);
1671da177e4SLinus Torvalds 	}
1681da177e4SLinus Torvalds 	hdr->nops = ntohl(*p);
1691da177e4SLinus Torvalds 	return 0;
1701da177e4SLinus Torvalds }
1711da177e4SLinus Torvalds 
172e6f684f6SAl Viro static __be32 decode_op_hdr(struct xdr_stream *xdr, unsigned int *op)
1731da177e4SLinus Torvalds {
1745704fdebSAl Viro 	__be32 *p;
1751da177e4SLinus Torvalds 	p = read_buf(xdr, 4);
1761da177e4SLinus Torvalds 	if (unlikely(p == NULL))
17731d2b435SAndy Adamson 		return htonl(NFS4ERR_RESOURCE_HDR);
1781da177e4SLinus Torvalds 	*op = ntohl(*p);
1791da177e4SLinus Torvalds 	return 0;
1801da177e4SLinus Torvalds }
1811da177e4SLinus Torvalds 
182f4dac4adSChristoph Hellwig static __be32 decode_getattr_args(struct svc_rqst *rqstp,
183f4dac4adSChristoph Hellwig 		struct xdr_stream *xdr, void *argp)
1841da177e4SLinus Torvalds {
185f4dac4adSChristoph Hellwig 	struct cb_getattrargs *args = argp;
186e6f684f6SAl Viro 	__be32 status;
1871da177e4SLinus Torvalds 
1881da177e4SLinus Torvalds 	status = decode_fh(xdr, &args->fh);
1891da177e4SLinus Torvalds 	if (unlikely(status != 0))
1901da177e4SLinus Torvalds 		return status;
19156938bb7SAnna Schumaker 	return decode_bitmap(xdr, args->bitmap);
1921da177e4SLinus Torvalds }
1931da177e4SLinus Torvalds 
194f4dac4adSChristoph Hellwig static __be32 decode_recall_args(struct svc_rqst *rqstp,
195f4dac4adSChristoph Hellwig 		struct xdr_stream *xdr, void *argp)
1961da177e4SLinus Torvalds {
197f4dac4adSChristoph Hellwig 	struct cb_recallargs *args = argp;
1985704fdebSAl Viro 	__be32 *p;
199e6f684f6SAl Viro 	__be32 status;
2001da177e4SLinus Torvalds 
20193b717fdSTrond Myklebust 	status = decode_delegation_stateid(xdr, &args->stateid);
2021da177e4SLinus Torvalds 	if (unlikely(status != 0))
2033873bc50SAlexey Dobriyan 		return status;
204135a4ea0SAnna Schumaker 	p = read_buf(xdr, 4);
205135a4ea0SAnna Schumaker 	if (unlikely(p == NULL))
206135a4ea0SAnna Schumaker 		return htonl(NFS4ERR_RESOURCE);
207135a4ea0SAnna Schumaker 	args->truncate = ntohl(*p);
208135a4ea0SAnna Schumaker 	return decode_fh(xdr, &args->fh);
2091da177e4SLinus Torvalds }
2101da177e4SLinus Torvalds 
2114aece6a1SBenny Halevy #if defined(CONFIG_NFS_V4_1)
21293b717fdSTrond Myklebust static __be32 decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
21393b717fdSTrond Myklebust {
21493b717fdSTrond Myklebust 	stateid->type = NFS4_LAYOUT_STATEID_TYPE;
21593b717fdSTrond Myklebust 	return decode_stateid(xdr, stateid);
21693b717fdSTrond Myklebust }
2174aece6a1SBenny Halevy 
218f2a62561SFred Isaman static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp,
219f4dac4adSChristoph Hellwig 				       struct xdr_stream *xdr, void *argp)
220f2a62561SFred Isaman {
221f4dac4adSChristoph Hellwig 	struct cb_layoutrecallargs *args = argp;
222f2a62561SFred Isaman 	__be32 *p;
223f2a62561SFred Isaman 	__be32 status = 0;
224f2a62561SFred Isaman 	uint32_t iomode;
225f2a62561SFred Isaman 
226f2a62561SFred Isaman 	p = read_buf(xdr, 4 * sizeof(uint32_t));
227c79d56d2SAnna Schumaker 	if (unlikely(p == NULL))
228c79d56d2SAnna Schumaker 		return htonl(NFS4ERR_BADXDR);
229f2a62561SFred Isaman 
230f2a62561SFred Isaman 	args->cbl_layout_type = ntohl(*p++);
231f2a62561SFred Isaman 	/* Depite the spec's xdr, iomode really belongs in the FILE switch,
23225985edcSLucas De Marchi 	 * as it is unusable and ignored with the other types.
233f2a62561SFred Isaman 	 */
234f2a62561SFred Isaman 	iomode = ntohl(*p++);
235f2a62561SFred Isaman 	args->cbl_layoutchanged = ntohl(*p++);
236f2a62561SFred Isaman 	args->cbl_recall_type = ntohl(*p++);
237f2a62561SFred Isaman 
238f2a62561SFred Isaman 	if (args->cbl_recall_type == RETURN_FILE) {
239f2a62561SFred Isaman 		args->cbl_range.iomode = iomode;
240f2a62561SFred Isaman 		status = decode_fh(xdr, &args->cbl_fh);
241f2a62561SFred Isaman 		if (unlikely(status != 0))
242c79d56d2SAnna Schumaker 			return status;
243f2a62561SFred Isaman 
244f2a62561SFred Isaman 		p = read_buf(xdr, 2 * sizeof(uint64_t));
245c79d56d2SAnna Schumaker 		if (unlikely(p == NULL))
246c79d56d2SAnna Schumaker 			return htonl(NFS4ERR_BADXDR);
247f2a62561SFred Isaman 		p = xdr_decode_hyper(p, &args->cbl_range.offset);
248f2a62561SFred Isaman 		p = xdr_decode_hyper(p, &args->cbl_range.length);
249c79d56d2SAnna Schumaker 		return decode_layout_stateid(xdr, &args->cbl_stateid);
250f2a62561SFred Isaman 	} else if (args->cbl_recall_type == RETURN_FSID) {
251f2a62561SFred Isaman 		p = read_buf(xdr, 2 * sizeof(uint64_t));
252c79d56d2SAnna Schumaker 		if (unlikely(p == NULL))
253c79d56d2SAnna Schumaker 			return htonl(NFS4ERR_BADXDR);
254f2a62561SFred Isaman 		p = xdr_decode_hyper(p, &args->cbl_fsid.major);
255f2a62561SFred Isaman 		p = xdr_decode_hyper(p, &args->cbl_fsid.minor);
256c79d56d2SAnna Schumaker 	} else if (args->cbl_recall_type != RETURN_ALL)
257c79d56d2SAnna Schumaker 		return htonl(NFS4ERR_BADXDR);
258c79d56d2SAnna Schumaker 	return 0;
259f2a62561SFred Isaman }
260f2a62561SFred Isaman 
2611be5683bSMarc Eshel static
2621be5683bSMarc Eshel __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
2631be5683bSMarc Eshel 				struct xdr_stream *xdr,
264f4dac4adSChristoph Hellwig 				void *argp)
2651be5683bSMarc Eshel {
266f4dac4adSChristoph Hellwig 	struct cb_devicenotifyargs *args = argp;
2671be5683bSMarc Eshel 	__be32 *p;
2681be5683bSMarc Eshel 	__be32 status = 0;
2691be5683bSMarc Eshel 	u32 tmp;
2701be5683bSMarc Eshel 	int n, i;
2711be5683bSMarc Eshel 	args->ndevs = 0;
2721be5683bSMarc Eshel 
2731be5683bSMarc Eshel 	/* Num of device notifications */
2741be5683bSMarc Eshel 	p = read_buf(xdr, sizeof(uint32_t));
2751be5683bSMarc Eshel 	if (unlikely(p == NULL)) {
2761be5683bSMarc Eshel 		status = htonl(NFS4ERR_BADXDR);
2771be5683bSMarc Eshel 		goto out;
2781be5683bSMarc Eshel 	}
2791be5683bSMarc Eshel 	n = ntohl(*p++);
2801be5683bSMarc Eshel 	if (n <= 0)
2811be5683bSMarc Eshel 		goto out;
282363e0df0SDan Carpenter 	if (n > ULONG_MAX / sizeof(*args->devs)) {
283363e0df0SDan Carpenter 		status = htonl(NFS4ERR_BADXDR);
284363e0df0SDan Carpenter 		goto out;
285363e0df0SDan Carpenter 	}
2861be5683bSMarc Eshel 
287a4f743a6STrond Myklebust 	args->devs = kmalloc_array(n, sizeof(*args->devs), GFP_KERNEL);
2881be5683bSMarc Eshel 	if (!args->devs) {
2891be5683bSMarc Eshel 		status = htonl(NFS4ERR_DELAY);
2901be5683bSMarc Eshel 		goto out;
2911be5683bSMarc Eshel 	}
2921be5683bSMarc Eshel 
2931be5683bSMarc Eshel 	/* Decode each dev notification */
2941be5683bSMarc Eshel 	for (i = 0; i < n; i++) {
2951be5683bSMarc Eshel 		struct cb_devicenotifyitem *dev = &args->devs[i];
2961be5683bSMarc Eshel 
2971be5683bSMarc Eshel 		p = read_buf(xdr, (4 * sizeof(uint32_t)) + NFS4_DEVICEID4_SIZE);
2981be5683bSMarc Eshel 		if (unlikely(p == NULL)) {
2991be5683bSMarc Eshel 			status = htonl(NFS4ERR_BADXDR);
3001be5683bSMarc Eshel 			goto err;
3011be5683bSMarc Eshel 		}
3021be5683bSMarc Eshel 
3031be5683bSMarc Eshel 		tmp = ntohl(*p++);	/* bitmap size */
3041be5683bSMarc Eshel 		if (tmp != 1) {
3051be5683bSMarc Eshel 			status = htonl(NFS4ERR_INVAL);
3061be5683bSMarc Eshel 			goto err;
3071be5683bSMarc Eshel 		}
3081be5683bSMarc Eshel 		dev->cbd_notify_type = ntohl(*p++);
3091be5683bSMarc Eshel 		if (dev->cbd_notify_type != NOTIFY_DEVICEID4_CHANGE &&
3101be5683bSMarc Eshel 		    dev->cbd_notify_type != NOTIFY_DEVICEID4_DELETE) {
3111be5683bSMarc Eshel 			status = htonl(NFS4ERR_INVAL);
3121be5683bSMarc Eshel 			goto err;
3131be5683bSMarc Eshel 		}
3141be5683bSMarc Eshel 
3151be5683bSMarc Eshel 		tmp = ntohl(*p++);	/* opaque size */
3161be5683bSMarc Eshel 		if (((dev->cbd_notify_type == NOTIFY_DEVICEID4_CHANGE) &&
3171be5683bSMarc Eshel 		     (tmp != NFS4_DEVICEID4_SIZE + 8)) ||
3181be5683bSMarc Eshel 		    ((dev->cbd_notify_type == NOTIFY_DEVICEID4_DELETE) &&
3191be5683bSMarc Eshel 		     (tmp != NFS4_DEVICEID4_SIZE + 4))) {
3201be5683bSMarc Eshel 			status = htonl(NFS4ERR_INVAL);
3211be5683bSMarc Eshel 			goto err;
3221be5683bSMarc Eshel 		}
3231be5683bSMarc Eshel 		dev->cbd_layout_type = ntohl(*p++);
3241be5683bSMarc Eshel 		memcpy(dev->cbd_dev_id.data, p, NFS4_DEVICEID4_SIZE);
3251be5683bSMarc Eshel 		p += XDR_QUADLEN(NFS4_DEVICEID4_SIZE);
3261be5683bSMarc Eshel 
3271be5683bSMarc Eshel 		if (dev->cbd_layout_type == NOTIFY_DEVICEID4_CHANGE) {
3281be5683bSMarc Eshel 			p = read_buf(xdr, sizeof(uint32_t));
3291be5683bSMarc Eshel 			if (unlikely(p == NULL)) {
3301be5683bSMarc Eshel 				status = htonl(NFS4ERR_BADXDR);
3311be5683bSMarc Eshel 				goto err;
3321be5683bSMarc Eshel 			}
3331be5683bSMarc Eshel 			dev->cbd_immediate = ntohl(*p++);
3341be5683bSMarc Eshel 		} else {
3351be5683bSMarc Eshel 			dev->cbd_immediate = 0;
3361be5683bSMarc Eshel 		}
3371be5683bSMarc Eshel 
3381be5683bSMarc Eshel 		args->ndevs++;
3391be5683bSMarc Eshel 
3401be5683bSMarc Eshel 		dprintk("%s: type %d layout 0x%x immediate %d\n",
3411be5683bSMarc Eshel 			__func__, dev->cbd_notify_type, dev->cbd_layout_type,
3421be5683bSMarc Eshel 			dev->cbd_immediate);
3431be5683bSMarc Eshel 	}
3441be5683bSMarc Eshel out:
3451be5683bSMarc Eshel 	dprintk("%s: status %d ndevs %d\n",
3461be5683bSMarc Eshel 		__func__, ntohl(status), args->ndevs);
3471be5683bSMarc Eshel 	return status;
3481be5683bSMarc Eshel err:
3491be5683bSMarc Eshel 	kfree(args->devs);
3501be5683bSMarc Eshel 	goto out;
3511be5683bSMarc Eshel }
3521be5683bSMarc Eshel 
3539733f0d9SAndy Adamson static __be32 decode_sessionid(struct xdr_stream *xdr,
3544aece6a1SBenny Halevy 				 struct nfs4_sessionid *sid)
3554aece6a1SBenny Halevy {
3569733f0d9SAndy Adamson 	__be32 *p;
3574aece6a1SBenny Halevy 
358590184a6SKinglong Mee 	p = read_buf(xdr, NFS4_MAX_SESSIONID_LEN);
3594aece6a1SBenny Halevy 	if (unlikely(p == NULL))
360a419aef8SJoe Perches 		return htonl(NFS4ERR_RESOURCE);
3614aece6a1SBenny Halevy 
362590184a6SKinglong Mee 	memcpy(sid->data, p, NFS4_MAX_SESSIONID_LEN);
3634aece6a1SBenny Halevy 	return 0;
3644aece6a1SBenny Halevy }
3654aece6a1SBenny Halevy 
3669733f0d9SAndy Adamson static __be32 decode_rc_list(struct xdr_stream *xdr,
3674aece6a1SBenny Halevy 			       struct referring_call_list *rc_list)
3684aece6a1SBenny Halevy {
3699733f0d9SAndy Adamson 	__be32 *p;
3704aece6a1SBenny Halevy 	int i;
3719733f0d9SAndy Adamson 	__be32 status;
3724aece6a1SBenny Halevy 
3734aece6a1SBenny Halevy 	status = decode_sessionid(xdr, &rc_list->rcl_sessionid);
3744aece6a1SBenny Halevy 	if (status)
3754aece6a1SBenny Halevy 		goto out;
3764aece6a1SBenny Halevy 
3774aece6a1SBenny Halevy 	status = htonl(NFS4ERR_RESOURCE);
3784aece6a1SBenny Halevy 	p = read_buf(xdr, sizeof(uint32_t));
3794aece6a1SBenny Halevy 	if (unlikely(p == NULL))
3804aece6a1SBenny Halevy 		goto out;
3814aece6a1SBenny Halevy 
3824aece6a1SBenny Halevy 	rc_list->rcl_nrefcalls = ntohl(*p++);
3834aece6a1SBenny Halevy 	if (rc_list->rcl_nrefcalls) {
3844aece6a1SBenny Halevy 		p = read_buf(xdr,
3854aece6a1SBenny Halevy 			     rc_list->rcl_nrefcalls * 2 * sizeof(uint32_t));
3864aece6a1SBenny Halevy 		if (unlikely(p == NULL))
3874aece6a1SBenny Halevy 			goto out;
388a4f743a6STrond Myklebust 		rc_list->rcl_refcalls = kmalloc_array(rc_list->rcl_nrefcalls,
3894aece6a1SBenny Halevy 						sizeof(*rc_list->rcl_refcalls),
3904aece6a1SBenny Halevy 						GFP_KERNEL);
3914aece6a1SBenny Halevy 		if (unlikely(rc_list->rcl_refcalls == NULL))
3924aece6a1SBenny Halevy 			goto out;
3934aece6a1SBenny Halevy 		for (i = 0; i < rc_list->rcl_nrefcalls; i++) {
3944aece6a1SBenny Halevy 			rc_list->rcl_refcalls[i].rc_sequenceid = ntohl(*p++);
3954aece6a1SBenny Halevy 			rc_list->rcl_refcalls[i].rc_slotid = ntohl(*p++);
3964aece6a1SBenny Halevy 		}
3974aece6a1SBenny Halevy 	}
3984aece6a1SBenny Halevy 	status = 0;
3994aece6a1SBenny Halevy 
4004aece6a1SBenny Halevy out:
4014aece6a1SBenny Halevy 	return status;
4024aece6a1SBenny Halevy }
4034aece6a1SBenny Halevy 
4049733f0d9SAndy Adamson static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp,
4054aece6a1SBenny Halevy 					struct xdr_stream *xdr,
406f4dac4adSChristoph Hellwig 					void *argp)
4074aece6a1SBenny Halevy {
408f4dac4adSChristoph Hellwig 	struct cb_sequenceargs *args = argp;
4099733f0d9SAndy Adamson 	__be32 *p;
4104aece6a1SBenny Halevy 	int i;
4119733f0d9SAndy Adamson 	__be32 status;
4124aece6a1SBenny Halevy 
4134aece6a1SBenny Halevy 	status = decode_sessionid(xdr, &args->csa_sessionid);
4144aece6a1SBenny Halevy 	if (status)
4151796549aSAnna Schumaker 		return status;
4164aece6a1SBenny Halevy 
4174aece6a1SBenny Halevy 	p = read_buf(xdr, 5 * sizeof(uint32_t));
4184aece6a1SBenny Halevy 	if (unlikely(p == NULL))
4191796549aSAnna Schumaker 		return htonl(NFS4ERR_RESOURCE);
4204aece6a1SBenny Halevy 
42165fc64e5SRicardo Labiaga 	args->csa_addr = svc_addr(rqstp);
4224aece6a1SBenny Halevy 	args->csa_sequenceid = ntohl(*p++);
4234aece6a1SBenny Halevy 	args->csa_slotid = ntohl(*p++);
4244aece6a1SBenny Halevy 	args->csa_highestslotid = ntohl(*p++);
4254aece6a1SBenny Halevy 	args->csa_cachethis = ntohl(*p++);
4264aece6a1SBenny Halevy 	args->csa_nrclists = ntohl(*p++);
4274aece6a1SBenny Halevy 	args->csa_rclists = NULL;
4284aece6a1SBenny Halevy 	if (args->csa_nrclists) {
4290439f31cSDan Carpenter 		args->csa_rclists = kmalloc_array(args->csa_nrclists,
4304aece6a1SBenny Halevy 						  sizeof(*args->csa_rclists),
4314aece6a1SBenny Halevy 						  GFP_KERNEL);
4324aece6a1SBenny Halevy 		if (unlikely(args->csa_rclists == NULL))
4331796549aSAnna Schumaker 			return htonl(NFS4ERR_RESOURCE);
4344aece6a1SBenny Halevy 
4354aece6a1SBenny Halevy 		for (i = 0; i < args->csa_nrclists; i++) {
4364aece6a1SBenny Halevy 			status = decode_rc_list(xdr, &args->csa_rclists[i]);
437d8ba1f97STrond Myklebust 			if (status) {
438d8ba1f97STrond Myklebust 				args->csa_nrclists = i;
4394aece6a1SBenny Halevy 				goto out_free;
4404aece6a1SBenny Halevy 			}
4414aece6a1SBenny Halevy 		}
442d8ba1f97STrond Myklebust 	}
4431796549aSAnna Schumaker 	return 0;
4444aece6a1SBenny Halevy 
4454aece6a1SBenny Halevy out_free:
4464aece6a1SBenny Halevy 	for (i = 0; i < args->csa_nrclists; i++)
4474aece6a1SBenny Halevy 		kfree(args->csa_rclists[i].rcl_refcalls);
4484aece6a1SBenny Halevy 	kfree(args->csa_rclists);
4491796549aSAnna Schumaker 	return status;
4504aece6a1SBenny Halevy }
4514aece6a1SBenny Halevy 
4529733f0d9SAndy Adamson static __be32 decode_recallany_args(struct svc_rqst *rqstp,
45331f09607SAlexandros Batsakis 				      struct xdr_stream *xdr,
454f4dac4adSChristoph Hellwig 				      void *argp)
45531f09607SAlexandros Batsakis {
456f4dac4adSChristoph Hellwig 	struct cb_recallanyargs *args = argp;
457d743c3c9SPeng Tao 	uint32_t bitmap[2];
458d743c3c9SPeng Tao 	__be32 *p, status;
45931f09607SAlexandros Batsakis 
46031f09607SAlexandros Batsakis 	p = read_buf(xdr, 4);
46131f09607SAlexandros Batsakis 	if (unlikely(p == NULL))
46231f09607SAlexandros Batsakis 		return htonl(NFS4ERR_BADXDR);
46331f09607SAlexandros Batsakis 	args->craa_objs_to_keep = ntohl(*p++);
464d743c3c9SPeng Tao 	status = decode_bitmap(xdr, bitmap);
465d743c3c9SPeng Tao 	if (unlikely(status))
466d743c3c9SPeng Tao 		return status;
467d743c3c9SPeng Tao 	args->craa_type_mask = bitmap[0];
46831f09607SAlexandros Batsakis 
46931f09607SAlexandros Batsakis 	return 0;
47031f09607SAlexandros Batsakis }
47131f09607SAlexandros Batsakis 
4729733f0d9SAndy Adamson static __be32 decode_recallslot_args(struct svc_rqst *rqstp,
473b9efa1b2SAndy Adamson 					struct xdr_stream *xdr,
474f4dac4adSChristoph Hellwig 					void *argp)
475b9efa1b2SAndy Adamson {
476f4dac4adSChristoph Hellwig 	struct cb_recallslotargs *args = argp;
477b9efa1b2SAndy Adamson 	__be32 *p;
478b9efa1b2SAndy Adamson 
479b9efa1b2SAndy Adamson 	p = read_buf(xdr, 4);
480b9efa1b2SAndy Adamson 	if (unlikely(p == NULL))
481b9efa1b2SAndy Adamson 		return htonl(NFS4ERR_BADXDR);
482d5fb4ce3STrond Myklebust 	args->crsa_target_highest_slotid = ntohl(*p++);
483b9efa1b2SAndy Adamson 	return 0;
484b9efa1b2SAndy Adamson }
485b9efa1b2SAndy Adamson 
486db783688SJeff Layton static __be32 decode_lockowner(struct xdr_stream *xdr, struct cb_notify_lock_args *args)
487db783688SJeff Layton {
488db783688SJeff Layton 	__be32		*p;
489db783688SJeff Layton 	unsigned int	len;
490db783688SJeff Layton 
491db783688SJeff Layton 	p = read_buf(xdr, 12);
492db783688SJeff Layton 	if (unlikely(p == NULL))
493db783688SJeff Layton 		return htonl(NFS4ERR_BADXDR);
494db783688SJeff Layton 
495db783688SJeff Layton 	p = xdr_decode_hyper(p, &args->cbnl_owner.clientid);
496db783688SJeff Layton 	len = be32_to_cpu(*p);
497db783688SJeff Layton 
498db783688SJeff Layton 	p = read_buf(xdr, len);
499db783688SJeff Layton 	if (unlikely(p == NULL))
500db783688SJeff Layton 		return htonl(NFS4ERR_BADXDR);
501db783688SJeff Layton 
502db783688SJeff Layton 	/* Only try to decode if the length is right */
503db783688SJeff Layton 	if (len == 20) {
504db783688SJeff Layton 		p += 2;	/* skip "lock id:" */
505db783688SJeff Layton 		args->cbnl_owner.s_dev = be32_to_cpu(*p++);
506db783688SJeff Layton 		xdr_decode_hyper(p, &args->cbnl_owner.id);
507db783688SJeff Layton 		args->cbnl_valid = true;
508db783688SJeff Layton 	} else {
509db783688SJeff Layton 		args->cbnl_owner.s_dev = 0;
510db783688SJeff Layton 		args->cbnl_owner.id = 0;
511db783688SJeff Layton 		args->cbnl_valid = false;
512db783688SJeff Layton 	}
513db783688SJeff Layton 	return 0;
514db783688SJeff Layton }
515db783688SJeff Layton 
516f4dac4adSChristoph Hellwig static __be32 decode_notify_lock_args(struct svc_rqst *rqstp,
517f4dac4adSChristoph Hellwig 		struct xdr_stream *xdr, void *argp)
518db783688SJeff Layton {
519f4dac4adSChristoph Hellwig 	struct cb_notify_lock_args *args = argp;
520db783688SJeff Layton 	__be32 status;
521db783688SJeff Layton 
522db783688SJeff Layton 	status = decode_fh(xdr, &args->cbnl_fh);
523db783688SJeff Layton 	if (unlikely(status != 0))
524db783688SJeff Layton 		return status;
525535ece2bSAnna Schumaker 	return decode_lockowner(xdr, args);
526db783688SJeff Layton }
527db783688SJeff Layton 
5284aece6a1SBenny Halevy #endif /* CONFIG_NFS_V4_1 */
5294aece6a1SBenny Halevy 
530e6f684f6SAl Viro static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
5311da177e4SLinus Torvalds {
532ab6e9aafSTrond Myklebust 	if (unlikely(xdr_stream_encode_opaque(xdr, str, len) < 0))
533ab6e9aafSTrond Myklebust 		return cpu_to_be32(NFS4ERR_RESOURCE);
5341da177e4SLinus Torvalds 	return 0;
5351da177e4SLinus Torvalds }
5361da177e4SLinus Torvalds 
5371da177e4SLinus Torvalds #define CB_SUPPORTED_ATTR0 (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE)
5381da177e4SLinus Torvalds #define CB_SUPPORTED_ATTR1 (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY)
5395704fdebSAl Viro static __be32 encode_attr_bitmap(struct xdr_stream *xdr, const uint32_t *bitmap, __be32 **savep)
5401da177e4SLinus Torvalds {
5415704fdebSAl Viro 	__be32 bm[2];
5425704fdebSAl Viro 	__be32 *p;
5431da177e4SLinus Torvalds 
5441da177e4SLinus Torvalds 	bm[0] = htonl(bitmap[0] & CB_SUPPORTED_ATTR0);
5451da177e4SLinus Torvalds 	bm[1] = htonl(bitmap[1] & CB_SUPPORTED_ATTR1);
5461da177e4SLinus Torvalds 	if (bm[1] != 0) {
5471da177e4SLinus Torvalds 		p = xdr_reserve_space(xdr, 16);
5481da177e4SLinus Torvalds 		if (unlikely(p == NULL))
5491da177e4SLinus Torvalds 			return htonl(NFS4ERR_RESOURCE);
5501da177e4SLinus Torvalds 		*p++ = htonl(2);
5511da177e4SLinus Torvalds 		*p++ = bm[0];
5521da177e4SLinus Torvalds 		*p++ = bm[1];
5531da177e4SLinus Torvalds 	} else if (bm[0] != 0) {
5541da177e4SLinus Torvalds 		p = xdr_reserve_space(xdr, 12);
5551da177e4SLinus Torvalds 		if (unlikely(p == NULL))
5561da177e4SLinus Torvalds 			return htonl(NFS4ERR_RESOURCE);
5571da177e4SLinus Torvalds 		*p++ = htonl(1);
5581da177e4SLinus Torvalds 		*p++ = bm[0];
5591da177e4SLinus Torvalds 	} else {
5601da177e4SLinus Torvalds 		p = xdr_reserve_space(xdr, 8);
5611da177e4SLinus Torvalds 		if (unlikely(p == NULL))
5621da177e4SLinus Torvalds 			return htonl(NFS4ERR_RESOURCE);
5631da177e4SLinus Torvalds 		*p++ = htonl(0);
5641da177e4SLinus Torvalds 	}
5651da177e4SLinus Torvalds 	*savep = p;
5661da177e4SLinus Torvalds 	return 0;
5671da177e4SLinus Torvalds }
5681da177e4SLinus Torvalds 
569e6f684f6SAl Viro static __be32 encode_attr_change(struct xdr_stream *xdr, const uint32_t *bitmap, uint64_t change)
5701da177e4SLinus Torvalds {
5715704fdebSAl Viro 	__be32 *p;
5721da177e4SLinus Torvalds 
5731da177e4SLinus Torvalds 	if (!(bitmap[0] & FATTR4_WORD0_CHANGE))
5741da177e4SLinus Torvalds 		return 0;
5751da177e4SLinus Torvalds 	p = xdr_reserve_space(xdr, 8);
57690dc7d27SHarvey Harrison 	if (unlikely(!p))
5771da177e4SLinus Torvalds 		return htonl(NFS4ERR_RESOURCE);
5781da177e4SLinus Torvalds 	p = xdr_encode_hyper(p, change);
5791da177e4SLinus Torvalds 	return 0;
5801da177e4SLinus Torvalds }
5811da177e4SLinus Torvalds 
582e6f684f6SAl Viro static __be32 encode_attr_size(struct xdr_stream *xdr, const uint32_t *bitmap, uint64_t size)
5831da177e4SLinus Torvalds {
5845704fdebSAl Viro 	__be32 *p;
5851da177e4SLinus Torvalds 
5861da177e4SLinus Torvalds 	if (!(bitmap[0] & FATTR4_WORD0_SIZE))
5871da177e4SLinus Torvalds 		return 0;
5881da177e4SLinus Torvalds 	p = xdr_reserve_space(xdr, 8);
58990dc7d27SHarvey Harrison 	if (unlikely(!p))
5901da177e4SLinus Torvalds 		return htonl(NFS4ERR_RESOURCE);
5911da177e4SLinus Torvalds 	p = xdr_encode_hyper(p, size);
5921da177e4SLinus Torvalds 	return 0;
5931da177e4SLinus Torvalds }
5941da177e4SLinus Torvalds 
595e6f684f6SAl Viro static __be32 encode_attr_time(struct xdr_stream *xdr, const struct timespec *time)
5961da177e4SLinus Torvalds {
5975704fdebSAl Viro 	__be32 *p;
5981da177e4SLinus Torvalds 
5991da177e4SLinus Torvalds 	p = xdr_reserve_space(xdr, 12);
60090dc7d27SHarvey Harrison 	if (unlikely(!p))
6011da177e4SLinus Torvalds 		return htonl(NFS4ERR_RESOURCE);
6021da177e4SLinus Torvalds 	p = xdr_encode_hyper(p, time->tv_sec);
6031da177e4SLinus Torvalds 	*p = htonl(time->tv_nsec);
6041da177e4SLinus Torvalds 	return 0;
6051da177e4SLinus Torvalds }
6061da177e4SLinus Torvalds 
607e6f684f6SAl Viro static __be32 encode_attr_ctime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec *time)
6081da177e4SLinus Torvalds {
6091da177e4SLinus Torvalds 	if (!(bitmap[1] & FATTR4_WORD1_TIME_METADATA))
6101da177e4SLinus Torvalds 		return 0;
6111da177e4SLinus Torvalds 	return encode_attr_time(xdr,time);
6121da177e4SLinus Torvalds }
6131da177e4SLinus Torvalds 
614e6f684f6SAl Viro static __be32 encode_attr_mtime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec *time)
6151da177e4SLinus Torvalds {
6161da177e4SLinus Torvalds 	if (!(bitmap[1] & FATTR4_WORD1_TIME_MODIFY))
6171da177e4SLinus Torvalds 		return 0;
6181da177e4SLinus Torvalds 	return encode_attr_time(xdr,time);
6191da177e4SLinus Torvalds }
6201da177e4SLinus Torvalds 
621e6f684f6SAl Viro static __be32 encode_compound_hdr_res(struct xdr_stream *xdr, struct cb_compound_hdr_res *hdr)
6221da177e4SLinus Torvalds {
623e6f684f6SAl Viro 	__be32 status;
6241da177e4SLinus Torvalds 
6251da177e4SLinus Torvalds 	hdr->status = xdr_reserve_space(xdr, 4);
6261da177e4SLinus Torvalds 	if (unlikely(hdr->status == NULL))
6271da177e4SLinus Torvalds 		return htonl(NFS4ERR_RESOURCE);
6281da177e4SLinus Torvalds 	status = encode_string(xdr, hdr->taglen, hdr->tag);
6291da177e4SLinus Torvalds 	if (unlikely(status != 0))
6301da177e4SLinus Torvalds 		return status;
6311da177e4SLinus Torvalds 	hdr->nops = xdr_reserve_space(xdr, 4);
6321da177e4SLinus Torvalds 	if (unlikely(hdr->nops == NULL))
6331da177e4SLinus Torvalds 		return htonl(NFS4ERR_RESOURCE);
6341da177e4SLinus Torvalds 	return 0;
6351da177e4SLinus Torvalds }
6361da177e4SLinus Torvalds 
637e6f684f6SAl Viro static __be32 encode_op_hdr(struct xdr_stream *xdr, uint32_t op, __be32 res)
6381da177e4SLinus Torvalds {
6395704fdebSAl Viro 	__be32 *p;
6401da177e4SLinus Torvalds 
6411da177e4SLinus Torvalds 	p = xdr_reserve_space(xdr, 8);
6421da177e4SLinus Torvalds 	if (unlikely(p == NULL))
64331d2b435SAndy Adamson 		return htonl(NFS4ERR_RESOURCE_HDR);
6441da177e4SLinus Torvalds 	*p++ = htonl(op);
6451da177e4SLinus Torvalds 	*p = res;
6461da177e4SLinus Torvalds 	return 0;
6471da177e4SLinus Torvalds }
6481da177e4SLinus Torvalds 
649f4dac4adSChristoph Hellwig static __be32 encode_getattr_res(struct svc_rqst *rqstp, struct xdr_stream *xdr,
650f4dac4adSChristoph Hellwig 		const void *resp)
6511da177e4SLinus Torvalds {
652f4dac4adSChristoph Hellwig 	const struct cb_getattrres *res = resp;
6535704fdebSAl Viro 	__be32 *savep = NULL;
654e6f684f6SAl Viro 	__be32 status = res->status;
6551da177e4SLinus Torvalds 
6561da177e4SLinus Torvalds 	if (unlikely(status != 0))
6571da177e4SLinus Torvalds 		goto out;
6581da177e4SLinus Torvalds 	status = encode_attr_bitmap(xdr, res->bitmap, &savep);
6591da177e4SLinus Torvalds 	if (unlikely(status != 0))
6601da177e4SLinus Torvalds 		goto out;
6611da177e4SLinus Torvalds 	status = encode_attr_change(xdr, res->bitmap, res->change_attr);
6621da177e4SLinus Torvalds 	if (unlikely(status != 0))
6631da177e4SLinus Torvalds 		goto out;
6641da177e4SLinus Torvalds 	status = encode_attr_size(xdr, res->bitmap, res->size);
6651da177e4SLinus Torvalds 	if (unlikely(status != 0))
6661da177e4SLinus Torvalds 		goto out;
6671da177e4SLinus Torvalds 	status = encode_attr_ctime(xdr, res->bitmap, &res->ctime);
6681da177e4SLinus Torvalds 	if (unlikely(status != 0))
6691da177e4SLinus Torvalds 		goto out;
6701da177e4SLinus Torvalds 	status = encode_attr_mtime(xdr, res->bitmap, &res->mtime);
6711da177e4SLinus Torvalds 	*savep = htonl((unsigned int)((char *)xdr->p - (char *)(savep+1)));
6721da177e4SLinus Torvalds out:
6731da177e4SLinus Torvalds 	return status;
6741da177e4SLinus Torvalds }
6751da177e4SLinus Torvalds 
67634bc47c9SBenny Halevy #if defined(CONFIG_NFS_V4_1)
67734bc47c9SBenny Halevy 
6789733f0d9SAndy Adamson static __be32 encode_sessionid(struct xdr_stream *xdr,
6794aece6a1SBenny Halevy 				 const struct nfs4_sessionid *sid)
6804aece6a1SBenny Halevy {
6819733f0d9SAndy Adamson 	__be32 *p;
6824aece6a1SBenny Halevy 
683590184a6SKinglong Mee 	p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN);
6844aece6a1SBenny Halevy 	if (unlikely(p == NULL))
6854aece6a1SBenny Halevy 		return htonl(NFS4ERR_RESOURCE);
6864aece6a1SBenny Halevy 
687590184a6SKinglong Mee 	memcpy(p, sid, NFS4_MAX_SESSIONID_LEN);
6884aece6a1SBenny Halevy 	return 0;
6894aece6a1SBenny Halevy }
6904aece6a1SBenny Halevy 
6919733f0d9SAndy Adamson static __be32 encode_cb_sequence_res(struct svc_rqst *rqstp,
6924aece6a1SBenny Halevy 				       struct xdr_stream *xdr,
693f4dac4adSChristoph Hellwig 				       const void *resp)
6944aece6a1SBenny Halevy {
695f4dac4adSChristoph Hellwig 	const struct cb_sequenceres *res = resp;
6969733f0d9SAndy Adamson 	__be32 *p;
697e216c8c7SDan Carpenter 	__be32 status = res->csr_status;
6984aece6a1SBenny Halevy 
6994aece6a1SBenny Halevy 	if (unlikely(status != 0))
7003d0bfaa6SAnna Schumaker 		return status;
7014aece6a1SBenny Halevy 
702e0a63c0bSKinglong Mee 	status = encode_sessionid(xdr, &res->csr_sessionid);
703e0a63c0bSKinglong Mee 	if (status)
7043d0bfaa6SAnna Schumaker 		return status;
7054aece6a1SBenny Halevy 
7064aece6a1SBenny Halevy 	p = xdr_reserve_space(xdr, 4 * sizeof(uint32_t));
7074aece6a1SBenny Halevy 	if (unlikely(p == NULL))
7084aece6a1SBenny Halevy 		return htonl(NFS4ERR_RESOURCE);
7094aece6a1SBenny Halevy 
7104aece6a1SBenny Halevy 	*p++ = htonl(res->csr_sequenceid);
7114aece6a1SBenny Halevy 	*p++ = htonl(res->csr_slotid);
7124aece6a1SBenny Halevy 	*p++ = htonl(res->csr_highestslotid);
7134aece6a1SBenny Halevy 	*p++ = htonl(res->csr_target_highestslotid);
7143d0bfaa6SAnna Schumaker 	return 0;
7154aece6a1SBenny Halevy }
7164aece6a1SBenny Halevy 
71734bc47c9SBenny Halevy static __be32
71834bc47c9SBenny Halevy preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op)
71934bc47c9SBenny Halevy {
720281fe15dSBenny Halevy 	if (op_nr == OP_CB_SEQUENCE) {
721281fe15dSBenny Halevy 		if (nop != 0)
722281fe15dSBenny Halevy 			return htonl(NFS4ERR_SEQUENCE_POS);
723281fe15dSBenny Halevy 	} else {
724281fe15dSBenny Halevy 		if (nop == 0)
725281fe15dSBenny Halevy 			return htonl(NFS4ERR_OP_NOT_IN_SESSION);
726281fe15dSBenny Halevy 	}
727281fe15dSBenny Halevy 
72834bc47c9SBenny Halevy 	switch (op_nr) {
72934bc47c9SBenny Halevy 	case OP_CB_GETATTR:
73034bc47c9SBenny Halevy 	case OP_CB_RECALL:
7314aece6a1SBenny Halevy 	case OP_CB_SEQUENCE:
73231f09607SAlexandros Batsakis 	case OP_CB_RECALL_ANY:
733b9efa1b2SAndy Adamson 	case OP_CB_RECALL_SLOT:
734f2a62561SFred Isaman 	case OP_CB_LAYOUTRECALL:
7351be5683bSMarc Eshel 	case OP_CB_NOTIFY_DEVICEID:
736db783688SJeff Layton 	case OP_CB_NOTIFY_LOCK:
73734bc47c9SBenny Halevy 		*op = &callback_ops[op_nr];
73834bc47c9SBenny Halevy 		break;
73934bc47c9SBenny Halevy 
74034bc47c9SBenny Halevy 	case OP_CB_NOTIFY:
74134bc47c9SBenny Halevy 	case OP_CB_PUSH_DELEG:
74234bc47c9SBenny Halevy 	case OP_CB_RECALLABLE_OBJ_AVAIL:
74334bc47c9SBenny Halevy 	case OP_CB_WANTS_CANCELLED:
74434bc47c9SBenny Halevy 		return htonl(NFS4ERR_NOTSUPP);
74534bc47c9SBenny Halevy 
74634bc47c9SBenny Halevy 	default:
74734bc47c9SBenny Halevy 		return htonl(NFS4ERR_OP_ILLEGAL);
74834bc47c9SBenny Halevy 	}
74934bc47c9SBenny Halevy 
75034bc47c9SBenny Halevy 	return htonl(NFS_OK);
75134bc47c9SBenny Halevy }
75234bc47c9SBenny Halevy 
753810d82e6STrond Myklebust static void nfs4_callback_free_slot(struct nfs4_session *session,
754810d82e6STrond Myklebust 		struct nfs4_slot *slot)
75542acd021SAndy Adamson {
75642acd021SAndy Adamson 	struct nfs4_slot_table *tbl = &session->bc_slot_table;
75742acd021SAndy Adamson 
75842acd021SAndy Adamson 	spin_lock(&tbl->slot_tbl_lock);
75942acd021SAndy Adamson 	/*
76042acd021SAndy Adamson 	 * Let the state manager know callback processing done.
76142acd021SAndy Adamson 	 * A single slot, so highest used slotid is either 0 or -1
76242acd021SAndy Adamson 	 */
763810d82e6STrond Myklebust 	nfs4_free_slot(tbl, slot);
764774d5f14SAndy Adamson 	nfs4_slot_tbl_drain_complete(tbl);
76542acd021SAndy Adamson 	spin_unlock(&tbl->slot_tbl_lock);
76642acd021SAndy Adamson }
76742acd021SAndy Adamson 
76855a67399STrond Myklebust static void nfs4_cb_free_slot(struct cb_process_state *cps)
76942acd021SAndy Adamson {
770810d82e6STrond Myklebust 	if (cps->slot) {
771810d82e6STrond Myklebust 		nfs4_callback_free_slot(cps->clp->cl_session, cps->slot);
772810d82e6STrond Myklebust 		cps->slot = NULL;
773810d82e6STrond Myklebust 	}
77442acd021SAndy Adamson }
77542acd021SAndy Adamson 
77634bc47c9SBenny Halevy #else /* CONFIG_NFS_V4_1 */
77734bc47c9SBenny Halevy 
77834bc47c9SBenny Halevy static __be32
77934bc47c9SBenny Halevy preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op)
78034bc47c9SBenny Halevy {
78134bc47c9SBenny Halevy 	return htonl(NFS4ERR_MINOR_VERS_MISMATCH);
78234bc47c9SBenny Halevy }
78334bc47c9SBenny Halevy 
78455a67399STrond Myklebust static void nfs4_cb_free_slot(struct cb_process_state *cps)
78542acd021SAndy Adamson {
78642acd021SAndy Adamson }
78734bc47c9SBenny Halevy #endif /* CONFIG_NFS_V4_1 */
78834bc47c9SBenny Halevy 
7896b140b85SBryan Schumaker #ifdef CONFIG_NFS_V4_2
7906b140b85SBryan Schumaker static __be32
7916b140b85SBryan Schumaker preprocess_nfs42_op(int nop, unsigned int op_nr, struct callback_op **op)
7926b140b85SBryan Schumaker {
7936b140b85SBryan Schumaker 	__be32 status = preprocess_nfs41_op(nop, op_nr, op);
7946b140b85SBryan Schumaker 	if (status != htonl(NFS4ERR_OP_ILLEGAL))
7956b140b85SBryan Schumaker 		return status;
7966b140b85SBryan Schumaker 
7976b140b85SBryan Schumaker 	if (op_nr == OP_CB_OFFLOAD)
7986b140b85SBryan Schumaker 		return htonl(NFS4ERR_NOTSUPP);
7996b140b85SBryan Schumaker 	return htonl(NFS4ERR_OP_ILLEGAL);
8006b140b85SBryan Schumaker }
8016b140b85SBryan Schumaker #else /* CONFIG_NFS_V4_2 */
8026b140b85SBryan Schumaker static __be32
8036b140b85SBryan Schumaker preprocess_nfs42_op(int nop, unsigned int op_nr, struct callback_op **op)
8046b140b85SBryan Schumaker {
8056b140b85SBryan Schumaker 	return htonl(NFS4ERR_MINOR_VERS_MISMATCH);
8066b140b85SBryan Schumaker }
8076b140b85SBryan Schumaker #endif /* CONFIG_NFS_V4_2 */
8086b140b85SBryan Schumaker 
80934bc47c9SBenny Halevy static __be32
81034bc47c9SBenny Halevy preprocess_nfs4_op(unsigned int op_nr, struct callback_op **op)
81134bc47c9SBenny Halevy {
81234bc47c9SBenny Halevy 	switch (op_nr) {
81334bc47c9SBenny Halevy 	case OP_CB_GETATTR:
81434bc47c9SBenny Halevy 	case OP_CB_RECALL:
81534bc47c9SBenny Halevy 		*op = &callback_ops[op_nr];
81634bc47c9SBenny Halevy 		break;
81734bc47c9SBenny Halevy 	default:
81834bc47c9SBenny Halevy 		return htonl(NFS4ERR_OP_ILLEGAL);
81934bc47c9SBenny Halevy 	}
82034bc47c9SBenny Halevy 
82134bc47c9SBenny Halevy 	return htonl(NFS_OK);
82234bc47c9SBenny Halevy }
82334bc47c9SBenny Halevy 
824459de2edSBryan Schumaker static __be32 process_op(int nop, struct svc_rqst *rqstp,
8251da177e4SLinus Torvalds 		struct xdr_stream *xdr_in, void *argp,
826c36fca52SAndy Adamson 		struct xdr_stream *xdr_out, void *resp,
827c36fca52SAndy Adamson 		struct cb_process_state *cps)
8281da177e4SLinus Torvalds {
829a162a6b8STrond Myklebust 	struct callback_op *op = &callback_ops[0];
83031d2b435SAndy Adamson 	unsigned int op_nr;
83134bc47c9SBenny Halevy 	__be32 status;
8321da177e4SLinus Torvalds 	long maxlen;
833e6f684f6SAl Viro 	__be32 res;
8341da177e4SLinus Torvalds 
8351da177e4SLinus Torvalds 	status = decode_op_hdr(xdr_in, &op_nr);
83631d2b435SAndy Adamson 	if (unlikely(status))
83731d2b435SAndy Adamson 		return status;
8381da177e4SLinus Torvalds 
8396b140b85SBryan Schumaker 	switch (cps->minorversion) {
8406b140b85SBryan Schumaker 	case 0:
8416b140b85SBryan Schumaker 		status = preprocess_nfs4_op(op_nr, &op);
8426b140b85SBryan Schumaker 		break;
8436b140b85SBryan Schumaker 	case 1:
8446b140b85SBryan Schumaker 		status = preprocess_nfs41_op(nop, op_nr, &op);
8456b140b85SBryan Schumaker 		break;
8466b140b85SBryan Schumaker 	case 2:
8476b140b85SBryan Schumaker 		status = preprocess_nfs42_op(nop, op_nr, &op);
8486b140b85SBryan Schumaker 		break;
8496b140b85SBryan Schumaker 	default:
8506b140b85SBryan Schumaker 		status = htonl(NFS4ERR_MINOR_VERS_MISMATCH);
8516b140b85SBryan Schumaker 	}
8526b140b85SBryan Schumaker 
85334bc47c9SBenny Halevy 	if (status == htonl(NFS4ERR_OP_ILLEGAL))
85434bc47c9SBenny Halevy 		op_nr = OP_CB_ILLEGAL;
855b92b3019SAndy Adamson 	if (status)
856b92b3019SAndy Adamson 		goto encode_hdr;
85731d2b435SAndy Adamson 
858c36fca52SAndy Adamson 	if (cps->drc_status) {
859c36fca52SAndy Adamson 		status = cps->drc_status;
8604911096fSAndy Adamson 		goto encode_hdr;
8614911096fSAndy Adamson 	}
8624911096fSAndy Adamson 
8631da177e4SLinus Torvalds 	maxlen = xdr_out->end - xdr_out->p;
8641da177e4SLinus Torvalds 	if (maxlen > 0 && maxlen < PAGE_SIZE) {
8651da177e4SLinus Torvalds 		status = op->decode_args(rqstp, xdr_in, argp);
866e95e60daSAndy Adamson 		if (likely(status == 0))
867c36fca52SAndy Adamson 			status = op->process_op(argp, resp, cps);
8681da177e4SLinus Torvalds 	} else
8691da177e4SLinus Torvalds 		status = htonl(NFS4ERR_RESOURCE);
8701da177e4SLinus Torvalds 
871b92b3019SAndy Adamson encode_hdr:
8721da177e4SLinus Torvalds 	res = encode_op_hdr(xdr_out, op_nr, status);
87331d2b435SAndy Adamson 	if (unlikely(res))
87431d2b435SAndy Adamson 		return res;
8751da177e4SLinus Torvalds 	if (op->encode_res != NULL && status == 0)
8761da177e4SLinus Torvalds 		status = op->encode_res(rqstp, xdr_out, resp);
8771da177e4SLinus Torvalds 	return status;
8781da177e4SLinus Torvalds }
8791da177e4SLinus Torvalds 
8801da177e4SLinus Torvalds /*
8811da177e4SLinus Torvalds  * Decode, process and encode a COMPOUND
8821da177e4SLinus Torvalds  */
883a6beb732SChristoph Hellwig static __be32 nfs4_callback_compound(struct svc_rqst *rqstp)
8841da177e4SLinus Torvalds {
8853a6258e1STrond Myklebust 	struct cb_compound_hdr_arg hdr_arg = { 0 };
8863a6258e1STrond Myklebust 	struct cb_compound_hdr_res hdr_res = { NULL };
8871da177e4SLinus Torvalds 	struct xdr_stream xdr_in, xdr_out;
888c36fca52SAndy Adamson 	__be32 *p, status;
889c36fca52SAndy Adamson 	struct cb_process_state cps = {
890c36fca52SAndy Adamson 		.drc_status = 0,
891c36fca52SAndy Adamson 		.clp = NULL,
8929695c705SStanislav Kinsbursky 		.net = SVC_NET(rqstp),
893c36fca52SAndy Adamson 	};
8943a6258e1STrond Myklebust 	unsigned int nops = 0;
8951da177e4SLinus Torvalds 
896756b9b37STrond Myklebust 	xdr_init_decode(&xdr_in, &rqstp->rq_arg, rqstp->rq_arg.head[0].iov_base);
8971da177e4SLinus Torvalds 
8985704fdebSAl Viro 	p = (__be32*)((char *)rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len);
8991da177e4SLinus Torvalds 	xdr_init_encode(&xdr_out, &rqstp->rq_res, p);
9001da177e4SLinus Torvalds 
9013a6258e1STrond Myklebust 	status = decode_compound_hdr_arg(&xdr_in, &hdr_arg);
9024ed0d83dSVaishali Thakkar 	if (status == htonl(NFS4ERR_RESOURCE))
9033a6258e1STrond Myklebust 		return rpc_garbage_args;
9043a6258e1STrond Myklebust 
905c36fca52SAndy Adamson 	if (hdr_arg.minorversion == 0) {
9069695c705SStanislav Kinsbursky 		cps.clp = nfs4_find_client_ident(SVC_NET(rqstp), hdr_arg.cb_ident);
907778be232SAndy Adamson 		if (!cps.clp || !check_gss_callback_principal(cps.clp, rqstp))
908a4e187d8SChuck Lever 			goto out_invalidcred;
909778be232SAndy Adamson 	}
910c36fca52SAndy Adamson 
911459de2edSBryan Schumaker 	cps.minorversion = hdr_arg.minorversion;
9121da177e4SLinus Torvalds 	hdr_res.taglen = hdr_arg.taglen;
9131da177e4SLinus Torvalds 	hdr_res.tag = hdr_arg.tag;
9143a6258e1STrond Myklebust 	if (encode_compound_hdr_res(&xdr_out, &hdr_res) != 0)
9153a6258e1STrond Myklebust 		return rpc_system_err;
9161da177e4SLinus Torvalds 
9173a6258e1STrond Myklebust 	while (status == 0 && nops != hdr_arg.nops) {
918459de2edSBryan Schumaker 		status = process_op(nops, rqstp, &xdr_in,
919a6beb732SChristoph Hellwig 				    rqstp->rq_argp, &xdr_out, rqstp->rq_resp,
920a6beb732SChristoph Hellwig 				    &cps);
9211da177e4SLinus Torvalds 		nops++;
9221da177e4SLinus Torvalds 	}
9233a6258e1STrond Myklebust 
92431d2b435SAndy Adamson 	/* Buffer overflow in decode_ops_hdr or encode_ops_hdr. Return
92531d2b435SAndy Adamson 	* resource error in cb_compound status without returning op */
92631d2b435SAndy Adamson 	if (unlikely(status == htonl(NFS4ERR_RESOURCE_HDR))) {
92731d2b435SAndy Adamson 		status = htonl(NFS4ERR_RESOURCE);
92831d2b435SAndy Adamson 		nops--;
92931d2b435SAndy Adamson 	}
93031d2b435SAndy Adamson 
9311da177e4SLinus Torvalds 	*hdr_res.status = status;
9321da177e4SLinus Torvalds 	*hdr_res.nops = htonl(nops);
93355a67399STrond Myklebust 	nfs4_cb_free_slot(&cps);
934c36fca52SAndy Adamson 	nfs_put_client(cps.clp);
9351da177e4SLinus Torvalds 	return rpc_success;
936a4e187d8SChuck Lever 
937a4e187d8SChuck Lever out_invalidcred:
938a4e187d8SChuck Lever 	pr_warn_ratelimited("NFS: NFSv4 callback contains invalid cred\n");
939a4e187d8SChuck Lever 	return rpc_autherr_badcred;
9401da177e4SLinus Torvalds }
9411da177e4SLinus Torvalds 
9421da177e4SLinus Torvalds /*
9431da177e4SLinus Torvalds  * Define NFS4 callback COMPOUND ops.
9441da177e4SLinus Torvalds  */
9451da177e4SLinus Torvalds static struct callback_op callback_ops[] = {
9461da177e4SLinus Torvalds 	[0] = {
9471da177e4SLinus Torvalds 		.res_maxsize = CB_OP_HDR_RES_MAXSZ,
9481da177e4SLinus Torvalds 	},
9491da177e4SLinus Torvalds 	[OP_CB_GETATTR] = {
950f4dac4adSChristoph Hellwig 		.process_op = nfs4_callback_getattr,
951f4dac4adSChristoph Hellwig 		.decode_args = decode_getattr_args,
952f4dac4adSChristoph Hellwig 		.encode_res = encode_getattr_res,
9531da177e4SLinus Torvalds 		.res_maxsize = CB_OP_GETATTR_RES_MAXSZ,
9541da177e4SLinus Torvalds 	},
9551da177e4SLinus Torvalds 	[OP_CB_RECALL] = {
956f4dac4adSChristoph Hellwig 		.process_op = nfs4_callback_recall,
957f4dac4adSChristoph Hellwig 		.decode_args = decode_recall_args,
9581da177e4SLinus Torvalds 		.res_maxsize = CB_OP_RECALL_RES_MAXSZ,
9594aece6a1SBenny Halevy 	},
9604aece6a1SBenny Halevy #if defined(CONFIG_NFS_V4_1)
961f2a62561SFred Isaman 	[OP_CB_LAYOUTRECALL] = {
962f4dac4adSChristoph Hellwig 		.process_op = nfs4_callback_layoutrecall,
963f4dac4adSChristoph Hellwig 		.decode_args = decode_layoutrecall_args,
964f2a62561SFred Isaman 		.res_maxsize = CB_OP_LAYOUTRECALL_RES_MAXSZ,
965f2a62561SFred Isaman 	},
9661be5683bSMarc Eshel 	[OP_CB_NOTIFY_DEVICEID] = {
967f4dac4adSChristoph Hellwig 		.process_op = nfs4_callback_devicenotify,
968f4dac4adSChristoph Hellwig 		.decode_args = decode_devicenotify_args,
9691be5683bSMarc Eshel 		.res_maxsize = CB_OP_DEVICENOTIFY_RES_MAXSZ,
9701be5683bSMarc Eshel 	},
9714aece6a1SBenny Halevy 	[OP_CB_SEQUENCE] = {
972f4dac4adSChristoph Hellwig 		.process_op = nfs4_callback_sequence,
973f4dac4adSChristoph Hellwig 		.decode_args = decode_cb_sequence_args,
974f4dac4adSChristoph Hellwig 		.encode_res = encode_cb_sequence_res,
9754aece6a1SBenny Halevy 		.res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ,
9764aece6a1SBenny Halevy 	},
97731f09607SAlexandros Batsakis 	[OP_CB_RECALL_ANY] = {
978f4dac4adSChristoph Hellwig 		.process_op = nfs4_callback_recallany,
979f4dac4adSChristoph Hellwig 		.decode_args = decode_recallany_args,
98031f09607SAlexandros Batsakis 		.res_maxsize = CB_OP_RECALLANY_RES_MAXSZ,
98131f09607SAlexandros Batsakis 	},
982b9efa1b2SAndy Adamson 	[OP_CB_RECALL_SLOT] = {
983f4dac4adSChristoph Hellwig 		.process_op = nfs4_callback_recallslot,
984f4dac4adSChristoph Hellwig 		.decode_args = decode_recallslot_args,
985b9efa1b2SAndy Adamson 		.res_maxsize = CB_OP_RECALLSLOT_RES_MAXSZ,
986b9efa1b2SAndy Adamson 	},
987db783688SJeff Layton 	[OP_CB_NOTIFY_LOCK] = {
988f4dac4adSChristoph Hellwig 		.process_op = nfs4_callback_notify_lock,
989f4dac4adSChristoph Hellwig 		.decode_args = decode_notify_lock_args,
990db783688SJeff Layton 		.res_maxsize = CB_OP_NOTIFY_LOCK_RES_MAXSZ,
991db783688SJeff Layton 	},
9924aece6a1SBenny Halevy #endif /* CONFIG_NFS_V4_1 */
9931da177e4SLinus Torvalds };
9941da177e4SLinus Torvalds 
9951da177e4SLinus Torvalds /*
9961da177e4SLinus Torvalds  * Define NFS4 callback procedures
9971da177e4SLinus Torvalds  */
9981da177e4SLinus Torvalds static struct svc_procedure nfs4_callback_procedures1[] = {
9991da177e4SLinus Torvalds 	[CB_NULL] = {
10001da177e4SLinus Torvalds 		.pc_func = nfs4_callback_null,
1001026fec7eSChristoph Hellwig 		.pc_decode = nfs4_decode_void,
10021da177e4SLinus Torvalds 		.pc_encode = (kxdrproc_t)nfs4_encode_void,
10031da177e4SLinus Torvalds 		.pc_xdrressize = 1,
10041da177e4SLinus Torvalds 	},
10051da177e4SLinus Torvalds 	[CB_COMPOUND] = {
10061da177e4SLinus Torvalds 		.pc_func = nfs4_callback_compound,
10071da177e4SLinus Torvalds 		.pc_encode = (kxdrproc_t)nfs4_encode_void,
10081da177e4SLinus Torvalds 		.pc_argsize = 256,
10091da177e4SLinus Torvalds 		.pc_ressize = 256,
10101da177e4SLinus Torvalds 		.pc_xdrressize = NFS4_CALLBACK_BUFSIZE,
10111da177e4SLinus Torvalds 	}
10121da177e4SLinus Torvalds };
10131da177e4SLinus Torvalds 
10141da177e4SLinus Torvalds struct svc_version nfs4_callback_version1 = {
10151da177e4SLinus Torvalds 	.vs_vers = 1,
10161da177e4SLinus Torvalds 	.vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1),
10171da177e4SLinus Torvalds 	.vs_proc = nfs4_callback_procedures1,
10181da177e4SLinus Torvalds 	.vs_xdrsize = NFS4_CALLBACK_XDRSIZE,
10191da177e4SLinus Torvalds 	.vs_dispatch = NULL,
102005a45a2dSJeff Layton 	.vs_hidden = true,
10215283b03eSJeff Layton 	.vs_need_cong_ctrl = true,
10221da177e4SLinus Torvalds };
10231da177e4SLinus Torvalds 
102407bccc2dSAlexandros Batsakis struct svc_version nfs4_callback_version4 = {
102507bccc2dSAlexandros Batsakis 	.vs_vers = 4,
102607bccc2dSAlexandros Batsakis 	.vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1),
102707bccc2dSAlexandros Batsakis 	.vs_proc = nfs4_callback_procedures1,
102807bccc2dSAlexandros Batsakis 	.vs_xdrsize = NFS4_CALLBACK_XDRSIZE,
102907bccc2dSAlexandros Batsakis 	.vs_dispatch = NULL,
103005a45a2dSJeff Layton 	.vs_hidden = true,
10315283b03eSJeff Layton 	.vs_need_cong_ctrl = true,
103207bccc2dSAlexandros Batsakis };
1033