]> www.infradead.org Git - users/hch/misc.git/commitdiff
btrfs: rename btrfs_compress_op to btrfs_compress_levels
authorQu Wenruo <wqu@suse.com>
Thu, 14 Aug 2025 01:05:23 +0000 (10:35 +0930)
committerDavid Sterba <dsterba@suse.com>
Tue, 23 Sep 2025 06:49:16 +0000 (08:49 +0200)
Since all workspace managers are per-fs, there is no need nor no way to
store them inside btrfs_compress_op::wsm anymore.

With that said, we can do the following modifications:

- Remove zstd_workspace_mananger::ops
  Zstd always grab the global btrfs_compress_op[].
- Remove btrfs_compress_op::wsm member
- Rename btrfs_compress_op to btrfs_compress_levels

This should make it more clear that btrfs_compress_levels structures are
only to indicate the levels of each compress algorithm.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@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 ff2bf3f358a54e0bfc72472fbb5b2997905a534b..d1de0151a1540a4ec95d7d0d837d84c62ab5150e 100644 (file)
@@ -727,9 +727,9 @@ fail:
        return ERR_PTR(-ENOMEM);
 }
 
-const struct btrfs_compress_op btrfs_heuristic_compress = { 0 };
+const struct btrfs_compress_levels btrfs_heuristic_compress = { 0 };
 
-static const struct btrfs_compress_op * const btrfs_compress_op[] = {
+static const struct btrfs_compress_levels * const btrfs_compress_levels[] = {
        /* The heuristic is represented as compression type 0 */
        &btrfs_heuristic_compress,
        &btrfs_zlib_compress,
@@ -981,12 +981,12 @@ static void put_workspace(struct btrfs_fs_info *fs_info, int type, struct list_h
  */
 static int btrfs_compress_set_level(unsigned int type, int level)
 {
-       const struct btrfs_compress_op *ops = btrfs_compress_op[type];
+       const struct btrfs_compress_levels *levels = btrfs_compress_levels[type];
 
        if (level == 0)
-               level = ops->default_level;
+               level = levels->default_level;
        else
-               level = clamp(level, ops->min_level, ops->max_level);
+               level = clamp(level, levels->min_level, levels->max_level);
 
        return level;
 }
@@ -996,9 +996,9 @@ static int btrfs_compress_set_level(unsigned int type, int level)
  */
 bool btrfs_compress_level_valid(unsigned int type, int level)
 {
-       const struct btrfs_compress_op *ops = btrfs_compress_op[type];
+       const struct btrfs_compress_levels *levels = btrfs_compress_levels[type];
 
-       return ops->min_level <= level && level <= ops->max_level;
+       return levels->min_level <= level && level <= levels->max_level;
 }
 
 /* Wrapper around find_get_page(), with extra error message. */
index 4fa4d3b9fa570a5bb1fa037bd226f72847a69933..243771ae7d64390e42a66dad27c2b775a806ee56 100644 (file)
@@ -129,8 +129,7 @@ struct workspace_manager {
 struct list_head *btrfs_get_workspace(struct btrfs_fs_info *fs_info, int type, int level);
 void btrfs_put_workspace(struct btrfs_fs_info *fs_info, int type, struct list_head *ws);
 
-struct btrfs_compress_op {
-       struct workspace_manager *workspace_manager;
+struct btrfs_compress_levels {
        /* Maximum level supported by the compression algorithm */
        int min_level;
        int max_level;
@@ -140,10 +139,10 @@ struct btrfs_compress_op {
 /* The heuristic workspaces are managed via the 0th workspace manager */
 #define BTRFS_NR_WORKSPACE_MANAGERS    BTRFS_NR_COMPRESS_TYPES
 
-extern const struct btrfs_compress_op btrfs_heuristic_compress;
-extern const struct btrfs_compress_op btrfs_zlib_compress;
-extern const struct btrfs_compress_op btrfs_lzo_compress;
-extern const struct btrfs_compress_op btrfs_zstd_compress;
+extern const struct btrfs_compress_levels btrfs_heuristic_compress;
+extern const struct btrfs_compress_levels btrfs_zlib_compress;
+extern const struct btrfs_compress_levels btrfs_lzo_compress;
+extern const struct btrfs_compress_levels btrfs_zstd_compress;
 
 const char* btrfs_compress_type2str(enum btrfs_compression_type type);
 bool btrfs_compress_is_valid_type(const char *str, size_t len);
index 3456a1dcd420733556e85ecef7e9dfba09f7aa4c..2983214643daf32c3a17ede6274273fda83983cc 100644 (file)
@@ -486,7 +486,7 @@ out:
        return ret;
 }
 
-const struct btrfs_compress_op btrfs_lzo_compress = {
+const struct btrfs_compress_levels  btrfs_lzo_compress = {
        .max_level              = 1,
        .default_level          = 1,
 };
index aecc5805404505b04eb0c07baf44d1de95a39413..8e0bf34e099813d90a87cfbbbf2f1a2bc303a270 100644 (file)
@@ -480,7 +480,7 @@ out:
        return ret;
 }
 
-const struct btrfs_compress_op btrfs_zlib_compress = {
+const struct btrfs_compress_levels btrfs_zlib_compress = {
        .min_level              = 1,
        .max_level              = 9,
        .default_level          = BTRFS_ZLIB_DEFAULT_LEVEL,
index d514a73a4015f5fcce553c43014a1b47d89e7201..63faeb3ed9acb8fd16227551d1a705790ce49540 100644 (file)
@@ -77,7 +77,6 @@ struct workspace {
  */
 
 struct zstd_workspace_manager {
-       const struct btrfs_compress_op *ops;
        spinlock_t lock;
        struct list_head lru_list;
        struct list_head idle_ws[ZSTD_BTRFS_MAX_LEVEL];
@@ -190,7 +189,6 @@ int zstd_alloc_workspace_manager(struct btrfs_fs_info *fs_info)
        if (!zwsm)
                return -ENOMEM;
        zstd_calc_ws_mem_sizes();
-       zwsm->ops = &btrfs_zstd_compress;
        spin_lock_init(&zwsm->lock);
        init_waitqueue_head(&zwsm->wait);
        timer_setup(&zwsm->timer, zstd_reclaim_timer_fn, 0);
@@ -727,7 +725,7 @@ finish:
        return ret;
 }
 
-const struct btrfs_compress_op btrfs_zstd_compress = {
+const struct btrfs_compress_levels btrfs_zstd_compress = {
        .min_level      = ZSTD_BTRFS_MIN_LEVEL,
        .max_level      = ZSTD_BTRFS_MAX_LEVEL,
        .default_level  = ZSTD_BTRFS_DEFAULT_LEVEL,