mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 21:21:09 -04:00
nfsd: dynamically allocate the nfsd-client shrinker
In preparation for implementing lockless slab shrink, use new APIs to dynamically allocate the nfsd-client shrinker, so that it can be freed asynchronously via RCU. Then it doesn't need to wait for RCU read-side critical section when releasing the struct nfsd_net. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Qi Zheng <[email protected]> Acked-by: Chuck Lever <[email protected]> Acked-by: Jeff Layton <[email protected]> Cc: Jeff Layton <[email protected]> Cc: Olga Kornievskaia <[email protected]> Cc: Dai Ngo <[email protected]> Cc: Tom Talpey <[email protected]> Cc: Abhinav Kumar <[email protected]> Cc: Alasdair Kergon <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Alyssa Rosenzweig <[email protected]> Cc: Andreas Dilger <[email protected]> Cc: Andreas Gruenbacher <[email protected]> Cc: Anna Schumaker <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Bob Peterson <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Carlos Llamas <[email protected]> Cc: Chandan Babu R <[email protected]> Cc: Chao Yu <[email protected]> Cc: Chris Mason <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Christian Koenig <[email protected]> Cc: Chuck Lever <[email protected]> Cc: Coly Li <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: "Darrick J. Wong" <[email protected]> Cc: Dave Chinner <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Airlie <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: David Sterba <[email protected]> Cc: Dmitry Baryshkov <[email protected]> Cc: Gao Xiang <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Huang Rui <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jaegeuk Kim <[email protected]> Cc: Jani Nikula <[email protected]> Cc: Jan Kara <[email protected]> Cc: Jason Wang <[email protected]> Cc: Jeffle Xu <[email protected]> Cc: Joel Fernandes (Google) <[email protected]> Cc: Joonas Lahtinen <[email protected]> Cc: Josef Bacik <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: Kirill Tkhai <[email protected]> Cc: Marijn Suijten <[email protected]> Cc: "Michael S. Tsirkin" <[email protected]> Cc: Mike Snitzer <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Muchun Song <[email protected]> Cc: Muchun Song <[email protected]> Cc: Nadav Amit <[email protected]> Cc: Neil Brown <[email protected]> Cc: Oleksandr Tyshchenko <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Rob Clark <[email protected]> Cc: Rob Herring <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Sean Paul <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: Song Liu <[email protected]> Cc: Stefano Stabellini <[email protected]> Cc: Steven Price <[email protected]> Cc: "Theodore Ts'o" <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Tomeu Vizoso <[email protected]> Cc: Trond Myklebust <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Xuan Zhuo <[email protected]> Cc: Yue Hu <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
+1
-1
@@ -195,7 +195,7 @@ struct nfsd_net {
|
||||
int nfs4_max_clients;
|
||||
|
||||
atomic_t nfsd_courtesy_clients;
|
||||
struct shrinker nfsd_client_shrinker;
|
||||
struct shrinker *nfsd_client_shrinker;
|
||||
struct work_struct nfsd_shrinker_work;
|
||||
};
|
||||
|
||||
|
||||
+11
-8
@@ -4400,8 +4400,7 @@ static unsigned long
|
||||
nfsd4_state_shrinker_count(struct shrinker *shrink, struct shrink_control *sc)
|
||||
{
|
||||
int count;
|
||||
struct nfsd_net *nn = container_of(shrink,
|
||||
struct nfsd_net, nfsd_client_shrinker);
|
||||
struct nfsd_net *nn = shrink->private_data;
|
||||
|
||||
count = atomic_read(&nn->nfsd_courtesy_clients);
|
||||
if (!count)
|
||||
@@ -8149,12 +8148,16 @@ static int nfs4_state_create_net(struct net *net)
|
||||
INIT_WORK(&nn->nfsd_shrinker_work, nfsd4_state_shrinker_worker);
|
||||
get_net(net);
|
||||
|
||||
nn->nfsd_client_shrinker.scan_objects = nfsd4_state_shrinker_scan;
|
||||
nn->nfsd_client_shrinker.count_objects = nfsd4_state_shrinker_count;
|
||||
nn->nfsd_client_shrinker.seeks = DEFAULT_SEEKS;
|
||||
|
||||
if (register_shrinker(&nn->nfsd_client_shrinker, "nfsd-client"))
|
||||
nn->nfsd_client_shrinker = shrinker_alloc(0, "nfsd-client");
|
||||
if (!nn->nfsd_client_shrinker)
|
||||
goto err_shrinker;
|
||||
|
||||
nn->nfsd_client_shrinker->scan_objects = nfsd4_state_shrinker_scan;
|
||||
nn->nfsd_client_shrinker->count_objects = nfsd4_state_shrinker_count;
|
||||
nn->nfsd_client_shrinker->private_data = nn;
|
||||
|
||||
shrinker_register(nn->nfsd_client_shrinker);
|
||||
|
||||
return 0;
|
||||
|
||||
err_shrinker:
|
||||
@@ -8252,7 +8255,7 @@ nfs4_state_shutdown_net(struct net *net)
|
||||
struct list_head *pos, *next, reaplist;
|
||||
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
|
||||
|
||||
unregister_shrinker(&nn->nfsd_client_shrinker);
|
||||
shrinker_free(nn->nfsd_client_shrinker);
|
||||
cancel_work(&nn->nfsd_shrinker_work);
|
||||
cancel_delayed_work_sync(&nn->laundromat_work);
|
||||
locks_end_grace(&nn->nfsd4_manager);
|
||||
|
||||
Reference in New Issue
Block a user