1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * linux/fs/nfs/callback_xdr.c 41da177e4SLinus Torvalds * 51da177e4SLinus Torvalds * Copyright (C) 2004 Trond Myklebust 61da177e4SLinus Torvalds * 71da177e4SLinus Torvalds * NFSv4 callback encode/decode procedures 81da177e4SLinus Torvalds */ 91da177e4SLinus Torvalds #include <linux/kernel.h> 101da177e4SLinus Torvalds #include <linux/sunrpc/svc.h> 111da177e4SLinus Torvalds #include <linux/nfs4.h> 121da177e4SLinus Torvalds #include <linux/nfs_fs.h> 139a3ba432STrond Myklebust #include <linux/ratelimit.h> 149a3ba432STrond Myklebust #include <linux/printk.h> 155a0e3ad6STejun Heo #include <linux/slab.h> 16c36fca52SAndy Adamson #include <linux/sunrpc/bc_xprt.h> 174ce79717STrond Myklebust #include "nfs4_fs.h" 181da177e4SLinus Torvalds #include "callback.h" 19c36fca52SAndy Adamson #include "internal.h" 2076e697baSTrond Myklebust #include "nfs4session.h" 211da177e4SLinus Torvalds 221da177e4SLinus Torvalds #define CB_OP_TAGLEN_MAXSZ (512) 2345724e8aSKinglong Mee #define CB_OP_HDR_RES_MAXSZ (2 * 4) // opcode, status 2445724e8aSKinglong Mee #define CB_OP_GETATTR_BITMAP_MAXSZ (4 * 4) // bitmap length, 3 bitmaps 251da177e4SLinus Torvalds #define CB_OP_GETATTR_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ 261da177e4SLinus Torvalds CB_OP_GETATTR_BITMAP_MAXSZ + \ 2745724e8aSKinglong Mee /* change, size, ctime, mtime */\ 2845724e8aSKinglong Mee (2 + 2 + 3 + 3) * 4) 291da177e4SLinus Torvalds #define CB_OP_RECALL_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 301da177e4SLinus Torvalds 314aece6a1SBenny Halevy #if defined(CONFIG_NFS_V4_1) 32f2a62561SFred Isaman #define CB_OP_LAYOUTRECALL_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 331be5683bSMarc Eshel #define CB_OP_DEVICENOTIFY_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 344aece6a1SBenny Halevy #define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ 3545724e8aSKinglong Mee NFS4_MAX_SESSIONID_LEN + \ 3645724e8aSKinglong Mee (1 + 3) * 4) // seqid, 3 slotids 3731f09607SAlexandros Batsakis #define CB_OP_RECALLANY_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 38b9efa1b2SAndy Adamson #define CB_OP_RECALLSLOT_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 39db783688SJeff Layton #define CB_OP_NOTIFY_LOCK_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 404aece6a1SBenny Halevy #endif /* CONFIG_NFS_V4_1 */ 415178a125SOlga Kornievskaia #ifdef CONFIG_NFS_V4_2 425178a125SOlga Kornievskaia #define CB_OP_OFFLOAD_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 435178a125SOlga Kornievskaia #endif /* CONFIG_NFS_V4_2 */ 444aece6a1SBenny Halevy 451da177e4SLinus Torvalds #define NFSDBG_FACILITY NFSDBG_CALLBACK 461da177e4SLinus Torvalds 4731d2b435SAndy Adamson /* Internal error code */ 4831d2b435SAndy Adamson #define NFS4ERR_RESOURCE_HDR 11050 4931d2b435SAndy Adamson 501da177e4SLinus Torvalds struct callback_op { 51f4dac4adSChristoph Hellwig __be32 (*process_op)(void *, void *, struct cb_process_state *); 52f4dac4adSChristoph Hellwig __be32 (*decode_args)(struct svc_rqst *, struct xdr_stream *, void *); 53f4dac4adSChristoph Hellwig __be32 (*encode_res)(struct svc_rqst *, struct xdr_stream *, 54f4dac4adSChristoph Hellwig const void *); 551da177e4SLinus Torvalds long res_maxsize; 561da177e4SLinus Torvalds }; 571da177e4SLinus Torvalds 581da177e4SLinus Torvalds static struct callback_op callback_ops[]; 591da177e4SLinus Torvalds 60a6beb732SChristoph Hellwig static __be32 nfs4_callback_null(struct svc_rqst *rqstp) 611da177e4SLinus Torvalds { 621da177e4SLinus Torvalds return htonl(NFS4_OK); 631da177e4SLinus Torvalds } 641da177e4SLinus Torvalds 65026fec7eSChristoph Hellwig static int nfs4_decode_void(struct svc_rqst *rqstp, __be32 *p) 661da177e4SLinus Torvalds { 671da177e4SLinus Torvalds return xdr_argsize_check(rqstp, p); 681da177e4SLinus Torvalds } 691da177e4SLinus Torvalds 7063f8de37SChristoph Hellwig static int nfs4_encode_void(struct svc_rqst *rqstp, __be32 *p) 711da177e4SLinus Torvalds { 721da177e4SLinus Torvalds return xdr_ressize_check(rqstp, p); 731da177e4SLinus Torvalds } 741da177e4SLinus Torvalds 75b60475c9SJeff Layton static __be32 *read_buf(struct xdr_stream *xdr, size_t nbytes) 761da177e4SLinus Torvalds { 775704fdebSAl Viro __be32 *p; 781da177e4SLinus Torvalds 791da177e4SLinus Torvalds p = xdr_inline_decode(xdr, nbytes); 801da177e4SLinus Torvalds if (unlikely(p == NULL)) 81756b9b37STrond Myklebust printk(KERN_WARNING "NFS: NFSv4 callback reply buffer overflowed!\n"); 821da177e4SLinus Torvalds return p; 831da177e4SLinus Torvalds } 841da177e4SLinus Torvalds 85c065eeeaSTrond Myklebust static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len, 86c065eeeaSTrond Myklebust const char **str, size_t maxlen) 871da177e4SLinus Torvalds { 88c065eeeaSTrond Myklebust ssize_t err; 891da177e4SLinus Torvalds 90c065eeeaSTrond Myklebust err = xdr_stream_decode_opaque_inline(xdr, (void **)str, maxlen); 91c065eeeaSTrond Myklebust if (err < 0) 92c065eeeaSTrond Myklebust return cpu_to_be32(NFS4ERR_RESOURCE); 93c065eeeaSTrond Myklebust *len = err; 941da177e4SLinus Torvalds return 0; 951da177e4SLinus Torvalds } 961da177e4SLinus Torvalds 97e6f684f6SAl Viro static __be32 decode_fh(struct xdr_stream *xdr, struct nfs_fh *fh) 981da177e4SLinus Torvalds { 995704fdebSAl Viro __be32 *p; 1001da177e4SLinus Torvalds 1011da177e4SLinus Torvalds p = read_buf(xdr, 4); 1021da177e4SLinus Torvalds if (unlikely(p == NULL)) 1031da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 1041da177e4SLinus Torvalds fh->size = ntohl(*p); 1051da177e4SLinus Torvalds if (fh->size > NFS4_FHSIZE) 1061da177e4SLinus Torvalds return htonl(NFS4ERR_BADHANDLE); 1071da177e4SLinus Torvalds p = read_buf(xdr, fh->size); 1081da177e4SLinus Torvalds if (unlikely(p == NULL)) 1091da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 1101da177e4SLinus Torvalds memcpy(&fh->data[0], p, fh->size); 1111da177e4SLinus Torvalds memset(&fh->data[fh->size], 0, sizeof(fh->data) - fh->size); 1121da177e4SLinus Torvalds return 0; 1131da177e4SLinus Torvalds } 1141da177e4SLinus Torvalds 115e6f684f6SAl Viro static __be32 decode_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) 1161da177e4SLinus Torvalds { 1175704fdebSAl Viro __be32 *p; 1181da177e4SLinus Torvalds unsigned int attrlen; 1191da177e4SLinus Torvalds 1201da177e4SLinus Torvalds p = read_buf(xdr, 4); 1211da177e4SLinus Torvalds if (unlikely(p == NULL)) 1221da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 1231da177e4SLinus Torvalds attrlen = ntohl(*p); 1241da177e4SLinus Torvalds p = read_buf(xdr, attrlen << 2); 1251da177e4SLinus Torvalds if (unlikely(p == NULL)) 1261da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 1271da177e4SLinus Torvalds if (likely(attrlen > 0)) 1281da177e4SLinus Torvalds bitmap[0] = ntohl(*p++); 1291da177e4SLinus Torvalds if (attrlen > 1) 1301da177e4SLinus Torvalds bitmap[1] = ntohl(*p); 1311da177e4SLinus Torvalds return 0; 1321da177e4SLinus Torvalds } 1331da177e4SLinus Torvalds 134e6f684f6SAl Viro static __be32 decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) 1351da177e4SLinus Torvalds { 1365704fdebSAl Viro __be32 *p; 1371da177e4SLinus Torvalds 1382d2f24adSTrond Myklebust p = read_buf(xdr, NFS4_STATEID_SIZE); 1391da177e4SLinus Torvalds if (unlikely(p == NULL)) 1401da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 14193b717fdSTrond Myklebust memcpy(stateid->data, p, NFS4_STATEID_SIZE); 1421da177e4SLinus Torvalds return 0; 1431da177e4SLinus Torvalds } 1441da177e4SLinus Torvalds 14593b717fdSTrond Myklebust static __be32 decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) 14693b717fdSTrond Myklebust { 14793b717fdSTrond Myklebust stateid->type = NFS4_DELEGATION_STATEID_TYPE; 14893b717fdSTrond Myklebust return decode_stateid(xdr, stateid); 14993b717fdSTrond Myklebust } 15093b717fdSTrond Myklebust 151e6f684f6SAl Viro static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound_hdr_arg *hdr) 1521da177e4SLinus Torvalds { 1535704fdebSAl Viro __be32 *p; 154e6f684f6SAl Viro __be32 status; 1551da177e4SLinus Torvalds 156c065eeeaSTrond Myklebust status = decode_string(xdr, &hdr->taglen, &hdr->tag, CB_OP_TAGLEN_MAXSZ); 1571da177e4SLinus Torvalds if (unlikely(status != 0)) 1581da177e4SLinus Torvalds return status; 1591da177e4SLinus Torvalds p = read_buf(xdr, 12); 1601da177e4SLinus Torvalds if (unlikely(p == NULL)) 1611da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 162b8f2ef84SBenny Halevy hdr->minorversion = ntohl(*p++); 163459de2edSBryan Schumaker /* Check for minor version support */ 164459de2edSBryan Schumaker if (hdr->minorversion <= NFS4_MAX_MINOR_VERSION) { 16542c2c424SSteve Dickson hdr->cb_ident = ntohl(*p++); /* ignored by v4.1 and v4.2 */ 16648a9e2d2SBenny Halevy } else { 1679a3ba432STrond Myklebust pr_warn_ratelimited("NFS: %s: NFSv4 server callback with " 168b8f2ef84SBenny Halevy "illegal minor version %u!\n", 169b8f2ef84SBenny Halevy __func__, hdr->minorversion); 1701da177e4SLinus Torvalds return htonl(NFS4ERR_MINOR_VERS_MISMATCH); 1711da177e4SLinus Torvalds } 1721da177e4SLinus Torvalds hdr->nops = ntohl(*p); 1731da177e4SLinus Torvalds return 0; 1741da177e4SLinus Torvalds } 1751da177e4SLinus Torvalds 176e6f684f6SAl Viro static __be32 decode_op_hdr(struct xdr_stream *xdr, unsigned int *op) 1771da177e4SLinus Torvalds { 1785704fdebSAl Viro __be32 *p; 1791da177e4SLinus Torvalds p = read_buf(xdr, 4); 1801da177e4SLinus Torvalds if (unlikely(p == NULL)) 18131d2b435SAndy Adamson return htonl(NFS4ERR_RESOURCE_HDR); 1821da177e4SLinus Torvalds *op = ntohl(*p); 1831da177e4SLinus Torvalds return 0; 1841da177e4SLinus Torvalds } 1851da177e4SLinus Torvalds 186f4dac4adSChristoph Hellwig static __be32 decode_getattr_args(struct svc_rqst *rqstp, 187f4dac4adSChristoph Hellwig struct xdr_stream *xdr, void *argp) 1881da177e4SLinus Torvalds { 189f4dac4adSChristoph Hellwig struct cb_getattrargs *args = argp; 190e6f684f6SAl Viro __be32 status; 1911da177e4SLinus Torvalds 1921da177e4SLinus Torvalds status = decode_fh(xdr, &args->fh); 1931da177e4SLinus Torvalds if (unlikely(status != 0)) 1941da177e4SLinus Torvalds return status; 19556938bb7SAnna Schumaker return decode_bitmap(xdr, args->bitmap); 1961da177e4SLinus Torvalds } 1971da177e4SLinus Torvalds 198f4dac4adSChristoph Hellwig static __be32 decode_recall_args(struct svc_rqst *rqstp, 199f4dac4adSChristoph Hellwig struct xdr_stream *xdr, void *argp) 2001da177e4SLinus Torvalds { 201f4dac4adSChristoph Hellwig struct cb_recallargs *args = argp; 2025704fdebSAl Viro __be32 *p; 203e6f684f6SAl Viro __be32 status; 2041da177e4SLinus Torvalds 20593b717fdSTrond Myklebust status = decode_delegation_stateid(xdr, &args->stateid); 2061da177e4SLinus Torvalds if (unlikely(status != 0)) 2073873bc50SAlexey Dobriyan return status; 208135a4ea0SAnna Schumaker p = read_buf(xdr, 4); 209135a4ea0SAnna Schumaker if (unlikely(p == NULL)) 210135a4ea0SAnna Schumaker return htonl(NFS4ERR_RESOURCE); 211135a4ea0SAnna Schumaker args->truncate = ntohl(*p); 212135a4ea0SAnna Schumaker return decode_fh(xdr, &args->fh); 2131da177e4SLinus Torvalds } 2141da177e4SLinus Torvalds 2154aece6a1SBenny Halevy #if defined(CONFIG_NFS_V4_1) 21693b717fdSTrond Myklebust static __be32 decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) 21793b717fdSTrond Myklebust { 21893b717fdSTrond Myklebust stateid->type = NFS4_LAYOUT_STATEID_TYPE; 21993b717fdSTrond Myklebust return decode_stateid(xdr, stateid); 22093b717fdSTrond Myklebust } 2214aece6a1SBenny Halevy 222f2a62561SFred Isaman static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp, 223f4dac4adSChristoph Hellwig struct xdr_stream *xdr, void *argp) 224f2a62561SFred Isaman { 225f4dac4adSChristoph Hellwig struct cb_layoutrecallargs *args = argp; 226f2a62561SFred Isaman __be32 *p; 227f2a62561SFred Isaman __be32 status = 0; 228f2a62561SFred Isaman uint32_t iomode; 229f2a62561SFred Isaman 230f2a62561SFred Isaman p = read_buf(xdr, 4 * sizeof(uint32_t)); 231c79d56d2SAnna Schumaker if (unlikely(p == NULL)) 232c79d56d2SAnna Schumaker return htonl(NFS4ERR_BADXDR); 233f2a62561SFred Isaman 234f2a62561SFred Isaman args->cbl_layout_type = ntohl(*p++); 235f2a62561SFred Isaman /* Depite the spec's xdr, iomode really belongs in the FILE switch, 23625985edcSLucas De Marchi * as it is unusable and ignored with the other types. 237f2a62561SFred Isaman */ 238f2a62561SFred Isaman iomode = ntohl(*p++); 239f2a62561SFred Isaman args->cbl_layoutchanged = ntohl(*p++); 240f2a62561SFred Isaman args->cbl_recall_type = ntohl(*p++); 241f2a62561SFred Isaman 242f2a62561SFred Isaman if (args->cbl_recall_type == RETURN_FILE) { 243f2a62561SFred Isaman args->cbl_range.iomode = iomode; 244f2a62561SFred Isaman status = decode_fh(xdr, &args->cbl_fh); 245f2a62561SFred Isaman if (unlikely(status != 0)) 246c79d56d2SAnna Schumaker return status; 247f2a62561SFred Isaman 248f2a62561SFred Isaman p = read_buf(xdr, 2 * sizeof(uint64_t)); 249c79d56d2SAnna Schumaker if (unlikely(p == NULL)) 250c79d56d2SAnna Schumaker return htonl(NFS4ERR_BADXDR); 251f2a62561SFred Isaman p = xdr_decode_hyper(p, &args->cbl_range.offset); 252f2a62561SFred Isaman p = xdr_decode_hyper(p, &args->cbl_range.length); 253c79d56d2SAnna Schumaker return decode_layout_stateid(xdr, &args->cbl_stateid); 254f2a62561SFred Isaman } else if (args->cbl_recall_type == RETURN_FSID) { 255f2a62561SFred Isaman p = read_buf(xdr, 2 * sizeof(uint64_t)); 256c79d56d2SAnna Schumaker if (unlikely(p == NULL)) 257c79d56d2SAnna Schumaker return htonl(NFS4ERR_BADXDR); 258f2a62561SFred Isaman p = xdr_decode_hyper(p, &args->cbl_fsid.major); 259f2a62561SFred Isaman p = xdr_decode_hyper(p, &args->cbl_fsid.minor); 260c79d56d2SAnna Schumaker } else if (args->cbl_recall_type != RETURN_ALL) 261c79d56d2SAnna Schumaker return htonl(NFS4ERR_BADXDR); 262c79d56d2SAnna Schumaker return 0; 263f2a62561SFred Isaman } 264f2a62561SFred Isaman 2651be5683bSMarc Eshel static 2661be5683bSMarc Eshel __be32 decode_devicenotify_args(struct svc_rqst *rqstp, 2671be5683bSMarc Eshel struct xdr_stream *xdr, 268f4dac4adSChristoph Hellwig void *argp) 2691be5683bSMarc Eshel { 270f4dac4adSChristoph Hellwig struct cb_devicenotifyargs *args = argp; 2711be5683bSMarc Eshel __be32 *p; 2721be5683bSMarc Eshel __be32 status = 0; 2731be5683bSMarc Eshel u32 tmp; 2741be5683bSMarc Eshel int n, i; 2751be5683bSMarc Eshel args->ndevs = 0; 2761be5683bSMarc Eshel 2771be5683bSMarc Eshel /* Num of device notifications */ 2781be5683bSMarc Eshel p = read_buf(xdr, sizeof(uint32_t)); 2791be5683bSMarc Eshel if (unlikely(p == NULL)) { 2801be5683bSMarc Eshel status = htonl(NFS4ERR_BADXDR); 2811be5683bSMarc Eshel goto out; 2821be5683bSMarc Eshel } 2831be5683bSMarc Eshel n = ntohl(*p++); 2841be5683bSMarc Eshel if (n <= 0) 2851be5683bSMarc Eshel goto out; 286363e0df0SDan Carpenter if (n > ULONG_MAX / sizeof(*args->devs)) { 287363e0df0SDan Carpenter status = htonl(NFS4ERR_BADXDR); 288363e0df0SDan Carpenter goto out; 289363e0df0SDan Carpenter } 2901be5683bSMarc Eshel 291a4f743a6STrond Myklebust args->devs = kmalloc_array(n, sizeof(*args->devs), GFP_KERNEL); 2921be5683bSMarc Eshel if (!args->devs) { 2931be5683bSMarc Eshel status = htonl(NFS4ERR_DELAY); 2941be5683bSMarc Eshel goto out; 2951be5683bSMarc Eshel } 2961be5683bSMarc Eshel 2971be5683bSMarc Eshel /* Decode each dev notification */ 2981be5683bSMarc Eshel for (i = 0; i < n; i++) { 2991be5683bSMarc Eshel struct cb_devicenotifyitem *dev = &args->devs[i]; 3001be5683bSMarc Eshel 3011be5683bSMarc Eshel p = read_buf(xdr, (4 * sizeof(uint32_t)) + NFS4_DEVICEID4_SIZE); 3021be5683bSMarc Eshel if (unlikely(p == NULL)) { 3031be5683bSMarc Eshel status = htonl(NFS4ERR_BADXDR); 3041be5683bSMarc Eshel goto err; 3051be5683bSMarc Eshel } 3061be5683bSMarc Eshel 3071be5683bSMarc Eshel tmp = ntohl(*p++); /* bitmap size */ 3081be5683bSMarc Eshel if (tmp != 1) { 3091be5683bSMarc Eshel status = htonl(NFS4ERR_INVAL); 3101be5683bSMarc Eshel goto err; 3111be5683bSMarc Eshel } 3121be5683bSMarc Eshel dev->cbd_notify_type = ntohl(*p++); 3131be5683bSMarc Eshel if (dev->cbd_notify_type != NOTIFY_DEVICEID4_CHANGE && 3141be5683bSMarc Eshel dev->cbd_notify_type != NOTIFY_DEVICEID4_DELETE) { 3151be5683bSMarc Eshel status = htonl(NFS4ERR_INVAL); 3161be5683bSMarc Eshel goto err; 3171be5683bSMarc Eshel } 3181be5683bSMarc Eshel 3191be5683bSMarc Eshel tmp = ntohl(*p++); /* opaque size */ 3201be5683bSMarc Eshel if (((dev->cbd_notify_type == NOTIFY_DEVICEID4_CHANGE) && 3211be5683bSMarc Eshel (tmp != NFS4_DEVICEID4_SIZE + 8)) || 3221be5683bSMarc Eshel ((dev->cbd_notify_type == NOTIFY_DEVICEID4_DELETE) && 3231be5683bSMarc Eshel (tmp != NFS4_DEVICEID4_SIZE + 4))) { 3241be5683bSMarc Eshel status = htonl(NFS4ERR_INVAL); 3251be5683bSMarc Eshel goto err; 3261be5683bSMarc Eshel } 3271be5683bSMarc Eshel dev->cbd_layout_type = ntohl(*p++); 3281be5683bSMarc Eshel memcpy(dev->cbd_dev_id.data, p, NFS4_DEVICEID4_SIZE); 3291be5683bSMarc Eshel p += XDR_QUADLEN(NFS4_DEVICEID4_SIZE); 3301be5683bSMarc Eshel 3311be5683bSMarc Eshel if (dev->cbd_layout_type == NOTIFY_DEVICEID4_CHANGE) { 3321be5683bSMarc Eshel p = read_buf(xdr, sizeof(uint32_t)); 3331be5683bSMarc Eshel if (unlikely(p == NULL)) { 3341be5683bSMarc Eshel status = htonl(NFS4ERR_BADXDR); 3351be5683bSMarc Eshel goto err; 3361be5683bSMarc Eshel } 3371be5683bSMarc Eshel dev->cbd_immediate = ntohl(*p++); 3381be5683bSMarc Eshel } else { 3391be5683bSMarc Eshel dev->cbd_immediate = 0; 3401be5683bSMarc Eshel } 3411be5683bSMarc Eshel 3421be5683bSMarc Eshel args->ndevs++; 3431be5683bSMarc Eshel 3441be5683bSMarc Eshel dprintk("%s: type %d layout 0x%x immediate %d\n", 3451be5683bSMarc Eshel __func__, dev->cbd_notify_type, dev->cbd_layout_type, 3461be5683bSMarc Eshel dev->cbd_immediate); 3471be5683bSMarc Eshel } 3481be5683bSMarc Eshel out: 3491be5683bSMarc Eshel dprintk("%s: status %d ndevs %d\n", 3501be5683bSMarc Eshel __func__, ntohl(status), args->ndevs); 3511be5683bSMarc Eshel return status; 3521be5683bSMarc Eshel err: 3531be5683bSMarc Eshel kfree(args->devs); 3541be5683bSMarc Eshel goto out; 3551be5683bSMarc Eshel } 3561be5683bSMarc Eshel 3579733f0d9SAndy Adamson static __be32 decode_sessionid(struct xdr_stream *xdr, 3584aece6a1SBenny Halevy struct nfs4_sessionid *sid) 3594aece6a1SBenny Halevy { 3609733f0d9SAndy Adamson __be32 *p; 3614aece6a1SBenny Halevy 362590184a6SKinglong Mee p = read_buf(xdr, NFS4_MAX_SESSIONID_LEN); 3634aece6a1SBenny Halevy if (unlikely(p == NULL)) 364a419aef8SJoe Perches return htonl(NFS4ERR_RESOURCE); 3654aece6a1SBenny Halevy 366590184a6SKinglong Mee memcpy(sid->data, p, NFS4_MAX_SESSIONID_LEN); 3674aece6a1SBenny Halevy return 0; 3684aece6a1SBenny Halevy } 3694aece6a1SBenny Halevy 3709733f0d9SAndy Adamson static __be32 decode_rc_list(struct xdr_stream *xdr, 3714aece6a1SBenny Halevy struct referring_call_list *rc_list) 3724aece6a1SBenny Halevy { 3739733f0d9SAndy Adamson __be32 *p; 3744aece6a1SBenny Halevy int i; 3759733f0d9SAndy Adamson __be32 status; 3764aece6a1SBenny Halevy 3774aece6a1SBenny Halevy status = decode_sessionid(xdr, &rc_list->rcl_sessionid); 3784aece6a1SBenny Halevy if (status) 3794aece6a1SBenny Halevy goto out; 3804aece6a1SBenny Halevy 3814aece6a1SBenny Halevy status = htonl(NFS4ERR_RESOURCE); 3824aece6a1SBenny Halevy p = read_buf(xdr, sizeof(uint32_t)); 3834aece6a1SBenny Halevy if (unlikely(p == NULL)) 3844aece6a1SBenny Halevy goto out; 3854aece6a1SBenny Halevy 3864aece6a1SBenny Halevy rc_list->rcl_nrefcalls = ntohl(*p++); 3874aece6a1SBenny Halevy if (rc_list->rcl_nrefcalls) { 3884aece6a1SBenny Halevy p = read_buf(xdr, 3894aece6a1SBenny Halevy rc_list->rcl_nrefcalls * 2 * sizeof(uint32_t)); 3904aece6a1SBenny Halevy if (unlikely(p == NULL)) 3914aece6a1SBenny Halevy goto out; 392a4f743a6STrond Myklebust rc_list->rcl_refcalls = kmalloc_array(rc_list->rcl_nrefcalls, 3934aece6a1SBenny Halevy sizeof(*rc_list->rcl_refcalls), 3944aece6a1SBenny Halevy GFP_KERNEL); 3954aece6a1SBenny Halevy if (unlikely(rc_list->rcl_refcalls == NULL)) 3964aece6a1SBenny Halevy goto out; 3974aece6a1SBenny Halevy for (i = 0; i < rc_list->rcl_nrefcalls; i++) { 3984aece6a1SBenny Halevy rc_list->rcl_refcalls[i].rc_sequenceid = ntohl(*p++); 3994aece6a1SBenny Halevy rc_list->rcl_refcalls[i].rc_slotid = ntohl(*p++); 4004aece6a1SBenny Halevy } 4014aece6a1SBenny Halevy } 4024aece6a1SBenny Halevy status = 0; 4034aece6a1SBenny Halevy 4044aece6a1SBenny Halevy out: 4054aece6a1SBenny Halevy return status; 4064aece6a1SBenny Halevy } 4074aece6a1SBenny Halevy 4089733f0d9SAndy Adamson static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp, 4094aece6a1SBenny Halevy struct xdr_stream *xdr, 410f4dac4adSChristoph Hellwig void *argp) 4114aece6a1SBenny Halevy { 412f4dac4adSChristoph Hellwig struct cb_sequenceargs *args = argp; 4139733f0d9SAndy Adamson __be32 *p; 4144aece6a1SBenny Halevy int i; 4159733f0d9SAndy Adamson __be32 status; 4164aece6a1SBenny Halevy 4174aece6a1SBenny Halevy status = decode_sessionid(xdr, &args->csa_sessionid); 4184aece6a1SBenny Halevy if (status) 4191796549aSAnna Schumaker return status; 4204aece6a1SBenny Halevy 4214aece6a1SBenny Halevy p = read_buf(xdr, 5 * sizeof(uint32_t)); 4224aece6a1SBenny Halevy if (unlikely(p == NULL)) 4231796549aSAnna Schumaker return htonl(NFS4ERR_RESOURCE); 4244aece6a1SBenny Halevy 42565fc64e5SRicardo Labiaga args->csa_addr = svc_addr(rqstp); 4264aece6a1SBenny Halevy args->csa_sequenceid = ntohl(*p++); 4274aece6a1SBenny Halevy args->csa_slotid = ntohl(*p++); 4284aece6a1SBenny Halevy args->csa_highestslotid = ntohl(*p++); 4294aece6a1SBenny Halevy args->csa_cachethis = ntohl(*p++); 4304aece6a1SBenny Halevy args->csa_nrclists = ntohl(*p++); 4314aece6a1SBenny Halevy args->csa_rclists = NULL; 4324aece6a1SBenny Halevy if (args->csa_nrclists) { 4330439f31cSDan Carpenter args->csa_rclists = kmalloc_array(args->csa_nrclists, 4344aece6a1SBenny Halevy sizeof(*args->csa_rclists), 4354aece6a1SBenny Halevy GFP_KERNEL); 4364aece6a1SBenny Halevy if (unlikely(args->csa_rclists == NULL)) 4371796549aSAnna Schumaker return htonl(NFS4ERR_RESOURCE); 4384aece6a1SBenny Halevy 4394aece6a1SBenny Halevy for (i = 0; i < args->csa_nrclists; i++) { 4404aece6a1SBenny Halevy status = decode_rc_list(xdr, &args->csa_rclists[i]); 441d8ba1f97STrond Myklebust if (status) { 442d8ba1f97STrond Myklebust args->csa_nrclists = i; 4434aece6a1SBenny Halevy goto out_free; 4444aece6a1SBenny Halevy } 4454aece6a1SBenny Halevy } 446d8ba1f97STrond Myklebust } 4471796549aSAnna Schumaker return 0; 4484aece6a1SBenny Halevy 4494aece6a1SBenny Halevy out_free: 4504aece6a1SBenny Halevy for (i = 0; i < args->csa_nrclists; i++) 4514aece6a1SBenny Halevy kfree(args->csa_rclists[i].rcl_refcalls); 4524aece6a1SBenny Halevy kfree(args->csa_rclists); 4531796549aSAnna Schumaker return status; 4544aece6a1SBenny Halevy } 4554aece6a1SBenny Halevy 4569733f0d9SAndy Adamson static __be32 decode_recallany_args(struct svc_rqst *rqstp, 45731f09607SAlexandros Batsakis struct xdr_stream *xdr, 458f4dac4adSChristoph Hellwig void *argp) 45931f09607SAlexandros Batsakis { 460f4dac4adSChristoph Hellwig struct cb_recallanyargs *args = argp; 461d743c3c9SPeng Tao uint32_t bitmap[2]; 462d743c3c9SPeng Tao __be32 *p, status; 46331f09607SAlexandros Batsakis 46431f09607SAlexandros Batsakis p = read_buf(xdr, 4); 46531f09607SAlexandros Batsakis if (unlikely(p == NULL)) 46631f09607SAlexandros Batsakis return htonl(NFS4ERR_BADXDR); 46731f09607SAlexandros Batsakis args->craa_objs_to_keep = ntohl(*p++); 468d743c3c9SPeng Tao status = decode_bitmap(xdr, bitmap); 469d743c3c9SPeng Tao if (unlikely(status)) 470d743c3c9SPeng Tao return status; 471d743c3c9SPeng Tao args->craa_type_mask = bitmap[0]; 47231f09607SAlexandros Batsakis 47331f09607SAlexandros Batsakis return 0; 47431f09607SAlexandros Batsakis } 47531f09607SAlexandros Batsakis 4769733f0d9SAndy Adamson static __be32 decode_recallslot_args(struct svc_rqst *rqstp, 477b9efa1b2SAndy Adamson struct xdr_stream *xdr, 478f4dac4adSChristoph Hellwig void *argp) 479b9efa1b2SAndy Adamson { 480f4dac4adSChristoph Hellwig struct cb_recallslotargs *args = argp; 481b9efa1b2SAndy Adamson __be32 *p; 482b9efa1b2SAndy Adamson 483b9efa1b2SAndy Adamson p = read_buf(xdr, 4); 484b9efa1b2SAndy Adamson if (unlikely(p == NULL)) 485b9efa1b2SAndy Adamson return htonl(NFS4ERR_BADXDR); 486d5fb4ce3STrond Myklebust args->crsa_target_highest_slotid = ntohl(*p++); 487b9efa1b2SAndy Adamson return 0; 488b9efa1b2SAndy Adamson } 489b9efa1b2SAndy Adamson 490db783688SJeff Layton static __be32 decode_lockowner(struct xdr_stream *xdr, struct cb_notify_lock_args *args) 491db783688SJeff Layton { 492db783688SJeff Layton __be32 *p; 493db783688SJeff Layton unsigned int len; 494db783688SJeff Layton 495db783688SJeff Layton p = read_buf(xdr, 12); 496db783688SJeff Layton if (unlikely(p == NULL)) 497db783688SJeff Layton return htonl(NFS4ERR_BADXDR); 498db783688SJeff Layton 499db783688SJeff Layton p = xdr_decode_hyper(p, &args->cbnl_owner.clientid); 500db783688SJeff Layton len = be32_to_cpu(*p); 501db783688SJeff Layton 502db783688SJeff Layton p = read_buf(xdr, len); 503db783688SJeff Layton if (unlikely(p == NULL)) 504db783688SJeff Layton return htonl(NFS4ERR_BADXDR); 505db783688SJeff Layton 506db783688SJeff Layton /* Only try to decode if the length is right */ 507db783688SJeff Layton if (len == 20) { 508db783688SJeff Layton p += 2; /* skip "lock id:" */ 509db783688SJeff Layton args->cbnl_owner.s_dev = be32_to_cpu(*p++); 510db783688SJeff Layton xdr_decode_hyper(p, &args->cbnl_owner.id); 511db783688SJeff Layton args->cbnl_valid = true; 512db783688SJeff Layton } else { 513db783688SJeff Layton args->cbnl_owner.s_dev = 0; 514db783688SJeff Layton args->cbnl_owner.id = 0; 515db783688SJeff Layton args->cbnl_valid = false; 516db783688SJeff Layton } 517db783688SJeff Layton return 0; 518db783688SJeff Layton } 519db783688SJeff Layton 520f4dac4adSChristoph Hellwig static __be32 decode_notify_lock_args(struct svc_rqst *rqstp, 521f4dac4adSChristoph Hellwig struct xdr_stream *xdr, void *argp) 522db783688SJeff Layton { 523f4dac4adSChristoph Hellwig struct cb_notify_lock_args *args = argp; 524db783688SJeff Layton __be32 status; 525db783688SJeff Layton 526db783688SJeff Layton status = decode_fh(xdr, &args->cbnl_fh); 527db783688SJeff Layton if (unlikely(status != 0)) 528db783688SJeff Layton return status; 529535ece2bSAnna Schumaker return decode_lockowner(xdr, args); 530db783688SJeff Layton } 531db783688SJeff Layton 5324aece6a1SBenny Halevy #endif /* CONFIG_NFS_V4_1 */ 5335178a125SOlga Kornievskaia #ifdef CONFIG_NFS_V4_2 5345178a125SOlga Kornievskaia static __be32 decode_write_response(struct xdr_stream *xdr, 5355178a125SOlga Kornievskaia struct cb_offloadargs *args) 5365178a125SOlga Kornievskaia { 5375178a125SOlga Kornievskaia __be32 *p; 5384aece6a1SBenny Halevy 5395178a125SOlga Kornievskaia /* skip the always zero field */ 5405178a125SOlga Kornievskaia p = read_buf(xdr, 4); 5415178a125SOlga Kornievskaia if (unlikely(!p)) 5425178a125SOlga Kornievskaia goto out; 5435178a125SOlga Kornievskaia p++; 5445178a125SOlga Kornievskaia 5455178a125SOlga Kornievskaia /* decode count, stable_how, verifier */ 5465178a125SOlga Kornievskaia p = xdr_inline_decode(xdr, 8 + 4); 5475178a125SOlga Kornievskaia if (unlikely(!p)) 5485178a125SOlga Kornievskaia goto out; 5495178a125SOlga Kornievskaia p = xdr_decode_hyper(p, &args->wr_count); 5505178a125SOlga Kornievskaia args->wr_writeverf.committed = be32_to_cpup(p); 5515178a125SOlga Kornievskaia p = xdr_inline_decode(xdr, NFS4_VERIFIER_SIZE); 5525178a125SOlga Kornievskaia if (likely(p)) { 5535178a125SOlga Kornievskaia memcpy(&args->wr_writeverf.verifier.data[0], p, 5545178a125SOlga Kornievskaia NFS4_VERIFIER_SIZE); 5555178a125SOlga Kornievskaia return 0; 5565178a125SOlga Kornievskaia } 5575178a125SOlga Kornievskaia out: 5585178a125SOlga Kornievskaia return htonl(NFS4ERR_RESOURCE); 5595178a125SOlga Kornievskaia } 5605178a125SOlga Kornievskaia 5615178a125SOlga Kornievskaia static __be32 decode_offload_args(struct svc_rqst *rqstp, 5625178a125SOlga Kornievskaia struct xdr_stream *xdr, 5635178a125SOlga Kornievskaia void *data) 5645178a125SOlga Kornievskaia { 5655178a125SOlga Kornievskaia struct cb_offloadargs *args = data; 5665178a125SOlga Kornievskaia __be32 *p; 5675178a125SOlga Kornievskaia __be32 status; 5685178a125SOlga Kornievskaia 5695178a125SOlga Kornievskaia /* decode fh */ 5705178a125SOlga Kornievskaia status = decode_fh(xdr, &args->coa_fh); 5715178a125SOlga Kornievskaia if (unlikely(status != 0)) 5725178a125SOlga Kornievskaia return status; 5735178a125SOlga Kornievskaia 5745178a125SOlga Kornievskaia /* decode stateid */ 5755178a125SOlga Kornievskaia status = decode_stateid(xdr, &args->coa_stateid); 5765178a125SOlga Kornievskaia if (unlikely(status != 0)) 5775178a125SOlga Kornievskaia return status; 5785178a125SOlga Kornievskaia 5795178a125SOlga Kornievskaia /* decode status */ 5805178a125SOlga Kornievskaia p = read_buf(xdr, 4); 5815178a125SOlga Kornievskaia if (unlikely(!p)) 5825178a125SOlga Kornievskaia goto out; 5835178a125SOlga Kornievskaia args->error = ntohl(*p++); 5845178a125SOlga Kornievskaia if (!args->error) { 5855178a125SOlga Kornievskaia status = decode_write_response(xdr, args); 5865178a125SOlga Kornievskaia if (unlikely(status != 0)) 5875178a125SOlga Kornievskaia return status; 5885178a125SOlga Kornievskaia } else { 5895178a125SOlga Kornievskaia p = xdr_inline_decode(xdr, 8); 5905178a125SOlga Kornievskaia if (unlikely(!p)) 5915178a125SOlga Kornievskaia goto out; 5925178a125SOlga Kornievskaia p = xdr_decode_hyper(p, &args->wr_count); 5935178a125SOlga Kornievskaia } 5945178a125SOlga Kornievskaia return 0; 5955178a125SOlga Kornievskaia out: 5965178a125SOlga Kornievskaia return htonl(NFS4ERR_RESOURCE); 5975178a125SOlga Kornievskaia } 5985178a125SOlga Kornievskaia #endif /* CONFIG_NFS_V4_2 */ 599e6f684f6SAl Viro static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) 6001da177e4SLinus Torvalds { 601ab6e9aafSTrond Myklebust if (unlikely(xdr_stream_encode_opaque(xdr, str, len) < 0)) 602ab6e9aafSTrond Myklebust return cpu_to_be32(NFS4ERR_RESOURCE); 6031da177e4SLinus Torvalds return 0; 6041da177e4SLinus Torvalds } 6051da177e4SLinus Torvalds 6068b064946STrond Myklebust static __be32 encode_attr_bitmap(struct xdr_stream *xdr, const uint32_t *bitmap, size_t sz) 6071da177e4SLinus Torvalds { 6088b064946STrond Myklebust if (xdr_stream_encode_uint32_array(xdr, bitmap, sz) < 0) 6098b064946STrond Myklebust return cpu_to_be32(NFS4ERR_RESOURCE); 6101da177e4SLinus Torvalds return 0; 6111da177e4SLinus Torvalds } 6121da177e4SLinus Torvalds 613e6f684f6SAl Viro static __be32 encode_attr_change(struct xdr_stream *xdr, const uint32_t *bitmap, uint64_t change) 6141da177e4SLinus Torvalds { 6155704fdebSAl Viro __be32 *p; 6161da177e4SLinus Torvalds 6171da177e4SLinus Torvalds if (!(bitmap[0] & FATTR4_WORD0_CHANGE)) 6181da177e4SLinus Torvalds return 0; 6191da177e4SLinus Torvalds p = xdr_reserve_space(xdr, 8); 62090dc7d27SHarvey Harrison if (unlikely(!p)) 6211da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6221da177e4SLinus Torvalds p = xdr_encode_hyper(p, change); 6231da177e4SLinus Torvalds return 0; 6241da177e4SLinus Torvalds } 6251da177e4SLinus Torvalds 626e6f684f6SAl Viro static __be32 encode_attr_size(struct xdr_stream *xdr, const uint32_t *bitmap, uint64_t size) 6271da177e4SLinus Torvalds { 6285704fdebSAl Viro __be32 *p; 6291da177e4SLinus Torvalds 6301da177e4SLinus Torvalds if (!(bitmap[0] & FATTR4_WORD0_SIZE)) 6311da177e4SLinus Torvalds return 0; 6321da177e4SLinus Torvalds p = xdr_reserve_space(xdr, 8); 63390dc7d27SHarvey Harrison if (unlikely(!p)) 6341da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6351da177e4SLinus Torvalds p = xdr_encode_hyper(p, size); 6361da177e4SLinus Torvalds return 0; 6371da177e4SLinus Torvalds } 6381da177e4SLinus Torvalds 639e6f684f6SAl Viro static __be32 encode_attr_time(struct xdr_stream *xdr, const struct timespec *time) 6401da177e4SLinus Torvalds { 6415704fdebSAl Viro __be32 *p; 6421da177e4SLinus Torvalds 6431da177e4SLinus Torvalds p = xdr_reserve_space(xdr, 12); 64490dc7d27SHarvey Harrison if (unlikely(!p)) 6451da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6461da177e4SLinus Torvalds p = xdr_encode_hyper(p, time->tv_sec); 6471da177e4SLinus Torvalds *p = htonl(time->tv_nsec); 6481da177e4SLinus Torvalds return 0; 6491da177e4SLinus Torvalds } 6501da177e4SLinus Torvalds 651e6f684f6SAl Viro static __be32 encode_attr_ctime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec *time) 6521da177e4SLinus Torvalds { 6531da177e4SLinus Torvalds if (!(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) 6541da177e4SLinus Torvalds return 0; 6551da177e4SLinus Torvalds return encode_attr_time(xdr,time); 6561da177e4SLinus Torvalds } 6571da177e4SLinus Torvalds 658e6f684f6SAl Viro static __be32 encode_attr_mtime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec *time) 6591da177e4SLinus Torvalds { 6601da177e4SLinus Torvalds if (!(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) 6611da177e4SLinus Torvalds return 0; 6621da177e4SLinus Torvalds return encode_attr_time(xdr,time); 6631da177e4SLinus Torvalds } 6641da177e4SLinus Torvalds 665e6f684f6SAl Viro static __be32 encode_compound_hdr_res(struct xdr_stream *xdr, struct cb_compound_hdr_res *hdr) 6661da177e4SLinus Torvalds { 667e6f684f6SAl Viro __be32 status; 6681da177e4SLinus Torvalds 6691da177e4SLinus Torvalds hdr->status = xdr_reserve_space(xdr, 4); 6701da177e4SLinus Torvalds if (unlikely(hdr->status == NULL)) 6711da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6721da177e4SLinus Torvalds status = encode_string(xdr, hdr->taglen, hdr->tag); 6731da177e4SLinus Torvalds if (unlikely(status != 0)) 6741da177e4SLinus Torvalds return status; 6751da177e4SLinus Torvalds hdr->nops = xdr_reserve_space(xdr, 4); 6761da177e4SLinus Torvalds if (unlikely(hdr->nops == NULL)) 6771da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6781da177e4SLinus Torvalds return 0; 6791da177e4SLinus Torvalds } 6801da177e4SLinus Torvalds 681e6f684f6SAl Viro static __be32 encode_op_hdr(struct xdr_stream *xdr, uint32_t op, __be32 res) 6821da177e4SLinus Torvalds { 6835704fdebSAl Viro __be32 *p; 6841da177e4SLinus Torvalds 6851da177e4SLinus Torvalds p = xdr_reserve_space(xdr, 8); 6861da177e4SLinus Torvalds if (unlikely(p == NULL)) 68731d2b435SAndy Adamson return htonl(NFS4ERR_RESOURCE_HDR); 6881da177e4SLinus Torvalds *p++ = htonl(op); 6891da177e4SLinus Torvalds *p = res; 6901da177e4SLinus Torvalds return 0; 6911da177e4SLinus Torvalds } 6921da177e4SLinus Torvalds 693f4dac4adSChristoph Hellwig static __be32 encode_getattr_res(struct svc_rqst *rqstp, struct xdr_stream *xdr, 694f4dac4adSChristoph Hellwig const void *resp) 6951da177e4SLinus Torvalds { 696f4dac4adSChristoph Hellwig const struct cb_getattrres *res = resp; 6975704fdebSAl Viro __be32 *savep = NULL; 698e6f684f6SAl Viro __be32 status = res->status; 6991da177e4SLinus Torvalds 7001da177e4SLinus Torvalds if (unlikely(status != 0)) 7011da177e4SLinus Torvalds goto out; 7028b064946STrond Myklebust status = encode_attr_bitmap(xdr, res->bitmap, ARRAY_SIZE(res->bitmap)); 7031da177e4SLinus Torvalds if (unlikely(status != 0)) 7041da177e4SLinus Torvalds goto out; 7058b064946STrond Myklebust status = cpu_to_be32(NFS4ERR_RESOURCE); 7068b064946STrond Myklebust savep = xdr_reserve_space(xdr, sizeof(*savep)); 7078b064946STrond Myklebust if (unlikely(!savep)) 7088b064946STrond Myklebust goto out; 7091da177e4SLinus Torvalds status = encode_attr_change(xdr, res->bitmap, res->change_attr); 7101da177e4SLinus Torvalds if (unlikely(status != 0)) 7111da177e4SLinus Torvalds goto out; 7121da177e4SLinus Torvalds status = encode_attr_size(xdr, res->bitmap, res->size); 7131da177e4SLinus Torvalds if (unlikely(status != 0)) 7141da177e4SLinus Torvalds goto out; 7151da177e4SLinus Torvalds status = encode_attr_ctime(xdr, res->bitmap, &res->ctime); 7161da177e4SLinus Torvalds if (unlikely(status != 0)) 7171da177e4SLinus Torvalds goto out; 7181da177e4SLinus Torvalds status = encode_attr_mtime(xdr, res->bitmap, &res->mtime); 7191da177e4SLinus Torvalds *savep = htonl((unsigned int)((char *)xdr->p - (char *)(savep+1))); 7201da177e4SLinus Torvalds out: 7211da177e4SLinus Torvalds return status; 7221da177e4SLinus Torvalds } 7231da177e4SLinus Torvalds 72434bc47c9SBenny Halevy #if defined(CONFIG_NFS_V4_1) 72534bc47c9SBenny Halevy 7269733f0d9SAndy Adamson static __be32 encode_sessionid(struct xdr_stream *xdr, 7274aece6a1SBenny Halevy const struct nfs4_sessionid *sid) 7284aece6a1SBenny Halevy { 7299733f0d9SAndy Adamson __be32 *p; 7304aece6a1SBenny Halevy 731590184a6SKinglong Mee p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN); 7324aece6a1SBenny Halevy if (unlikely(p == NULL)) 7334aece6a1SBenny Halevy return htonl(NFS4ERR_RESOURCE); 7344aece6a1SBenny Halevy 735590184a6SKinglong Mee memcpy(p, sid, NFS4_MAX_SESSIONID_LEN); 7364aece6a1SBenny Halevy return 0; 7374aece6a1SBenny Halevy } 7384aece6a1SBenny Halevy 7399733f0d9SAndy Adamson static __be32 encode_cb_sequence_res(struct svc_rqst *rqstp, 7404aece6a1SBenny Halevy struct xdr_stream *xdr, 741f4dac4adSChristoph Hellwig const void *resp) 7424aece6a1SBenny Halevy { 743f4dac4adSChristoph Hellwig const struct cb_sequenceres *res = resp; 7449733f0d9SAndy Adamson __be32 *p; 745e216c8c7SDan Carpenter __be32 status = res->csr_status; 7464aece6a1SBenny Halevy 7474aece6a1SBenny Halevy if (unlikely(status != 0)) 7483d0bfaa6SAnna Schumaker return status; 7494aece6a1SBenny Halevy 750e0a63c0bSKinglong Mee status = encode_sessionid(xdr, &res->csr_sessionid); 751e0a63c0bSKinglong Mee if (status) 7523d0bfaa6SAnna Schumaker return status; 7534aece6a1SBenny Halevy 7544aece6a1SBenny Halevy p = xdr_reserve_space(xdr, 4 * sizeof(uint32_t)); 7554aece6a1SBenny Halevy if (unlikely(p == NULL)) 7564aece6a1SBenny Halevy return htonl(NFS4ERR_RESOURCE); 7574aece6a1SBenny Halevy 7584aece6a1SBenny Halevy *p++ = htonl(res->csr_sequenceid); 7594aece6a1SBenny Halevy *p++ = htonl(res->csr_slotid); 7604aece6a1SBenny Halevy *p++ = htonl(res->csr_highestslotid); 7614aece6a1SBenny Halevy *p++ = htonl(res->csr_target_highestslotid); 7623d0bfaa6SAnna Schumaker return 0; 7634aece6a1SBenny Halevy } 7644aece6a1SBenny Halevy 76534bc47c9SBenny Halevy static __be32 76634bc47c9SBenny Halevy preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op) 76734bc47c9SBenny Halevy { 768281fe15dSBenny Halevy if (op_nr == OP_CB_SEQUENCE) { 769281fe15dSBenny Halevy if (nop != 0) 770281fe15dSBenny Halevy return htonl(NFS4ERR_SEQUENCE_POS); 771281fe15dSBenny Halevy } else { 772281fe15dSBenny Halevy if (nop == 0) 773281fe15dSBenny Halevy return htonl(NFS4ERR_OP_NOT_IN_SESSION); 774281fe15dSBenny Halevy } 775281fe15dSBenny Halevy 77634bc47c9SBenny Halevy switch (op_nr) { 77734bc47c9SBenny Halevy case OP_CB_GETATTR: 77834bc47c9SBenny Halevy case OP_CB_RECALL: 7794aece6a1SBenny Halevy case OP_CB_SEQUENCE: 78031f09607SAlexandros Batsakis case OP_CB_RECALL_ANY: 781b9efa1b2SAndy Adamson case OP_CB_RECALL_SLOT: 782f2a62561SFred Isaman case OP_CB_LAYOUTRECALL: 7831be5683bSMarc Eshel case OP_CB_NOTIFY_DEVICEID: 784db783688SJeff Layton case OP_CB_NOTIFY_LOCK: 78534bc47c9SBenny Halevy *op = &callback_ops[op_nr]; 78634bc47c9SBenny Halevy break; 78734bc47c9SBenny Halevy 78834bc47c9SBenny Halevy case OP_CB_NOTIFY: 78934bc47c9SBenny Halevy case OP_CB_PUSH_DELEG: 79034bc47c9SBenny Halevy case OP_CB_RECALLABLE_OBJ_AVAIL: 79134bc47c9SBenny Halevy case OP_CB_WANTS_CANCELLED: 79234bc47c9SBenny Halevy return htonl(NFS4ERR_NOTSUPP); 79334bc47c9SBenny Halevy 79434bc47c9SBenny Halevy default: 79534bc47c9SBenny Halevy return htonl(NFS4ERR_OP_ILLEGAL); 79634bc47c9SBenny Halevy } 79734bc47c9SBenny Halevy 79834bc47c9SBenny Halevy return htonl(NFS_OK); 79934bc47c9SBenny Halevy } 80034bc47c9SBenny Halevy 801810d82e6STrond Myklebust static void nfs4_callback_free_slot(struct nfs4_session *session, 802810d82e6STrond Myklebust struct nfs4_slot *slot) 80342acd021SAndy Adamson { 80442acd021SAndy Adamson struct nfs4_slot_table *tbl = &session->bc_slot_table; 80542acd021SAndy Adamson 80642acd021SAndy Adamson spin_lock(&tbl->slot_tbl_lock); 80742acd021SAndy Adamson /* 80842acd021SAndy Adamson * Let the state manager know callback processing done. 80942acd021SAndy Adamson * A single slot, so highest used slotid is either 0 or -1 81042acd021SAndy Adamson */ 811810d82e6STrond Myklebust nfs4_free_slot(tbl, slot); 81242acd021SAndy Adamson spin_unlock(&tbl->slot_tbl_lock); 81342acd021SAndy Adamson } 81442acd021SAndy Adamson 81555a67399STrond Myklebust static void nfs4_cb_free_slot(struct cb_process_state *cps) 81642acd021SAndy Adamson { 817810d82e6STrond Myklebust if (cps->slot) { 818810d82e6STrond Myklebust nfs4_callback_free_slot(cps->clp->cl_session, cps->slot); 819810d82e6STrond Myklebust cps->slot = NULL; 820810d82e6STrond Myklebust } 82142acd021SAndy Adamson } 82242acd021SAndy Adamson 82334bc47c9SBenny Halevy #else /* CONFIG_NFS_V4_1 */ 82434bc47c9SBenny Halevy 82534bc47c9SBenny Halevy static __be32 82634bc47c9SBenny Halevy preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op) 82734bc47c9SBenny Halevy { 82834bc47c9SBenny Halevy return htonl(NFS4ERR_MINOR_VERS_MISMATCH); 82934bc47c9SBenny Halevy } 83034bc47c9SBenny Halevy 83155a67399STrond Myklebust static void nfs4_cb_free_slot(struct cb_process_state *cps) 83242acd021SAndy Adamson { 83342acd021SAndy Adamson } 83434bc47c9SBenny Halevy #endif /* CONFIG_NFS_V4_1 */ 83534bc47c9SBenny Halevy 8366b140b85SBryan Schumaker #ifdef CONFIG_NFS_V4_2 8376b140b85SBryan Schumaker static __be32 8386b140b85SBryan Schumaker preprocess_nfs42_op(int nop, unsigned int op_nr, struct callback_op **op) 8396b140b85SBryan Schumaker { 8406b140b85SBryan Schumaker __be32 status = preprocess_nfs41_op(nop, op_nr, op); 8416b140b85SBryan Schumaker if (status != htonl(NFS4ERR_OP_ILLEGAL)) 8426b140b85SBryan Schumaker return status; 8436b140b85SBryan Schumaker 8445178a125SOlga Kornievskaia if (op_nr == OP_CB_OFFLOAD) { 8455178a125SOlga Kornievskaia *op = &callback_ops[op_nr]; 8465178a125SOlga Kornievskaia return htonl(NFS_OK); 8475178a125SOlga Kornievskaia } else 8486b140b85SBryan Schumaker return htonl(NFS4ERR_NOTSUPP); 8496b140b85SBryan Schumaker return htonl(NFS4ERR_OP_ILLEGAL); 8506b140b85SBryan Schumaker } 8516b140b85SBryan Schumaker #else /* CONFIG_NFS_V4_2 */ 8526b140b85SBryan Schumaker static __be32 8536b140b85SBryan Schumaker preprocess_nfs42_op(int nop, unsigned int op_nr, struct callback_op **op) 8546b140b85SBryan Schumaker { 8556b140b85SBryan Schumaker return htonl(NFS4ERR_MINOR_VERS_MISMATCH); 8566b140b85SBryan Schumaker } 8576b140b85SBryan Schumaker #endif /* CONFIG_NFS_V4_2 */ 8586b140b85SBryan Schumaker 85934bc47c9SBenny Halevy static __be32 86034bc47c9SBenny Halevy preprocess_nfs4_op(unsigned int op_nr, struct callback_op **op) 86134bc47c9SBenny Halevy { 86234bc47c9SBenny Halevy switch (op_nr) { 86334bc47c9SBenny Halevy case OP_CB_GETATTR: 86434bc47c9SBenny Halevy case OP_CB_RECALL: 86534bc47c9SBenny Halevy *op = &callback_ops[op_nr]; 86634bc47c9SBenny Halevy break; 86734bc47c9SBenny Halevy default: 86834bc47c9SBenny Halevy return htonl(NFS4ERR_OP_ILLEGAL); 86934bc47c9SBenny Halevy } 87034bc47c9SBenny Halevy 87134bc47c9SBenny Halevy return htonl(NFS_OK); 87234bc47c9SBenny Halevy } 87334bc47c9SBenny Halevy 874459de2edSBryan Schumaker static __be32 process_op(int nop, struct svc_rqst *rqstp, 8751da177e4SLinus Torvalds struct xdr_stream *xdr_in, void *argp, 876c36fca52SAndy Adamson struct xdr_stream *xdr_out, void *resp, 877c36fca52SAndy Adamson struct cb_process_state *cps) 8781da177e4SLinus Torvalds { 879a162a6b8STrond Myklebust struct callback_op *op = &callback_ops[0]; 88031d2b435SAndy Adamson unsigned int op_nr; 88134bc47c9SBenny Halevy __be32 status; 8821da177e4SLinus Torvalds long maxlen; 883e6f684f6SAl Viro __be32 res; 8841da177e4SLinus Torvalds 8851da177e4SLinus Torvalds status = decode_op_hdr(xdr_in, &op_nr); 88631d2b435SAndy Adamson if (unlikely(status)) 88731d2b435SAndy Adamson return status; 8881da177e4SLinus Torvalds 8896b140b85SBryan Schumaker switch (cps->minorversion) { 8906b140b85SBryan Schumaker case 0: 8916b140b85SBryan Schumaker status = preprocess_nfs4_op(op_nr, &op); 8926b140b85SBryan Schumaker break; 8936b140b85SBryan Schumaker case 1: 8946b140b85SBryan Schumaker status = preprocess_nfs41_op(nop, op_nr, &op); 8956b140b85SBryan Schumaker break; 8966b140b85SBryan Schumaker case 2: 8976b140b85SBryan Schumaker status = preprocess_nfs42_op(nop, op_nr, &op); 8986b140b85SBryan Schumaker break; 8996b140b85SBryan Schumaker default: 9006b140b85SBryan Schumaker status = htonl(NFS4ERR_MINOR_VERS_MISMATCH); 9016b140b85SBryan Schumaker } 9026b140b85SBryan Schumaker 90334bc47c9SBenny Halevy if (status == htonl(NFS4ERR_OP_ILLEGAL)) 90434bc47c9SBenny Halevy op_nr = OP_CB_ILLEGAL; 905b92b3019SAndy Adamson if (status) 906b92b3019SAndy Adamson goto encode_hdr; 90731d2b435SAndy Adamson 908c36fca52SAndy Adamson if (cps->drc_status) { 909c36fca52SAndy Adamson status = cps->drc_status; 9104911096fSAndy Adamson goto encode_hdr; 9114911096fSAndy Adamson } 9124911096fSAndy Adamson 9131da177e4SLinus Torvalds maxlen = xdr_out->end - xdr_out->p; 9141da177e4SLinus Torvalds if (maxlen > 0 && maxlen < PAGE_SIZE) { 9151da177e4SLinus Torvalds status = op->decode_args(rqstp, xdr_in, argp); 916e95e60daSAndy Adamson if (likely(status == 0)) 917c36fca52SAndy Adamson status = op->process_op(argp, resp, cps); 9181da177e4SLinus Torvalds } else 9191da177e4SLinus Torvalds status = htonl(NFS4ERR_RESOURCE); 9201da177e4SLinus Torvalds 921b92b3019SAndy Adamson encode_hdr: 9221da177e4SLinus Torvalds res = encode_op_hdr(xdr_out, op_nr, status); 92331d2b435SAndy Adamson if (unlikely(res)) 92431d2b435SAndy Adamson return res; 9251da177e4SLinus Torvalds if (op->encode_res != NULL && status == 0) 9261da177e4SLinus Torvalds status = op->encode_res(rqstp, xdr_out, resp); 9271da177e4SLinus Torvalds return status; 9281da177e4SLinus Torvalds } 9291da177e4SLinus Torvalds 9301da177e4SLinus Torvalds /* 9311da177e4SLinus Torvalds * Decode, process and encode a COMPOUND 9321da177e4SLinus Torvalds */ 933a6beb732SChristoph Hellwig static __be32 nfs4_callback_compound(struct svc_rqst *rqstp) 9341da177e4SLinus Torvalds { 9353a6258e1STrond Myklebust struct cb_compound_hdr_arg hdr_arg = { 0 }; 9363a6258e1STrond Myklebust struct cb_compound_hdr_res hdr_res = { NULL }; 9371da177e4SLinus Torvalds struct xdr_stream xdr_in, xdr_out; 938c36fca52SAndy Adamson __be32 *p, status; 939c36fca52SAndy Adamson struct cb_process_state cps = { 940c36fca52SAndy Adamson .drc_status = 0, 941c36fca52SAndy Adamson .clp = NULL, 9429695c705SStanislav Kinsbursky .net = SVC_NET(rqstp), 943c36fca52SAndy Adamson }; 9443a6258e1STrond Myklebust unsigned int nops = 0; 9451da177e4SLinus Torvalds 9460ccc61b1SChuck Lever xdr_init_decode(&xdr_in, &rqstp->rq_arg, 9470ccc61b1SChuck Lever rqstp->rq_arg.head[0].iov_base, NULL); 9481da177e4SLinus Torvalds 9495704fdebSAl Viro p = (__be32*)((char *)rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len); 9500ccc61b1SChuck Lever xdr_init_encode(&xdr_out, &rqstp->rq_res, p, NULL); 9511da177e4SLinus Torvalds 9523a6258e1STrond Myklebust status = decode_compound_hdr_arg(&xdr_in, &hdr_arg); 9534ed0d83dSVaishali Thakkar if (status == htonl(NFS4ERR_RESOURCE)) 9543a6258e1STrond Myklebust return rpc_garbage_args; 9553a6258e1STrond Myklebust 956c36fca52SAndy Adamson if (hdr_arg.minorversion == 0) { 9579695c705SStanislav Kinsbursky cps.clp = nfs4_find_client_ident(SVC_NET(rqstp), hdr_arg.cb_ident); 95832cd3ee5SOlga Kornievskaia if (!cps.clp || !check_gss_callback_principal(cps.clp, rqstp)) { 95932cd3ee5SOlga Kornievskaia if (cps.clp) 96032cd3ee5SOlga Kornievskaia nfs_put_client(cps.clp); 961a4e187d8SChuck Lever goto out_invalidcred; 962778be232SAndy Adamson } 96332cd3ee5SOlga Kornievskaia } 964c36fca52SAndy Adamson 965459de2edSBryan Schumaker cps.minorversion = hdr_arg.minorversion; 9661da177e4SLinus Torvalds hdr_res.taglen = hdr_arg.taglen; 9671da177e4SLinus Torvalds hdr_res.tag = hdr_arg.tag; 96832cd3ee5SOlga Kornievskaia if (encode_compound_hdr_res(&xdr_out, &hdr_res) != 0) { 96932cd3ee5SOlga Kornievskaia if (cps.clp) 97032cd3ee5SOlga Kornievskaia nfs_put_client(cps.clp); 9713a6258e1STrond Myklebust return rpc_system_err; 97232cd3ee5SOlga Kornievskaia } 9733a6258e1STrond Myklebust while (status == 0 && nops != hdr_arg.nops) { 974459de2edSBryan Schumaker status = process_op(nops, rqstp, &xdr_in, 975a6beb732SChristoph Hellwig rqstp->rq_argp, &xdr_out, rqstp->rq_resp, 976a6beb732SChristoph Hellwig &cps); 9771da177e4SLinus Torvalds nops++; 9781da177e4SLinus Torvalds } 9793a6258e1STrond Myklebust 98031d2b435SAndy Adamson /* Buffer overflow in decode_ops_hdr or encode_ops_hdr. Return 98131d2b435SAndy Adamson * resource error in cb_compound status without returning op */ 98231d2b435SAndy Adamson if (unlikely(status == htonl(NFS4ERR_RESOURCE_HDR))) { 98331d2b435SAndy Adamson status = htonl(NFS4ERR_RESOURCE); 98431d2b435SAndy Adamson nops--; 98531d2b435SAndy Adamson } 98631d2b435SAndy Adamson 9871da177e4SLinus Torvalds *hdr_res.status = status; 9881da177e4SLinus Torvalds *hdr_res.nops = htonl(nops); 98955a67399STrond Myklebust nfs4_cb_free_slot(&cps); 990c36fca52SAndy Adamson nfs_put_client(cps.clp); 9911da177e4SLinus Torvalds return rpc_success; 992a4e187d8SChuck Lever 993a4e187d8SChuck Lever out_invalidcred: 994a4e187d8SChuck Lever pr_warn_ratelimited("NFS: NFSv4 callback contains invalid cred\n"); 995a4e187d8SChuck Lever return rpc_autherr_badcred; 9961da177e4SLinus Torvalds } 9971da177e4SLinus Torvalds 9981da177e4SLinus Torvalds /* 9991da177e4SLinus Torvalds * Define NFS4 callback COMPOUND ops. 10001da177e4SLinus Torvalds */ 10011da177e4SLinus Torvalds static struct callback_op callback_ops[] = { 10021da177e4SLinus Torvalds [0] = { 10031da177e4SLinus Torvalds .res_maxsize = CB_OP_HDR_RES_MAXSZ, 10041da177e4SLinus Torvalds }, 10051da177e4SLinus Torvalds [OP_CB_GETATTR] = { 1006f4dac4adSChristoph Hellwig .process_op = nfs4_callback_getattr, 1007f4dac4adSChristoph Hellwig .decode_args = decode_getattr_args, 1008f4dac4adSChristoph Hellwig .encode_res = encode_getattr_res, 10091da177e4SLinus Torvalds .res_maxsize = CB_OP_GETATTR_RES_MAXSZ, 10101da177e4SLinus Torvalds }, 10111da177e4SLinus Torvalds [OP_CB_RECALL] = { 1012f4dac4adSChristoph Hellwig .process_op = nfs4_callback_recall, 1013f4dac4adSChristoph Hellwig .decode_args = decode_recall_args, 10141da177e4SLinus Torvalds .res_maxsize = CB_OP_RECALL_RES_MAXSZ, 10154aece6a1SBenny Halevy }, 10164aece6a1SBenny Halevy #if defined(CONFIG_NFS_V4_1) 1017f2a62561SFred Isaman [OP_CB_LAYOUTRECALL] = { 1018f4dac4adSChristoph Hellwig .process_op = nfs4_callback_layoutrecall, 1019f4dac4adSChristoph Hellwig .decode_args = decode_layoutrecall_args, 1020f2a62561SFred Isaman .res_maxsize = CB_OP_LAYOUTRECALL_RES_MAXSZ, 1021f2a62561SFred Isaman }, 10221be5683bSMarc Eshel [OP_CB_NOTIFY_DEVICEID] = { 1023f4dac4adSChristoph Hellwig .process_op = nfs4_callback_devicenotify, 1024f4dac4adSChristoph Hellwig .decode_args = decode_devicenotify_args, 10251be5683bSMarc Eshel .res_maxsize = CB_OP_DEVICENOTIFY_RES_MAXSZ, 10261be5683bSMarc Eshel }, 10274aece6a1SBenny Halevy [OP_CB_SEQUENCE] = { 1028f4dac4adSChristoph Hellwig .process_op = nfs4_callback_sequence, 1029f4dac4adSChristoph Hellwig .decode_args = decode_cb_sequence_args, 1030f4dac4adSChristoph Hellwig .encode_res = encode_cb_sequence_res, 10314aece6a1SBenny Halevy .res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ, 10324aece6a1SBenny Halevy }, 103331f09607SAlexandros Batsakis [OP_CB_RECALL_ANY] = { 1034f4dac4adSChristoph Hellwig .process_op = nfs4_callback_recallany, 1035f4dac4adSChristoph Hellwig .decode_args = decode_recallany_args, 103631f09607SAlexandros Batsakis .res_maxsize = CB_OP_RECALLANY_RES_MAXSZ, 103731f09607SAlexandros Batsakis }, 1038b9efa1b2SAndy Adamson [OP_CB_RECALL_SLOT] = { 1039f4dac4adSChristoph Hellwig .process_op = nfs4_callback_recallslot, 1040f4dac4adSChristoph Hellwig .decode_args = decode_recallslot_args, 1041b9efa1b2SAndy Adamson .res_maxsize = CB_OP_RECALLSLOT_RES_MAXSZ, 1042b9efa1b2SAndy Adamson }, 1043db783688SJeff Layton [OP_CB_NOTIFY_LOCK] = { 1044f4dac4adSChristoph Hellwig .process_op = nfs4_callback_notify_lock, 1045f4dac4adSChristoph Hellwig .decode_args = decode_notify_lock_args, 1046db783688SJeff Layton .res_maxsize = CB_OP_NOTIFY_LOCK_RES_MAXSZ, 1047db783688SJeff Layton }, 10484aece6a1SBenny Halevy #endif /* CONFIG_NFS_V4_1 */ 10495178a125SOlga Kornievskaia #ifdef CONFIG_NFS_V4_2 10505178a125SOlga Kornievskaia [OP_CB_OFFLOAD] = { 10515178a125SOlga Kornievskaia .process_op = nfs4_callback_offload, 10525178a125SOlga Kornievskaia .decode_args = decode_offload_args, 10535178a125SOlga Kornievskaia .res_maxsize = CB_OP_OFFLOAD_RES_MAXSZ, 10545178a125SOlga Kornievskaia }, 10555178a125SOlga Kornievskaia #endif /* CONFIG_NFS_V4_2 */ 10561da177e4SLinus Torvalds }; 10571da177e4SLinus Torvalds 10581da177e4SLinus Torvalds /* 10591da177e4SLinus Torvalds * Define NFS4 callback procedures 10601da177e4SLinus Torvalds */ 1061860bda29SChristoph Hellwig static const struct svc_procedure nfs4_callback_procedures1[] = { 10621da177e4SLinus Torvalds [CB_NULL] = { 10631da177e4SLinus Torvalds .pc_func = nfs4_callback_null, 1064026fec7eSChristoph Hellwig .pc_decode = nfs4_decode_void, 106563f8de37SChristoph Hellwig .pc_encode = nfs4_encode_void, 10661da177e4SLinus Torvalds .pc_xdrressize = 1, 10671da177e4SLinus Torvalds }, 10681da177e4SLinus Torvalds [CB_COMPOUND] = { 10691da177e4SLinus Torvalds .pc_func = nfs4_callback_compound, 107063f8de37SChristoph Hellwig .pc_encode = nfs4_encode_void, 10711da177e4SLinus Torvalds .pc_argsize = 256, 10721da177e4SLinus Torvalds .pc_ressize = 256, 10731da177e4SLinus Torvalds .pc_xdrressize = NFS4_CALLBACK_BUFSIZE, 10741da177e4SLinus Torvalds } 10751da177e4SLinus Torvalds }; 10761da177e4SLinus Torvalds 10777fd38af9SChristoph Hellwig static unsigned int nfs4_callback_count1[ARRAY_SIZE(nfs4_callback_procedures1)]; 1078e9679189SChristoph Hellwig const struct svc_version nfs4_callback_version1 = { 10791da177e4SLinus Torvalds .vs_vers = 1, 10801da177e4SLinus Torvalds .vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1), 10811da177e4SLinus Torvalds .vs_proc = nfs4_callback_procedures1, 10827fd38af9SChristoph Hellwig .vs_count = nfs4_callback_count1, 10831da177e4SLinus Torvalds .vs_xdrsize = NFS4_CALLBACK_XDRSIZE, 10841da177e4SLinus Torvalds .vs_dispatch = NULL, 108505a45a2dSJeff Layton .vs_hidden = true, 10865283b03eSJeff Layton .vs_need_cong_ctrl = true, 10871da177e4SLinus Torvalds }; 10881da177e4SLinus Torvalds 10897fd38af9SChristoph Hellwig static unsigned int nfs4_callback_count4[ARRAY_SIZE(nfs4_callback_procedures1)]; 1090e9679189SChristoph Hellwig const struct svc_version nfs4_callback_version4 = { 109107bccc2dSAlexandros Batsakis .vs_vers = 4, 109207bccc2dSAlexandros Batsakis .vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1), 109307bccc2dSAlexandros Batsakis .vs_proc = nfs4_callback_procedures1, 10947fd38af9SChristoph Hellwig .vs_count = nfs4_callback_count4, 109507bccc2dSAlexandros Batsakis .vs_xdrsize = NFS4_CALLBACK_XDRSIZE, 109607bccc2dSAlexandros Batsakis .vs_dispatch = NULL, 109705a45a2dSJeff Layton .vs_hidden = true, 10985283b03eSJeff Layton .vs_need_cong_ctrl = true, 109907bccc2dSAlexandros Batsakis }; 1100