NFSD: Add common helpers to decode void args and encode void results
authorChuck Lever <chuck.lever@oracle.com>
Thu, 5 Nov 2020 19:48:29 +0000 (14:48 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 30 Nov 2020 19:46:35 +0000 (14:46 -0500)
Start off the conversion to xdr_stream by de-duplicating the functions
that decode void arguments and encode void results.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
13 files changed:
fs/nfsd/nfs2acl.c
fs/nfsd/nfs3acl.c
fs/nfsd/nfs3proc.c
fs/nfsd/nfs3xdr.c
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4xdr.c
fs/nfsd/nfsd.h
fs/nfsd/nfsproc.c
fs/nfsd/nfssvc.c
fs/nfsd/nfsxdr.c
fs/nfsd/xdr.h
fs/nfsd/xdr3.h
fs/nfsd/xdr4.h

index 6a900f770dd23bf49bcf3699bdae87173b76e6ae..b0f66604532a5d911df578f5d9978656784fe6d6 100644 (file)
@@ -185,10 +185,6 @@ out:
 /*
  * XDR decode functions
  */
-static int nfsaclsvc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p)
-{
-       return 1;
-}
 
 static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p)
 {
@@ -255,15 +251,6 @@ static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p)
  * XDR encode functions
  */
 
-/*
- * There must be an encoding function for void results so svc_process
- * will work properly.
- */
-static int nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p)
-{
-       return xdr_ressize_check(rqstp, p);
-}
-
 /* GETACL */
 static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
 {
@@ -378,10 +365,10 @@ struct nfsd3_voidargs { int dummy; };
 static const struct svc_procedure nfsd_acl_procedures2[5] = {
        [ACLPROC2_NULL] = {
                .pc_func = nfsacld_proc_null,
-               .pc_decode = nfsaclsvc_decode_voidarg,
-               .pc_encode = nfsaclsvc_encode_voidres,
-               .pc_argsize = sizeof(struct nfsd3_voidargs),
-               .pc_ressize = sizeof(struct nfsd3_voidargs),
+               .pc_decode = nfssvc_decode_voidarg,
+               .pc_encode = nfssvc_encode_voidres,
+               .pc_argsize = sizeof(struct nfsd_voidargs),
+               .pc_ressize = sizeof(struct nfsd_voidres),
                .pc_cachetype = RC_NOCACHE,
                .pc_xdrressize = ST,
        },
index 34a394e50e1d164613e32e2ab51c18f5a5c24aec..7c30876a31a1b67e495d1447e3b12b4c1274fd7c 100644 (file)
@@ -245,10 +245,10 @@ struct nfsd3_voidargs { int dummy; };
 static const struct svc_procedure nfsd_acl_procedures3[3] = {
        [ACLPROC3_NULL] = {
                .pc_func = nfsd3_proc_null,
-               .pc_decode = nfs3svc_decode_voidarg,
-               .pc_encode = nfs3svc_encode_voidres,
-               .pc_argsize = sizeof(struct nfsd3_voidargs),
-               .pc_ressize = sizeof(struct nfsd3_voidargs),
+               .pc_decode = nfssvc_decode_voidarg,
+               .pc_encode = nfssvc_encode_voidres,
+               .pc_argsize = sizeof(struct nfsd_voidargs),
+               .pc_ressize = sizeof(struct nfsd_voidres),
                .pc_cachetype = RC_NOCACHE,
                .pc_xdrressize = ST,
        },
index d9be589fed159c53b57bbe0df81c9ab0df9c7a08..76931f4f57c3ef4977ad714071c9d64a86aaa614 100644 (file)
@@ -692,8 +692,6 @@ out:
 #define nfsd3_attrstatres              nfsd3_attrstat
 #define nfsd3_wccstatres               nfsd3_attrstat
 #define nfsd3_createres                        nfsd3_diropres
-#define nfsd3_voidres                  nfsd3_voidargs
-struct nfsd3_voidargs { int dummy; };
 
 #define ST 1           /* status*/
 #define FH 17          /* filehandle with length */
@@ -704,10 +702,10 @@ struct nfsd3_voidargs { int dummy; };
 static const struct svc_procedure nfsd_procedures3[22] = {
        [NFS3PROC_NULL] = {
                .pc_func = nfsd3_proc_null,
-               .pc_decode = nfs3svc_decode_voidarg,
-               .pc_encode = nfs3svc_encode_voidres,
-               .pc_argsize = sizeof(struct nfsd3_voidargs),
-               .pc_ressize = sizeof(struct nfsd3_voidres),
+               .pc_decode = nfssvc_decode_voidarg,
+               .pc_encode = nfssvc_encode_voidres,
+               .pc_argsize = sizeof(struct nfsd_voidargs),
+               .pc_ressize = sizeof(struct nfsd_voidres),
                .pc_cachetype = RC_NOCACHE,
                .pc_xdrressize = ST,
        },
index 186b07a72373e5f01df4b2ad2e960e117605cd42..a6718b952975db389ad8c03187ca9d9fb96769e1 100644 (file)
@@ -304,11 +304,6 @@ void fill_post_wcc(struct svc_fh *fhp)
 /*
  * XDR decode functions
  */
-int
-nfs3svc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p)
-{
-       return 1;
-}
 
 int
 nfs3svc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p)
@@ -642,12 +637,6 @@ nfs3svc_decode_commitargs(struct svc_rqst *rqstp, __be32 *p)
  * XDR encode functions
  */
 
-int
-nfs3svc_encode_voidres(struct svc_rqst *rqstp, __be32 *p)
-{
-       return xdr_ressize_check(rqstp, p);
-}
-
 /* GETATTR */
 int
 nfs3svc_encode_attrstat(struct svc_rqst *rqstp, __be32 *p)
index 20772f6b0b2d370122ff2335981dee225088f20e..76300b0441f0951826f374c10e316919ce21fb76 100644 (file)
@@ -3295,16 +3295,13 @@ static const char *nfsd4_op_name(unsigned opnum)
        return "unknown_operation";
 }
 
-#define nfsd4_voidres                  nfsd4_voidargs
-struct nfsd4_voidargs { int dummy; };
-
 static const struct svc_procedure nfsd_procedures4[2] = {
        [NFSPROC4_NULL] = {
                .pc_func = nfsd4_proc_null,
-               .pc_decode = nfs4svc_decode_voidarg,
-               .pc_encode = nfs4svc_encode_voidres,
-               .pc_argsize = sizeof(struct nfsd4_voidargs),
-               .pc_ressize = sizeof(struct nfsd4_voidres),
+               .pc_decode = nfssvc_decode_voidarg,
+               .pc_encode = nfssvc_encode_voidres,
+               .pc_argsize = sizeof(struct nfsd_voidargs),
+               .pc_ressize = sizeof(struct nfsd_voidres),
                .pc_cachetype = RC_NOCACHE,
                .pc_xdrressize = 1,
        },
index e3c6bea83bd6da601f46c6e7e667fade8033de2f..86a149ce0e84bd08ae9da9ea624956e048583756 100644 (file)
@@ -5271,12 +5271,6 @@ nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op)
        p = xdr_encode_opaque_fixed(p, rp->rp_buf, rp->rp_buflen);
 }
 
