From ff7c2b2a2b4b61f9d8c67706cfc6c144d8a0c8fb Mon Sep 17 00:00:00 2001 From: Don Brady Date: Mon, 10 May 2021 20:41:49 -0600 Subject: [PATCH] DLPX-75524 avoid unnecessary nfserr_jukebox returns from nfsd_file_acquire (#8) Upstream fix from kernel 5.12 nfsd: Don't keep looking up unhashed files in the nfsd file cache If a file is unhashed, then we're going to reject it anyway and retry, so make sure we skip it when we're doing the RCU lockless lookup. This avoids a number of unnecessary nfserr_jukebox returns from nfsd_file_acquire() Fixes: 65294c1f2c5e ("nfsd: add a new struct file caching facility to nfsd") --- fs/nfsd/filecache.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index fde013b6e05b..a48db6f00154 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -958,6 +958,9 @@ nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp, if (!new) { trace_nfsd_file_acquire(rqstp, hashval, inode, may_flags, NULL, nfserr_jukebox); + pr_warn_ratelimited("nfsd: nfsd_file_acquire alloc failed XID, " + "%08x, nfserr_jukebox\n", + be32_to_cpu(rqstp->rq_xid)); return nfserr_jukebox; } @@ -975,6 +978,10 @@ nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp, if (!test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) { if (!retry) { status = nfserr_jukebox; + pr_warn_ratelimited("nfsd: nfsd_file_acquire " + "construction failed, XID %08x, " + "nfserr_jukebox\n", + be32_to_cpu(rqstp->rq_xid)); goto out; } retry = false; @@ -1011,11 +1018,15 @@ nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp, nfsd_file_gc(); nf->nf_mark = nfsd_file_mark_find_or_create(nf); - if (nf->nf_mark) + if (nf->nf_mark) { status = nfsd_open_verified(rqstp, fhp, S_IFREG, may_flags, &nf->nf_file); - else + } else { + pr_warn_ratelimited("nfsd: nfsd_file_acquire no file mark, XID " + "%08x, nfserr_jukebox\n", + be32_to_cpu(rqstp->rq_xid)); status = nfserr_jukebox; + } /* * If construction failed, or we raced with a call to unlink() * then unhash.