[PATCH v6 06/45] erofs: dynamically allocate the erofs-shrinker
Qi Zheng
zhengqi.arch at bytedance.com
Mon Sep 11 19:44:05 AEST 2023
Use new APIs to dynamically allocate the erofs-shrinker.
Signed-off-by: Qi Zheng <zhengqi.arch at bytedance.com>
Reviewed-by: Muchun Song <songmuchun at bytedance.com>
Reviewed-by: Chao Yu <chao at kernel.org>
Reviewed-by: Gao Xiang <hsiangkao at linux.alibaba.com>
CC: Yue Hu <huyue2 at coolpad.com>
CC: Jeffle Xu <jefflexu at linux.alibaba.com>
CC: linux-erofs at lists.ozlabs.org
---
fs/erofs/utils.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/fs/erofs/utils.c b/fs/erofs/utils.c
index cc6fb9e98899..e9c25cd7b601 100644
--- a/fs/erofs/utils.c
+++ b/fs/erofs/utils.c
@@ -270,19 +270,24 @@ static unsigned long erofs_shrink_scan(struct shrinker *shrink,
return freed;
}
-static struct shrinker erofs_shrinker_info = {
- .scan_objects = erofs_shrink_scan,
- .count_objects = erofs_shrink_count,
- .seeks = DEFAULT_SEEKS,
-};
+static struct shrinker *erofs_shrinker_info;
int __init erofs_init_shrinker(void)
{
- return register_shrinker(&erofs_shrinker_info, "erofs-shrinker");
+ erofs_shrinker_info = shrinker_alloc(0, "erofs-shrinker");
+ if (!erofs_shrinker_info)
+ return -ENOMEM;
+
+ erofs_shrinker_info->count_objects = erofs_shrink_count;
+ erofs_shrinker_info->scan_objects = erofs_shrink_scan;
+
+ shrinker_register(erofs_shrinker_info);
+
+ return 0;
}
void erofs_exit_shrinker(void)
{
- unregister_shrinker(&erofs_shrinker_info);
+ shrinker_free(erofs_shrinker_info);
}
#endif /* !CONFIG_EROFS_FS_ZIP */
--
2.30.2
More information about the Linux-erofs
mailing list