-int
-nfs4svc_encode_voidres(struct svc_rqst *rqstp, __be32 *p)
-{
-        return xdr_ressize_check(rqstp, p);
-}
-
 void nfsd4_release_compoundargs(struct svc_rqst *rqstp)
 {
        struct nfsd4_compoundargs *args = rqstp->rq_argp;
@@ -5294,12 +5288,6 @@ void nfsd4_release_compoundargs(struct svc_rqst *rqstp)
        }
 }
 
-int
-nfs4svc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p)
-{
-       return 1;
-}
-
 int
 nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p)
 {
index cb742e17e04a9d17e5757ff2a388620ae655a0b8..7907de3f2ee6385ae02490aaaf26880ebfdce7c8 100644 (file)
@@ -73,6 +73,14 @@ extern unsigned long         nfsd_drc_mem_used;
 
 extern const struct seq_operations nfs_exports_op;
 
+/*
+ * Common void argument and result helpers
+ */
+struct nfsd_voidargs { };
+struct nfsd_voidres { };
+int            nfssvc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p);
+int            nfssvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p);
+
 /*
  * Function prototypes.
  */
index 0d71549f9d42ab5c8c19d7feb5ce333f7e34435c..9473d048efec8fd4363b8f46b63a1443ec9b73ca 100644 (file)
@@ -609,7 +609,6 @@ nfsd_proc_statfs(struct svc_rqst *rqstp)
  * NFSv2 Server procedures.
  * Only the results of non-idempotent operations are cached.
  */
