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 (#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 Prakash Surya committed Mar 14, 2023
1 parent 26eae8a commit ff7c2b2
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 @@ -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;
}

Expand All @@ -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;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit ff7c2b2

Please sign in to comment.