Skip to content

Commit

Permalink
DLPX-75524 avoid unnecessary nfserr_jukebox returns from nfsd_file_ac…
Browse files Browse the repository at this point in the history
…quire (delphix#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: 65294c1 ("nfsd: add a new struct file caching facility to nfsd")
  • Loading branch information
Don Brady authored and Delphix Engineering committed Jul 22, 2021
1 parent bfb16e4 commit 148448c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions fs/nfsd/filecache.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,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;
}

Expand All @@ -835,6 +838,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;
Expand Down Expand Up @@ -884,11 +891,15 @@ nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
atomic_long_inc(&nfsd_filecache_count);

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.
Expand Down

0 comments on commit 148448c

Please sign in to comment.