Skip to content

Commit

Permalink
NFSD: replace delayed_work with work_struct for nfsd_client_shrinker
Browse files Browse the repository at this point in the history
Since nfsd4_state_shrinker_count always calls mod_delayed_work with
0 delay, we can replace delayed_work with work_struct to save some
space and overhead.

Also add the call to cancel_work after unregister the shrinker
in nfs4_state_shutdown_net.

Signed-off-by: Dai Ngo <[email protected]>
Reviewed-by: Jeff Layton <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>
  • Loading branch information
daimngo authored and chucklever committed Jan 12, 2023
1 parent f385f7d commit 7c24fa2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fs/nfsd/netns.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ struct nfsd_net {

atomic_t nfsd_courtesy_clients;
struct shrinker nfsd_client_shrinker;
struct delayed_work nfsd_shrinker_work;
struct work_struct nfsd_shrinker_work;
};

/* Simple check to find out if a given net was properly initialized */
Expand Down
8 changes: 4 additions & 4 deletions fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -4411,7 +4411,7 @@ nfsd4_state_shrinker_count(struct shrinker *shrink, struct shrink_control *sc)
if (!count)
count = atomic_long_read(&num_delegations);
if (count)
mod_delayed_work(laundry_wq, &nn->nfsd_shrinker_work, 0);
queue_work(laundry_wq, &nn->nfsd_shrinker_work);
return (unsigned long)count;
}

Expand Down Expand Up @@ -6225,8 +6225,7 @@ deleg_reaper(struct nfsd_net *nn)
static void
nfsd4_state_shrinker_worker(struct work_struct *work)
{
struct delayed_work *dwork = to_delayed_work(work);
struct nfsd_net *nn = container_of(dwork, struct nfsd_net,
struct nfsd_net *nn = container_of(work, struct nfsd_net,
nfsd_shrinker_work);

courtesy_client_reaper(nn);
Expand Down Expand Up @@ -8056,7 +8055,7 @@ static int nfs4_state_create_net(struct net *net)
INIT_LIST_HEAD(&nn->blocked_locks_lru);

INIT_DELAYED_WORK(&nn->laundromat_work, laundromat_main);
INIT_DELAYED_WORK(&nn->nfsd_shrinker_work, nfsd4_state_shrinker_worker);
INIT_WORK(&nn->nfsd_shrinker_work, nfsd4_state_shrinker_worker);
get_net(net);

nn->nfsd_client_shrinker.scan_objects = nfsd4_state_shrinker_scan;
Expand Down Expand Up @@ -8163,6 +8162,7 @@ nfs4_state_shutdown_net(struct net *net)
struct nfsd_net *nn = net_generic(net, nfsd_net_id);

unregister_shrinker(&nn->nfsd_client_shrinker);
cancel_work(&nn->nfsd_shrinker_work);
cancel_delayed_work_sync(&nn->laundromat_work);
locks_end_grace(&nn->nfsd4_manager);

Expand Down

0 comments on commit 7c24fa2

Please sign in to comment.