Skip to content

Commit 9993979

Browse files
Trond Myklebustchucklever
authored andcommitted
nfsd: Clean up nfsd_file_put()
Make it a little less racy, by removing the refcount_read() test. Then remove the redundant 'is_hashed' variable. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 6b8a943 commit 9993979

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

fs/nfsd/filecache.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,21 +301,14 @@ nfsd_file_put_noref(struct nfsd_file *nf)
301301
void
302302
nfsd_file_put(struct nfsd_file *nf)
303303
{
304-
bool is_hashed;
305-
306304
set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);
307-
if (refcount_read(&nf->nf_ref) > 2 || !nf->nf_file) {
308-
nfsd_file_put_noref(nf);
309-
return;
310-
}
311-
312-
is_hashed = test_bit(NFSD_FILE_HASHED, &nf->nf_flags) != 0;
313-
if (!is_hashed) {
305+
if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags) == 0) {
314306
nfsd_file_flush(nf);
315307
nfsd_file_put_noref(nf);
316308
} else {
317309
nfsd_file_put_noref(nf);
318-
nfsd_file_schedule_laundrette();
310+
if (nf->nf_file)
311+
nfsd_file_schedule_laundrette();
319312
}
320313
if (atomic_long_read(&nfsd_filecache_count) >= NFSD_FILE_LRU_LIMIT)
321314
nfsd_file_gc();

0 commit comments

Comments
 (0)