-struct nfsd_void { int dummy; };
 
 #define ST 1           /* status */
 #define FH 8           /* filehandle */
@@ -618,10 +617,10 @@ struct nfsd_void { int dummy; };
 static const struct svc_procedure nfsd_procedures2[18] = {
        [NFSPROC_NULL] = {
                .pc_func = nfsd_proc_null,
-               .pc_decode = nfssvc_decode_void,
-               .pc_encode = nfssvc_encode_void,
-               .pc_argsize = sizeof(struct nfsd_void),
-               .pc_ressize = sizeof(struct nfsd_void),
+               .pc_decode = nfssvc_decode_voidarg,
+               .pc_encode = nfssvc_encode_voidres,
+               .pc_argsize = sizeof(struct nfsd_voidargs),
+               .pc_ressize = sizeof(struct nfsd_voidres),
                .pc_cachetype = RC_NOCACHE,
                .pc_xdrressize = 0,
        },
@@ -647,10 +646,10 @@ static const struct svc_procedure nfsd_procedures2[18] = {
        },
        [NFSPROC_ROOT] = {
                .pc_func = nfsd_proc_root,
-               .pc_decode = nfssvc_decode_void,
-               .pc_encode = nfssvc_encode_void,
-               .pc_argsize = sizeof(struct nfsd_void),
-               .pc_ressize = sizeof(struct nfsd_void),
+               .pc_decode = nfssvc_decode_voidarg,
+               .pc_encode = nfssvc_encode_voidres,
+               .pc_argsize = sizeof(struct nfsd_voidargs),
+               .pc_ressize = sizeof(struct nfsd_voidres),
                .pc_cachetype = RC_NOCACHE,
                .pc_xdrressize = 0,
        },
@@ -685,10 +684,10 @@ static const struct svc_procedure nfsd_procedures2[18] = {
        },
        [NFSPROC_WRITECACHE] = {
                .pc_func = nfsd_proc_writecache,
-               .pc_decode = nfssvc_decode_void,
-               .pc_encode = nfssvc_encode_void,
-               .pc_argsize = sizeof(struct nfsd_void),
-               .pc_ressize = sizeof(struct nfsd_void),
+               .pc_decode = nfssvc_decode_voidarg,
+               .pc_encode = nfssvc_encode_voidres,
+               .pc_argsize = sizeof(struct nfsd_voidargs),
+               .pc_ressize = sizeof(struct nfsd_voidres),
                .pc_cachetype = RC_NOCACHE,
                .pc_xdrressize = 0,
        },
index 74d5e58eadb05ec890a229f076f5958b214e33db..24fb947a3c12b13b64216fff000b1d35a5433385 100644 (file)
@@ -1075,6 +1075,34 @@ out_encode_err:
        return 1;
 }
 
+/**
+ * nfssvc_decode_voidarg - Decode void arguments
+ * @rqstp: Server RPC transaction context
+ * @p: buffer containing arguments to decode
+ *
+ * Return values:
+ *   %0: Arguments were not valid
+ *   %1: Decoding was successful
+ */
+int nfssvc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p)
+{
+       return 1;
+}
+
+/**
+ * nfssvc_encode_voidres - Encode void results
+ * @rqstp: Server RPC transaction context
+ * @p: buffer in which to encode results
+ *
+ * Return values:
+ *   %0: Local error while encoding
+ *   %1: Encoding was successful
+ */
+int nfssvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p)
+{
+        return xdr_ressize_check(rqstp, p);
+}
+
 int nfsd_pool_stats_open(struct inode *inode, struct file *file)
 {
        int ret;
index 9e00a902113e37aa2fe057785db3e74b08bcba89..7aa6e8aca2c1a8a728c81385068c011fecf238d3 100644 (file)
@@ -192,11 +192,6 @@ __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *f
 /*
  * XDR decode functions
  */
-int
-nfssvc_decode_void(struct svc_rqst *rqstp, __be32 *p)
-{
-       return xdr_argsize_check(rqstp, p);
-}
 
 int
 nfssvc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p)
