lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-Id: <20230807110936.21819-11-zhengqi.arch@bytedance.com> Date: Mon, 7 Aug 2023 19:08:58 +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, simon.horman@...igine.com, dlemoal@...nel.org 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, Qi Zheng <zhengqi.arch@...edance.com>, Muchun Song <songmuchun@...edance.com> Subject: [PATCH v4 10/48] f2fs: dynamically allocate the f2fs-shrinker Use new APIs to dynamically allocate the f2fs-shrinker. Signed-off-by: Qi Zheng <zhengqi.arch@...edance.com> Reviewed-by: Muchun Song <songmuchun@...edance.com> --- fs/f2fs/super.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index aa1f9a3a8037..9092310582aa 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -83,11 +83,27 @@ void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate, #endif /* f2fs-wide shrinker description */ -static struct shrinker f2fs_shrinker_info = { - .scan_objects = f2fs_shrink_scan, - .count_objects = f2fs_shrink_count, - .seeks = DEFAULT_SEEKS, -}; +static struct shrinker *f2fs_shrinker_info; + +static int __init f2fs_init_shrinker(void) +{ + f2fs_shrinker_info = shrinker_alloc(0, "f2fs-shrinker"); + if (!f2fs_shrinker_info) + return -ENOMEM; + + f2fs_shrinker_info->count_objects = f2fs_shrink_count; + f2fs_shrinker_info->scan_objects = f2fs_shrink_scan; + f2fs_shrinker_info->seeks = DEFAULT_SEEKS; + + shrinker_register(f2fs_shrinker_info); + + return 0; +} + +static void f2fs_exit_shrinker(void) +{ + shrinker_free(f2fs_shrinker_info); +} enum { Opt_gc_background, @@ -4940,7 +4956,7 @@ static int __init init_f2fs_fs(void) err = f2fs_init_sysfs(); if (err) goto free_garbage_collection_cache; - err = register_shrinker(&f2fs_shrinker_info, "f2fs-shrinker"); + err = f2fs_init_shrinker(); if (err) goto free_sysfs; err = register_filesystem(&f2fs_fs_type); @@ -4985,7 +5001,7 @@ static int __init init_f2fs_fs(void) f2fs_destroy_root_stats(); unregister_filesystem(&f2fs_fs_type); free_shrinker: - unregister_shrinker(&f2fs_shrinker_info); + f2fs_exit_shrinker(); free_sysfs: f2fs_exit_sysfs(); free_garbage_collection_cache: @@ -5017,7 +5033,7 @@ static void __exit exit_f2fs_fs(void) f2fs_destroy_post_read_processing(); f2fs_destroy_root_stats(); unregister_filesystem(&f2fs_fs_type); - unregister_shrinker(&f2fs_shrinker_info); + f2fs_exit_shrinker(); f2fs_exit_sysfs(); f2fs_destroy_garbage_collection_cache(); f2fs_destroy_extent_cache(); -- 2.30.2
Powered by blists - more mailing lists