Skip to content

Commit a1049eb

Browse files
daimngoChuck Lever
authored andcommitted
NFSD: refactoring courtesy_client_reaper to a generic low memory shrinker
Refactoring courtesy_client_reaper to generic low memory shrinker so it can be used for other purposes. Signed-off-by: Dai Ngo <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 247c01f commit a1049eb

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

fs/nfsd/nfs4state.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4361,7 +4361,7 @@ nfsd4_init_slabs(void)
43614361
}
43624362

43634363
static unsigned long
4364-
nfsd_courtesy_client_count(struct shrinker *shrink, struct shrink_control *sc)
4364+
nfsd4_state_shrinker_count(struct shrinker *shrink, struct shrink_control *sc)
43654365
{
43664366
int cnt;
43674367
struct nfsd_net *nn = container_of(shrink,
@@ -4374,7 +4374,7 @@ nfsd_courtesy_client_count(struct shrinker *shrink, struct shrink_control *sc)
43744374
}
43754375

43764376
static unsigned long
4377-
nfsd_courtesy_client_scan(struct shrinker *shrink, struct shrink_control *sc)
4377+
nfsd4_state_shrinker_scan(struct shrinker *shrink, struct shrink_control *sc)
43784378
{
43794379
return SHRINK_STOP;
43804380
}
@@ -4401,8 +4401,8 @@ nfsd4_init_leases_net(struct nfsd_net *nn)
44014401
nn->nfs4_max_clients = max_t(int, max_clients, NFS4_CLIENTS_PER_GB);
44024402

44034403
atomic_set(&nn->nfsd_courtesy_clients, 0);
4404-
nn->nfsd_client_shrinker.scan_objects = nfsd_courtesy_client_scan;
4405-
nn->nfsd_client_shrinker.count_objects = nfsd_courtesy_client_count;
4404+
nn->nfsd_client_shrinker.scan_objects = nfsd4_state_shrinker_scan;
4405+
nn->nfsd_client_shrinker.count_objects = nfsd4_state_shrinker_count;
44064406
nn->nfsd_client_shrinker.seeks = DEFAULT_SEEKS;
44074407
return register_shrinker(&nn->nfsd_client_shrinker, "nfsd-client");
44084408
}
@@ -6151,17 +6151,24 @@ laundromat_main(struct work_struct *laundry)
61516151
}
61526152

61536153
static void
6154-
courtesy_client_reaper(struct work_struct *reaper)
6154+
courtesy_client_reaper(struct nfsd_net *nn)
61556155
{
61566156
struct list_head reaplist;
6157-
struct delayed_work *dwork = to_delayed_work(reaper);
6158-
struct nfsd_net *nn = container_of(dwork, struct nfsd_net,
6159-
nfsd_shrinker_work);
61606157

61616158
nfs4_get_courtesy_client_reaplist(nn, &reaplist);
61626159
nfs4_process_client_reaplist(&reaplist);
61636160
}
61646161

6162+
static void
6163+
nfsd4_state_shrinker_worker(struct work_struct *work)
6164+
{
6165+
struct delayed_work *dwork = to_delayed_work(work);
6166+
struct nfsd_net *nn = container_of(dwork, struct nfsd_net,
6167+
nfsd_shrinker_work);
6168+
6169+
courtesy_client_reaper(nn);
6170+
}
6171+
61656172
static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp)
61666173
{
61676174
if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle))
@@ -7985,7 +7992,7 @@ static int nfs4_state_create_net(struct net *net)
79857992
INIT_LIST_HEAD(&nn->blocked_locks_lru);
79867993

79877994
INIT_DELAYED_WORK(&nn->laundromat_work, laundromat_main);
7988-
INIT_DELAYED_WORK(&nn->nfsd_shrinker_work, courtesy_client_reaper);
7995+
INIT_DELAYED_WORK(&nn->nfsd_shrinker_work, nfsd4_state_shrinker_worker);
79897996
get_net(net);
79907997

79917998
return 0;

0 commit comments

Comments
 (0)