NFSD: Document and rename the NFSv4.1 session slot shrinker callbacks

Clean up: To prevent their reuse by generic code, rename the NFSv4.1
session slot shrinker's callback functions to make it clear they are
for use only by the shrinker.

Though they are static, callbacks are invoked from outside nfsd.ko,
so they need appropriate kdoc comments that document their API
contracts.

Reviewed-by: NeilBrown <neil@brown.name>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Benjamin Coddington <bcodding@hammerspace.com>
Link: https://patch.msgid.link/20260610-nfsd-slot-growth-clamp-v1-4-7b966700df0b@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
This commit is contained in:
Chuck Lever
2026-06-10 21:58:56 -04:00
parent 2f3c6a6400
commit a69ab29f49

View File

@@ -2297,8 +2297,16 @@ static void free_session(struct nfsd4_session *ses)
__free_session(ses);
}
/**
* nfsd_slot_shrinker_count - report reclaimable DRC slots
* @s: shrinker descriptor (unused)
* @sc: shrink control (unused)
*
* Return: a positive count of reclaimable slots, or SHRINK_EMPTY when
* there is nothing to reclaim.
*/
static unsigned long
nfsd_slot_count(struct shrinker *s, struct shrink_control *sc)
nfsd_slot_shrinker_count(struct shrinker *s, struct shrink_control *sc)
{
int count;
@@ -2313,13 +2321,27 @@ nfsd_slot_count(struct shrinker *s, struct shrink_control *sc)
return count > 0 ? count : SHRINK_EMPTY;
}
/**
* nfsd_slot_shrinker_scan - reclaim DRC slots under memory pressure
* @s: shrinker descriptor (unused)
* @sc: shrink control; @sc->nr_to_scan bounds the sessions visited,
* @sc->nr_scanned reports how many were visited
*
* Return: the number of session slots NFSD will release.
*/
static unsigned long
nfsd_slot_scan(struct shrinker *s, struct shrink_control *sc)
nfsd_slot_shrinker_scan(struct shrinker *s, struct shrink_control *sc)
{
struct nfsd4_session *ses;
unsigned long scanned = 0;
unsigned long freed = 0;
/*
* Each visited session releases at most one slot. After
* nr_to_scan sessions have been visited, the list head is
* rotated past the last visited session so the next scan
* resumes from there.
*/
spin_lock(&nfsd_session_list_lock);
list_for_each_entry(ses, &nfsd_session_list, se_all_sessions) {
freed += reduce_session_slots(ses, 1);
@@ -9325,8 +9347,8 @@ nfs4_state_start(void)
rhltable_destroy(&nfs4_file_rhltable);
return -ENOMEM;
}
nfsd_slot_shrinker->count_objects = nfsd_slot_count;
nfsd_slot_shrinker->scan_objects = nfsd_slot_scan;
nfsd_slot_shrinker->count_objects = nfsd_slot_shrinker_count;
nfsd_slot_shrinker->scan_objects = nfsd_slot_shrinker_scan;
shrinker_register(nfsd_slot_shrinker);
set_max_delegations();