OSDN Git Service

btrfs: compression: inline cleanup_workspace_manager
authorDavid Sterba <dsterba@suse.com>
Tue, 1 Oct 2019 23:08:03 +0000 (01:08 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 18 Nov 2019 11:46:57 +0000 (12:46 +0100)
Replace loop calling to all algos with a list of direct calls to the
cleanup manager callback. When that becomes trivial it is replaced by
direct call to the 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
fs/btrfs/zstd.c

index 6c4dc62..34921a1 100644 (file)
@@ -53,6 +53,7 @@ int zstd_decompress(struct list_head *ws, unsigned char *data_in,
                struct page *dest_page, unsigned long start_byte, size_t srclen,
                size_t destlen);
 void zstd_init_workspace_manager(void);
+void zstd_cleanup_workspace_manager(void);
 
 static const char* const btrfs_compress_types[] = { "", "zlib", "lzo", "zstd" };
 
@@ -861,11 +862,6 @@ struct heuristic_ws {
 
 static struct workspace_manager heuristic_wsm;
 
-static void heuristic_cleanup_workspace_manager(void)
-{
-       btrfs_cleanup_workspace_manager(BTRFS_COMPRESS_NONE);
-}
-
 static struct list_head *heuristic_get_workspace(unsigned int level)
 {
        return btrfs_get_workspace(&heuristic_wsm, level);
@@ -917,7 +913,6 @@ fail:
 
 const struct btrfs_compress_op btrfs_heuristic_compress = {
        .workspace_manager = &heuristic_wsm,
-       .cleanup_workspace_manager = heuristic_cleanup_workspace_manager,
        .get_workspace = heuristic_get_workspace,
        .put_workspace = heuristic_put_workspace,
        .alloc_workspace = alloc_heuristic_ws,
@@ -960,7 +955,7 @@ static void btrfs_init_workspace_manager(int type)
        }
 }
 
-void btrfs_cleanup_workspace_manager(int type)
+static void btrfs_cleanup_workspace_manager(int type)
 {
        struct workspace_manager *wsman;
        struct list_head *ws;
@@ -1199,10 +1194,10 @@ void __init btrfs_init_compress(void)
 
 void __cold btrfs_exit_compress(void)
 {
-       int i;
-
-       for (i = 0; i < BTRFS_NR_WORKSPACE_MANAGERS; i++)
-               btrfs_compress_op[i]->cleanup_workspace_manager();
+       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();
 }
 
 /*
index 0deaa8e..cf667e5 100644 (file)
@@ -123,11 +123,8 @@ struct workspace_manager {
 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);
-void btrfs_cleanup_workspace_manager(int type);
 
 struct btrfs_compress_op {
-       void (*cleanup_workspace_manager)(void);
-
        struct list_head *(*get_workspace)(unsigned int level);
 
        void (*put_workspace)(struct list_head *ws);
index 6aa6020..6f4619e 100644 (file)
@@ -63,11 +63,6 @@ struct workspace {
 
 static struct workspace_manager wsm;
 
-static void lzo_cleanup_workspace_manager(void)
-{
-       btrfs_cleanup_workspace_manager(BTRFS_COMPRESS_LZO);
-}
-
 static struct list_head *lzo_get_workspace(unsigned int level)
 {
        return btrfs_get_workspace(&wsm, level);
@@ -499,7 +494,6 @@ out:
 
 const struct btrfs_compress_op btrfs_lzo_compress = {
        .workspace_manager      = &wsm,
-       .cleanup_workspace_manager = lzo_cleanup_workspace_manager,
        .get_workspace          = lzo_get_workspace,
        .put_workspace          = lzo_put_workspace,
        .alloc_workspace        = lzo_alloc_workspace,
index 7319e9f..03c632c 100644 (file)
@@ -29,11 +29,6 @@ struct workspace {
 
 static struct workspace_manager wsm;
 
-static void zlib_cleanup_workspace_manager(void)
-{
-       btrfs_cleanup_workspace_manager(BTRFS_COMPRESS_ZLIB);
-}
-
 static struct list_head *zlib_get_workspace(unsigned int level)
 {
        struct list_head *ws = btrfs_get_workspace(&wsm, level);
@@ -410,7 +405,6 @@ next:
 
 const struct btrfs_compress_op btrfs_zlib_compress = {
        .workspace_manager      = &wsm,
-       .cleanup_workspace_manager = zlib_cleanup_workspace_manager,
        .get_workspace          = zlib_get_workspace,
        .put_workspace          = zlib_put_workspace,
        .alloc_workspace        = zlib_alloc_workspace,
index 8e7a804..f575ce7 100644 (file)
@@ -194,7 +194,7 @@ void zstd_init_workspace_manager(void)
        }
 }
 
-static void zstd_cleanup_workspace_manager(void)
+void zstd_cleanup_workspace_manager(void)
 {
        struct workspace *workspace;
        int i;
@@ -709,7 +709,6 @@ finish:
 const struct btrfs_compress_op btrfs_zstd_compress = {
        /* ZSTD uses own workspace manager */
        .workspace_manager = NULL,
-       .cleanup_workspace_manager = zstd_cleanup_workspace_manager,
        .get_workspace = zstd_get_workspace,
        .put_workspace = zstd_put_workspace,
        .alloc_workspace = zstd_alloc_workspace,