NFSD: Skip extra computation for RC_NOCACHE case
authorChuck Lever <chuck.lever@oracle.com>
Tue, 28 Sep 2021 15:39:02 +0000 (11:39 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 28 Feb 2022 15:26:38 +0000 (10:26 -0500)
Force the compiler to skip unneeded initialization for cases that
don't need those values. For example, NFSv4 COMPOUND operations are
RC_NOCACHE.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfscache.c

index f79790d..34087a7 100644 (file)
@@ -421,10 +421,10 @@ out:
  */
 int nfsd_cache_lookup(struct svc_rqst *rqstp)
 {
-       struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
+       struct nfsd_net         *nn;
        struct svc_cacherep     *rp, *found;
        __wsum                  csum;
-       struct nfsd_drc_bucket  *b = nfsd_cache_bucket_find(rqstp->rq_xid, nn);
+       struct nfsd_drc_bucket  *b;
        int type = rqstp->rq_cachetype;
        int rtn = RC_DOIT;
 
@@ -440,10 +440,12 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp)
         * Since the common case is a cache miss followed by an insert,
         * preallocate an entry.
         */
+       nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
        rp = nfsd_reply_cache_alloc(rqstp, csum, nn);
        if (!rp)
                goto out;
 
+       b = nfsd_cache_bucket_find(rqstp->rq_xid, nn);
        spin_lock(&b->cache_lock);
        found = nfsd_cache_insert(b, rp, nn);
        if (found != rp) {