Skip to content

Commit f4a86f8

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 da0ec7a commit f4a86f8

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
@@ -28,8 +28,6 @@
2828
#define NFSD_LAUNDRETTE_DELAY (2 * HZ)
2929

3030
#define NFSD_FILE_SHUTDOWN (1)
31-
#define NFSD_FILE_LRU_THRESHOLD (4096UL)
32-
#define NFSD_FILE_LRU_LIMIT (NFSD_FILE_LRU_THRESHOLD << 2)
3331

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

68-
static void nfsd_file_gc(void);
69-
7066
static void
7167
nfsd_file_schedule_laundrette(void)
7268
{
@@ -306,8 +302,6 @@ nfsd_file_put(struct nfsd_file *nf)
306302
nfsd_file_put_noref(nf);
307303
if (is_hashed)
308304
nfsd_file_schedule_laundrette();
309-
if (atomic_long_read(&nfsd_filecache_count) >= NFSD_FILE_LRU_LIMIT)
310-
nfsd_file_gc();
311305
}
312306

313307
struct nfsd_file *
@@ -1007,8 +1001,7 @@ nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
10071001
nfsd_file_hashtbl[hashval].nfb_maxcount = max(nfsd_file_hashtbl[hashval].nfb_maxcount,
10081002
nfsd_file_hashtbl[hashval].nfb_count);
10091003
spin_unlock(&nfsd_file_hashtbl[hashval].nfb_lock);
1010-
if (atomic_long_inc_return(&nfsd_filecache_count) >= NFSD_FILE_LRU_THRESHOLD)
1011-
nfsd_file_gc();
1004+
atomic_long_inc(&nfsd_filecache_count);
10121005

10131006
nf->nf_mark = nfsd_file_mark_find_or_create(nf);
10141007
if (nf->nf_mark)

0 commit comments

Comments
 (0)