[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8951e9da-15ae-f05e-a9a4-a9354249cee2@bytedance.com>
Date: Thu, 27 Jul 2023 17:08:52 +0800
From: Qi Zheng <zhengqi.arch@...edance.com>
To: akpm@...ux-foundation.org, david@...morbit.com, tkhai@...ru,
vbabka@...e.cz, roman.gushchin@...ux.dev, djwong@...nel.org,
brauner@...nel.org, paulmck@...nel.org, tytso@....edu,
steven.price@....com, cel@...nel.org, senozhatsky@...omium.org,
yujie.liu@...el.com, gregkh@...uxfoundation.org,
muchun.song@...ux.dev
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org, x86@...nel.org,
kvm@...r.kernel.org, xen-devel@...ts.xenproject.org,
linux-erofs@...ts.ozlabs.org,
linux-f2fs-devel@...ts.sourceforge.net, cluster-devel@...hat.com,
linux-nfs@...r.kernel.org, linux-mtd@...ts.infradead.org,
rcu@...r.kernel.org, netdev@...r.kernel.org,
dri-devel@...ts.freedesktop.org, linux-arm-msm@...r.kernel.org,
dm-devel@...hat.com, linux-raid@...r.kernel.org,
linux-bcache@...r.kernel.org,
virtualization@...ts.linux-foundation.org,
linux-fsdevel@...r.kernel.org, linux-ext4@...r.kernel.org,
linux-xfs@...r.kernel.org, linux-btrfs@...r.kernel.org,
Muchun Song <songmuchun@...edance.com>
Subject: Re: [PATCH v3 16/49] nfsd: dynamically allocate the nfsd-filecache
shrinker
On 2023/7/27 16:04, Qi Zheng wrote:
> Use new APIs to dynamically allocate the nfsd-filecache shrinker.
>
> Signed-off-by: Qi Zheng <zhengqi.arch@...edance.com>
> Reviewed-by: Muchun Song <songmuchun@...edance.com>
> ---
> fs/nfsd/filecache.c | 22 ++++++++++++----------
> 1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
> index ee9c923192e0..872eb9501965 100644
> --- a/fs/nfsd/filecache.c
> +++ b/fs/nfsd/filecache.c
> @@ -521,11 +521,7 @@ nfsd_file_lru_scan(struct shrinker *s, struct shrink_control *sc)
> return ret;
> }
>
> -static struct shrinker nfsd_file_shrinker = {
> - .scan_objects = nfsd_file_lru_scan,
> - .count_objects = nfsd_file_lru_count,
> - .seeks = 1,
> -};
> +static struct shrinker *nfsd_file_shrinker;
>
> /**
> * nfsd_file_cond_queue - conditionally unhash and queue a nfsd_file
> @@ -746,12 +742,18 @@ nfsd_file_cache_init(void)
> goto out_err;
> }
>
> - ret = register_shrinker(&nfsd_file_shrinker, "nfsd-filecache");
> - if (ret) {
> - pr_err("nfsd: failed to register nfsd_file_shrinker: %d\n", ret);
> + nfsd_file_shrinker = shrinker_alloc(0, "nfsd-filecache");
> + if (!nfsd_file_shrinker) {
Here should set ret to -ENOMEM, will fix.
> + pr_err("nfsd: failed to allocate nfsd_file_shrinker\n");
> goto out_lru;
> }
>
> + nfsd_file_shrinker->count_objects = nfsd_file_lru_count;
> + nfsd_file_shrinker->scan_objects = nfsd_file_lru_scan;
> + nfsd_file_shrinker->seeks = 1;
> +
> + shrinker_register(nfsd_file_shrinker);
> +
> ret = lease_register_notifier(&nfsd_file_lease_notifier);
> if (ret) {
> pr_err("nfsd: unable to register lease notifier: %d\n", ret);
> @@ -774,7 +776,7 @@ nfsd_file_cache_init(void)
> out_notifier:
> lease_unregister_notifier(&nfsd_file_lease_notifier);
> out_shrinker:
> - unregister_shrinker(&nfsd_file_shrinker);
> + shrinker_free(nfsd_file_shrinker);
> out_lru:
> list_lru_destroy(&nfsd_file_lru);
> out_err:
> @@ -891,7 +893,7 @@ nfsd_file_cache_shutdown(void)
> return;
>
> lease_unregister_notifier(&nfsd_file_lease_notifier);
> - unregister_shrinker(&nfsd_file_shrinker);
> + shrinker_free(nfsd_file_shrinker);
> /*
> * make sure all callers of nfsd_file_lru_cb are done before
> * calling nfsd_file_cache_purge
Powered by blists - more mailing lists