@@ -423,11 +418,6 @@ nfssvc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p)
 /*
  * XDR encode functions
  */
-int
-nfssvc_encode_void(struct svc_rqst *rqstp, __be32 *p)
-{
-       return xdr_ressize_check(rqstp, p);
-}
 
 int
 nfssvc_encode_stat(struct svc_rqst *rqstp, __be32 *p)
index 0ff336b0b25f9a3b498516dab19863631e96f088..ad77387734ccd0289d88f14ef2ae5be7a1cf9763 100644 (file)
@@ -144,7 +144,6 @@ union nfsd_xdrstore {
 #define NFS2_SVC_XDRSIZE       sizeof(union nfsd_xdrstore)
 
 
-int nfssvc_decode_void(struct svc_rqst *, __be32 *);
 int nfssvc_decode_fhandle(struct svc_rqst *, __be32 *);
 int nfssvc_decode_sattrargs(struct svc_rqst *, __be32 *);
 int nfssvc_decode_diropargs(struct svc_rqst *, __be32 *);
@@ -156,7 +155,6 @@ int nfssvc_decode_readlinkargs(struct svc_rqst *, __be32 *);
 int nfssvc_decode_linkargs(struct svc_rqst *, __be32 *);
 int nfssvc_decode_symlinkargs(struct svc_rqst *, __be32 *);
 int nfssvc_decode_readdirargs(struct svc_rqst *, __be32 *);
-int nfssvc_encode_void(struct svc_rqst *, __be32 *);
 int nfssvc_encode_stat(struct svc_rqst *, __be32 *);
 int nfssvc_encode_attrstat(struct svc_rqst *, __be32 *);
 int nfssvc_encode_diropres(struct svc_rqst *, __be32 *);
index ae6fa6c9cb467264ed13f306bbc5db3261e1333a..456fcd7a103836ff7fbcee03e94e3b1dd96ea178 100644 (file)
@@ -273,7 +273,6 @@ union nfsd3_xdrstore {
 
 #define NFS3_SVC_XDRSIZE               sizeof(union nfsd3_xdrstore)
 
-int nfs3svc_decode_voidarg(struct svc_rqst *, __be32 *);
 int nfs3svc_decode_fhandle(struct svc_rqst *, __be32 *);
 int nfs3svc_decode_sattrargs(struct svc_rqst *, __be32 *);
 int nfs3svc_decode_diropargs(struct svc_rqst *, __be32 *);
@@ -290,7 +289,6 @@ int nfs3svc_decode_symlinkargs(struct svc_rqst *, __be32 *);
 int nfs3svc_decode_readdirargs(struct svc_rqst *, __be32 *);
 int nfs3svc_decode_readdirplusargs(struct svc_rqst *, __be32 *);
 int nfs3svc_decode_commitargs(struct svc_rqst *, __be32 *);
-int nfs3svc_encode_voidres(struct svc_rqst *, __be32 *);
 int nfs3svc_encode_attrstat(struct svc_rqst *, __be32 *);
 int nfs3svc_encode_wccstat(struct svc_rqst *, __be32 *);
 int nfs3svc_encode_diropres(struct svc_rqst *, __be32 *);
index 679d40af1bbb1c252e11ae1171821fbdd9e507f2..37f89ad5e9923a2ce93fc3f8e13f0e1e0d1f2eed 100644 (file)
@@ -781,8 +781,6 @@ set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
 
 
 bool nfsd4_mach_creds_match(struct nfs4_client *cl, struct svc_rqst *rqstp);
-int nfs4svc_decode_voidarg(struct svc_rqst *, __be32 *);
-int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *);
 int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *);
 int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *);
 __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *, u32);