Skip to content

Commit ed5213d

Browse files
Don BradyDelphix Engineering
Don Brady
authored and
Delphix Engineering
committed
DLPX-84995 NFSD: Never call nfsd_file_gc() in foreground paths (#24)
The checks in nfsd_file_acquire() and nfsd_file_put() that directly invoke filecache garbage collection are intended to keep cache occupancy between a low- and high-watermark. The reason to limit the capacity of the filecache is to keep filecache lookups reasonably fast. However, invoking garbage collection at those points has some undesirable negative impacts. Files that are held open by NFSv4 clients often push the occupancy of the filecache over these watermarks. At that point: - Every call to nfsd_file_acquire() and nfsd_file_put() results in an LRU walk. This has the same effect on lookup latency as long chains in the hash table. - Garbage collection will then run on every nfsd thread, causing a lot of unnecessary lock contention. - Limiting cache capacity pushes out files used only by NFSv3 clients, which are the type of files the filecache is supposed to help. To address those negative impacts, remove the direct calls to the garbage collector.
1 parent 517a113 commit ed5213d

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

fs/nfsd/filecache.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
#define NFSD_FILE_LRU_RESCAN (0)
3131
#define NFSD_FILE_SHUTDOWN (1)
32-
#define NFSD_FILE_LRU_THRESHOLD (4096UL)
33-
#define NFSD_FILE_LRU_LIMIT (NFSD_FILE_LRU_THRESHOLD << 2)
3432

3533
/* We only care about NFSD_MAY_READ/WRITE for this cache */
3634
#define NFSD_FILE_MAY_MASK (NFSD_MAY_READ|NFSD_MAY_WRITE)
@@ -66,8 +64,6 @@ static struct delayed_work nfsd_filecache_laundrette;
6664
static DEFINE_SPINLOCK(laundrette_lock);
6765
static LIST_HEAD(laundrettes);
6866

69-
static void nfsd_file_gc(void);
70-
7167
static void
7268
nfsd_file_schedule_laundrette(void)
7369
{
@@ -317,8 +313,6 @@ nfsd_file_put(struct nfsd_file *nf)
317313
set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);
318314
if (nfsd_file_put_noref(nf) == 1 && is_hashed && unused)
319315
nfsd_file_schedule_laundrette();
320-
if (atomic_long_read(&nfsd_filecache_count) >= NFSD_FILE_LRU_LIMIT)
321-
nfsd_file_gc();
322316
}
323317

324318
struct nfsd_file *
@@ -1044,8 +1038,7 @@ nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
10441038
nfsd_file_hashtbl[hashval].nfb_maxcount = max(nfsd_file_hashtbl[hashval].nfb_maxcount,
10451039
nfsd_file_hashtbl[hashval].nfb_count);
10461040
spin_unlock(&nfsd_file_hashtbl[hashval].nfb_lock);
1047-
if (atomic_long_inc_return(&nfsd_filecache_count) >= NFSD_FILE_LRU_THRESHOLD)
1048-
nfsd_file_gc();
1041+
atomic_long_inc(&nfsd_filecache_count);
10491042

10501043
nf->nf_mark = nfsd_file_mark_find_or_create(nf);
10511044
if (nf->nf_mark) {

0 commit comments

Comments
 (0)