btrfs: compression: let workspace manager init take only the type
authorDavid Sterba <dsterba@suse.com>
Thu, 3 Oct 2019 23:40:58 +0000 (01:40 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 18 Nov 2019 11:46:57 +0000 (12:46 +0100)
With the access to the workspace structures, we can look it up together
with the compression ops inside the workspace manager init helper.

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c
fs/btrfs/compression.h
fs/btrfs/lzo.c
fs/btrfs/zlib.c

index e650125b1d2bfa45506639b2f277118ab0e9739c..6adc7f6857d7debc0935bfb595346866854dae97 100644 (file)
@@ -862,7 +862,7 @@ static struct workspace_manager heuristic_wsm;
 
 static void heuristic_init_workspace_manager(void)
 {
-       btrfs_init_workspace_manager(&heuristic_wsm, &btrfs_heuristic_compress);
+       btrfs_init_workspace_manager(BTRFS_COMPRESS_NONE);
 }
 
 static void heuristic_cleanup_workspace_manager(void)
@@ -937,9 +937,10 @@ static const struct btrfs_compress_op * const btrfs_compress_op[] = {
        &btrfs_zstd_compress,
 };
 
-void btrfs_init_workspace_manager(struct workspace_manager *wsm,
-                                 const struct btrfs_compress_op *ops)
+void btrfs_init_workspace_manager(int type)
 {
+       const struct btrfs_compress_op *ops = btrfs_compress_op[type];
+       struct workspace_manager *wsm = ops->workspace_manager;
        struct list_head *workspace;
 
        wsm->ops = ops;
index 7091eae063e559a10e0ca8a02b77fedecce3d722..10f82e7917698e8e9c1e2e60980a9c848c967e25 100644 (file)
@@ -120,8 +120,7 @@ struct workspace_manager {
        wait_queue_head_t ws_wait;
 };
 
-void btrfs_init_workspace_manager(struct workspace_manager *wsm,
-                                 const struct btrfs_compress_op *ops);
+void btrfs_init_workspace_manager(int type);
 struct list_head *btrfs_get_workspace(struct workspace_manager *wsm,
                                      unsigned int level);
 void btrfs_put_workspace(struct workspace_manager *wsm, struct list_head *ws);
index aff105cc80e7f00e0b53c3f35731b04611f7a7bd..5b8470041bf66388634bb004eeee38605a8bf45c 100644 (file)
@@ -65,7 +65,7 @@ static struct workspace_manager wsm;
 
 static void lzo_init_workspace_manager(void)
 {
-       btrfs_init_workspace_manager(&wsm, &btrfs_lzo_compress);
+       btrfs_init_workspace_manager(BTRFS_COMPRESS_LZO);
 }
 
 static void lzo_cleanup_workspace_manager(void)
index a5e8f020747311e01168f31de1e3238db3dbbcd7..be964128dba3411d20480b89037f251f7f33ad2a 100644 (file)
@@ -31,7 +31,7 @@ static struct workspace_manager wsm;
 
 static void zlib_init_workspace_manager(void)
 {
-       btrfs_init_workspace_manager(&wsm, &btrfs_zlib_compress);
+       btrfs_init_workspace_manager(BTRFS_COMPRESS_ZLIB);
 }
 
 static void zlib_cleanup_workspace_manager(void)