NFSD: Encoder and decoder functions are always present
authorChuck Lever <chuck.lever@oracle.com>
Thu, 1 Oct 2020 22:59:12 +0000 (18:59 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Fri, 2 Oct 2020 13:37:41 +0000 (09:37 -0400)
nfsd_dispatch() is a hot path. Let's optimize the XDR method calls
for the by-far common case, which is that the XDR methods are indeed
present.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
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/nfssvc.c
fs/nfsd/xdr3.h
fs/nfsd/xdr4.h

index 8d20e0d..3c8b925 100644 (file)
@@ -183,6 +183,11 @@ static __be32 nfsacld_proc_access(struct svc_rqst *rqstp)
 /*
  * 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)
 {
        struct nfsd3_getaclargs *argp = rqstp->rq_argp;
@@ -357,6 +362,7 @@ 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),
index 292acb2..6141686 100644 (file)
@@ -245,6 +245,7 @@ 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),
index 288bc76..3d09959 100644 (file)
@@ -716,6 +716,7 @@ 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),
index aae514d..e540fd1 100644 (file)
@@ -304,6 +304,12 @@ 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)
 {
index 63e5a48..578fc9f 100644 (file)
@@ -3279,6 +3279,7 @@ 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),
index c11943a..c28d908 100644 (file)
@@ -5134,6 +5134,12 @@ 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 f6bc94c..b2d2092 100644 (file)
@@ -1022,8 +1022,7 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
         */
        rqstp->rq_cachetype = proc->pc_cachetype;
        /* Decode arguments */
-       if (proc->pc_decode &&
-           !proc->pc_decode(rqstp, (__be32*)rqstp->rq_arg.head[0].iov_base)) {
+       if (!proc->pc_decode(rqstp, (__be32 *)rqstp->rq_arg.head[0].iov_base)) {
                dprintk("nfsd: failed to decode arguments!\n");
                *statp = rpc_garbage_args;
                return 1;
@@ -1062,7 +1061,7 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
         * For NFSv2, additional info is never returned in case of an error.
         */
        if (!(nfserr && rqstp->rq_vers == 2)) {
-               if (proc->pc_encode && !proc->pc_encode(rqstp, nfserrp)) {
+               if (!proc->pc_encode(rqstp, nfserrp)) {
                        /* Failed to encode result. Release cache entry */
                        dprintk("nfsd: failed to encode result!\n");
                        nfsd_cache_update(rqstp, RC_NOCACHE, NULL);
index 4155fd7..ae6fa6c 100644 (file)
@@ -273,6 +273,7 @@ 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 *);
index 66499fb..679d40a 100644 (file)
@@ -781,6 +781,7 @@ 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 *);