Skip to content

Commit f82855e

Browse files
adam900710kdave
authored andcommitted
btrfs: rename btrfs_compress_op to btrfs_compress_levels
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 <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 310712c commit f82855e

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

fs/btrfs/compression.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,9 @@ static struct list_head *alloc_heuristic_ws(struct btrfs_fs_info *fs_info)
727727
return ERR_PTR(-ENOMEM);
728728
}
729729

730-
const struct btrfs_compress_op btrfs_heuristic_compress = { 0 };
730+
const struct btrfs_compress_levels btrfs_heuristic_compress = { 0 };
731731

732-
static const struct btrfs_compress_op * const btrfs_compress_op[] = {
732+
static const struct btrfs_compress_levels * const btrfs_compress_levels[] = {
733733
/* The heuristic is represented as compression type 0 */
734734
&btrfs_heuristic_compress,
735735
&btrfs_zlib_compress,
@@ -981,12 +981,12 @@ static void put_workspace(struct btrfs_fs_info *fs_info, int type, struct list_h
981981
*/
982982
static int btrfs_compress_set_level(unsigned int type, int level)
983983
{
984-
const struct btrfs_compress_op *ops = btrfs_compress_op[type];
984+
const struct btrfs_compress_levels *levels = btrfs_compress_levels[type];
985985

986986
if (level == 0)
987-
level = ops->default_level;
987+
level = levels->default_level;
988988
else
989-
level = clamp(level, ops->min_level, ops->max_level);
989+
level = clamp(level, levels->min_level, levels->max_level);
990990

991991
return level;
992992
}
@@ -996,9 +996,9 @@ static int btrfs_compress_set_level(unsigned int type, int level)
996996
*/
997997
bool btrfs_compress_level_valid(unsigned int type, int level)
998998
{
999-
const struct btrfs_compress_op *ops = btrfs_compress_op[type];
999+
const struct btrfs_compress_levels *levels = btrfs_compress_levels[type];
10001000

1001-
return ops->min_level <= level && level <= ops->max_level;
1001+
return levels->min_level <= level && level <= levels->max_level;
10021002
}
10031003

10041004
/* Wrapper around find_get_page(), with extra error message. */

fs/btrfs/compression.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ struct workspace_manager {
129129
struct list_head *btrfs_get_workspace(struct btrfs_fs_info *fs_info, int type, int level);
130130
void btrfs_put_workspace(struct btrfs_fs_info *fs_info, int type, struct list_head *ws);
131131

132-
struct btrfs_compress_op {
133-
struct workspace_manager *workspace_manager;
132+
struct btrfs_compress_levels {
134133
/* Maximum level supported by the compression algorithm */
135134
int min_level;
136135
int max_level;
@@ -140,10 +139,10 @@ struct btrfs_compress_op {
140139
/* The heuristic workspaces are managed via the 0th workspace manager */
141140
#define BTRFS_NR_WORKSPACE_MANAGERS BTRFS_NR_COMPRESS_TYPES
142141

143-
extern const struct btrfs_compress_op btrfs_heuristic_compress;
144-
extern const struct btrfs_compress_op btrfs_zlib_compress;
145-
extern const struct btrfs_compress_op btrfs_lzo_compress;
146-
extern const struct btrfs_compress_op btrfs_zstd_compress;
142+
extern const struct btrfs_compress_levels btrfs_heuristic_compress;
143+
extern const struct btrfs_compress_levels btrfs_zlib_compress;
144+
extern const struct btrfs_compress_levels btrfs_lzo_compress;
145+
extern const struct btrfs_compress_levels btrfs_zstd_compress;
147146

148147
const char* btrfs_compress_type2str(enum btrfs_compression_type type);
149148
bool btrfs_compress_is_valid_type(const char *str, size_t len);

fs/btrfs/lzo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ int lzo_decompress(struct list_head *ws, const u8 *data_in,
486486
return ret;
487487
}
488488

489-
const struct btrfs_compress_op btrfs_lzo_compress = {
489+
const struct btrfs_compress_levels btrfs_lzo_compress = {
490490
.max_level = 1,
491491
.default_level = 1,
492492
};

fs/btrfs/zlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ int zlib_decompress(struct list_head *ws, const u8 *data_in,
480480
return ret;
481481
}
482482

483-
const struct btrfs_compress_op btrfs_zlib_compress = {
483+
const struct btrfs_compress_levels btrfs_zlib_compress = {
484484
.min_level = 1,
485485
.max_level = 9,
486486
.default_level = BTRFS_ZLIB_DEFAULT_LEVEL,

fs/btrfs/zstd.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ struct workspace {
7777
*/
7878

7979
struct zstd_workspace_manager {
80-
const struct btrfs_compress_op *ops;
8180
spinlock_t lock;
8281
struct list_head lru_list;
8382
struct list_head idle_ws[ZSTD_BTRFS_MAX_LEVEL];
@@ -190,7 +189,6 @@ int zstd_alloc_workspace_manager(struct btrfs_fs_info *fs_info)
190189
if (!zwsm)
191190
return -ENOMEM;
192191
zstd_calc_ws_mem_sizes();
193-
zwsm->ops = &btrfs_zstd_compress;
194192
spin_lock_init(&zwsm->lock);
195193
init_waitqueue_head(&zwsm->wait);
196194
timer_setup(&zwsm->timer, zstd_reclaim_timer_fn, 0);
@@ -727,7 +725,7 @@ int zstd_decompress(struct list_head *ws, const u8 *data_in,
727725
return ret;
728726
}
729727

730-
const struct btrfs_compress_op btrfs_zstd_compress = {
728+
const struct btrfs_compress_levels btrfs_zstd_compress = {
731729
.min_level = ZSTD_BTRFS_MIN_LEVEL,
732730
.max_level = ZSTD_BTRFS_MAX_LEVEL,
733731
.default_level = ZSTD_BTRFS_DEFAULT_LEVEL,

0 commit comments

Comments
 (0)