diff options
author | Qu Wenruo <wqu@suse.com> | 2025-08-14 10:29:58 +0930 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2025-09-23 08:49:16 +0200 |
commit | 9c8f4cf45651b8f07bd06df443871d526dc53cea (patch) | |
tree | f2944851b447823146017edcf63f877fef5461dd | |
parent | 856d46c31343169a566f44035c4c74b2f0842438 (diff) |
btrfs: cleanup the per-module compression workspace managers
Since all workspaces are handled by the per-fs workspace managers, we
can safely remove the old per-module managers.
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/compression.c | 55 | ||||
-rw-r--r-- | fs/btrfs/compression.h | 2 | ||||
-rw-r--r-- | fs/btrfs/lzo.c | 3 | ||||
-rw-r--r-- | fs/btrfs/zlib.c | 3 | ||||
-rw-r--r-- | fs/btrfs/zstd.c | 49 |
5 files changed, 1 insertions, 111 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index cd479016d73d..ff2bf3f358a5 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -688,8 +688,6 @@ struct heuristic_ws { struct list_head list; }; -static struct workspace_manager heuristic_wsm; - static void free_heuristic_ws(struct list_head *ws) { struct heuristic_ws *workspace; @@ -729,9 +727,7 @@ fail: return ERR_PTR(-ENOMEM); } -const struct btrfs_compress_op btrfs_heuristic_compress = { - .workspace_manager = &heuristic_wsm, -}; +const struct btrfs_compress_op btrfs_heuristic_compress = { 0 }; static const struct btrfs_compress_op * const btrfs_compress_op[] = { /* The heuristic is represented as compression type 0 */ @@ -807,32 +803,6 @@ static int alloc_workspace_manager(struct btrfs_fs_info *fs_info, return 0; } -static void btrfs_init_workspace_manager(struct btrfs_fs_info *fs_info, int type) -{ - struct workspace_manager *wsm; - struct list_head *workspace; - - wsm = btrfs_compress_op[type]->workspace_manager; - INIT_LIST_HEAD(&wsm->idle_ws); - spin_lock_init(&wsm->ws_lock); - atomic_set(&wsm->total_ws, 0); - init_waitqueue_head(&wsm->ws_wait); - - /* - * Preallocate one workspace for each compression type so we can - * guarantee forward progress in the worst case - */ - workspace = alloc_workspace(fs_info, type, 0); - if (IS_ERR(workspace)) { - btrfs_warn(fs_info, - "cannot preallocate compression workspace, will try later"); - } else { - atomic_set(&wsm->total_ws, 1); - wsm->free_ws = 1; - list_add(workspace, &wsm->idle_ws); - } -} - static void free_workspace_manager(struct btrfs_fs_info *fs_info, enum btrfs_compression_type type) { @@ -853,20 +823,6 @@ static void free_workspace_manager(struct btrfs_fs_info *fs_info, kfree(gwsm); } -static void btrfs_cleanup_workspace_manager(int type) -{ - struct workspace_manager *wsman; - struct list_head *ws; - - wsman = btrfs_compress_op[type]->workspace_manager; - while (!list_empty(&wsman->idle_ws)) { - ws = wsman->idle_ws.next; - list_del(ws); - free_workspace(type, ws); - atomic_dec(&wsman->total_ws); - } -} - /* * This finds an available workspace or allocates a new one. * If it's not possible to allocate a new one, waits until there's one. @@ -1192,11 +1148,6 @@ int __init btrfs_init_compress(void) if (!compr_pool.shrinker) return -ENOMEM; - btrfs_init_workspace_manager(NULL, BTRFS_COMPRESS_NONE); - btrfs_init_workspace_manager(NULL, BTRFS_COMPRESS_ZLIB); - btrfs_init_workspace_manager(NULL, BTRFS_COMPRESS_LZO); - zstd_init_workspace_manager(NULL); - spin_lock_init(&compr_pool.lock); INIT_LIST_HEAD(&compr_pool.list); compr_pool.count = 0; @@ -1217,10 +1168,6 @@ void __cold btrfs_exit_compress(void) btrfs_compr_pool_scan(NULL, NULL); shrinker_free(compr_pool.shrinker); - btrfs_cleanup_workspace_manager(BTRFS_COMPRESS_NONE); - btrfs_cleanup_workspace_manager(BTRFS_COMPRESS_ZLIB); - btrfs_cleanup_workspace_manager(BTRFS_COMPRESS_LZO); - zstd_cleanup_workspace_manager(); bioset_exit(&btrfs_compressed_bioset); } diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h index 70a3294bd14a..4fa4d3b9fa57 100644 --- a/fs/btrfs/compression.h +++ b/fs/btrfs/compression.h @@ -183,8 +183,6 @@ int zstd_decompress(struct list_head *ws, const u8 *data_in, size_t destlen); int zstd_alloc_workspace_manager(struct btrfs_fs_info *fs_info); void zstd_free_workspace_manager(struct btrfs_fs_info *fs_info); -void zstd_init_workspace_manager(struct btrfs_fs_info *fs_info); -void zstd_cleanup_workspace_manager(void); struct list_head *zstd_alloc_workspace(struct btrfs_fs_info *fs_info, int level); void zstd_free_workspace(struct list_head *ws); struct list_head *zstd_get_workspace(struct btrfs_fs_info *fs_info, int level); diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c index 82407d7d9502..3456a1dcd420 100644 --- a/fs/btrfs/lzo.c +++ b/fs/btrfs/lzo.c @@ -68,8 +68,6 @@ struct workspace { struct list_head list; }; -static struct workspace_manager wsm; - void lzo_free_workspace(struct list_head *ws) { struct workspace *workspace = list_entry(ws, struct workspace, list); @@ -489,7 +487,6 @@ out: } const struct btrfs_compress_op btrfs_lzo_compress = { - .workspace_manager = &wsm, .max_level = 1, .default_level = 1, }; diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c index 5fc045aeaa19..aecc58054045 100644 --- a/fs/btrfs/zlib.c +++ b/fs/btrfs/zlib.c @@ -34,8 +34,6 @@ struct workspace { int level; }; -static struct workspace_manager wsm; - struct list_head *zlib_get_workspace(struct btrfs_fs_info *fs_info, unsigned int level) { struct list_head *ws = btrfs_get_workspace(fs_info, BTRFS_COMPRESS_ZLIB, level); @@ -483,7 +481,6 @@ out: } const struct btrfs_compress_op btrfs_zlib_compress = { - .workspace_manager = &wsm, .min_level = 1, .max_level = 9, .default_level = BTRFS_ZLIB_DEFAULT_LEVEL, diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c index 41019fcebc13..d514a73a4015 100644 --- a/fs/btrfs/zstd.c +++ b/fs/btrfs/zstd.c @@ -86,8 +86,6 @@ struct zstd_workspace_manager { struct timer_list timer; }; -static struct zstd_workspace_manager wsm; - static size_t zstd_ws_mem_sizes[ZSTD_BTRFS_MAX_LEVEL]; static inline struct workspace *list_to_workspace(struct list_head *list) @@ -212,31 +210,6 @@ int zstd_alloc_workspace_manager(struct btrfs_fs_info *fs_info) return 0; } -void zstd_init_workspace_manager(struct btrfs_fs_info *fs_info) -{ - struct list_head *ws; - int i; - - zstd_calc_ws_mem_sizes(); - - wsm.ops = &btrfs_zstd_compress; - spin_lock_init(&wsm.lock); - init_waitqueue_head(&wsm.wait); - timer_setup(&wsm.timer, zstd_reclaim_timer_fn, 0); - - INIT_LIST_HEAD(&wsm.lru_list); - for (i = 0; i < ZSTD_BTRFS_MAX_LEVEL; i++) - INIT_LIST_HEAD(&wsm.idle_ws[i]); - - ws = zstd_alloc_workspace(fs_info, ZSTD_BTRFS_MAX_LEVEL); - if (IS_ERR(ws)) { - btrfs_warn(NULL, "cannot preallocate zstd compression workspace"); - } else { - set_bit(ZSTD_BTRFS_MAX_LEVEL - 1, &wsm.active_map); - list_add(ws, &wsm.idle_ws[ZSTD_BTRFS_MAX_LEVEL - 1]); - } -} - void zstd_free_workspace_manager(struct btrfs_fs_info *fs_info) { struct zstd_workspace_manager *zwsm = fs_info->compr_wsm[BTRFS_COMPRESS_ZSTD]; @@ -260,26 +233,6 @@ void zstd_free_workspace_manager(struct btrfs_fs_info *fs_info) kfree(zwsm); } -void zstd_cleanup_workspace_manager(void) -{ - struct workspace *workspace; - int i; - - spin_lock_bh(&wsm.lock); - for (i = 0; i < ZSTD_BTRFS_MAX_LEVEL; i++) { - while (!list_empty(&wsm.idle_ws[i])) { - workspace = container_of(wsm.idle_ws[i].next, - struct workspace, list); - list_del(&workspace->list); - list_del(&workspace->lru_list); - zstd_free_workspace(&workspace->list); - } - } - spin_unlock_bh(&wsm.lock); - - timer_delete_sync(&wsm.timer); -} - /* * Find workspace for given level. * @@ -775,8 +728,6 @@ finish: } const struct btrfs_compress_op btrfs_zstd_compress = { - /* ZSTD uses own workspace manager */ - .workspace_manager = NULL, .min_level = ZSTD_BTRFS_MIN_LEVEL, .max_level = ZSTD_BTRFS_MAX_LEVEL, .default_level = ZSTD_BTRFS_DEFAULT_LEVEL, |