Skip to content

Commit a1bc945

Browse files
adam900710kdave
authored andcommitted
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 <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 52691d3 commit a1bc945

File tree

5 files changed

+1
-111
lines changed

5 files changed

+1
-111
lines changed

fs/btrfs/compression.c

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,6 @@ struct heuristic_ws {
688688
struct list_head list;
689689
};
690690

691-
static struct workspace_manager heuristic_wsm;
692-
693691
static void free_heuristic_ws(struct list_head *ws)
694692
{
695693
struct heuristic_ws *workspace;
@@ -729,9 +727,7 @@ static struct list_head *alloc_heuristic_ws(struct btrfs_fs_info *fs_info)
729727
return ERR_PTR(-ENOMEM);
730728
}
731729

732-
const struct btrfs_compress_op btrfs_heuristic_compress = {
733-
.workspace_manager = &heuristic_wsm,
734-
};
730+
const struct btrfs_compress_op btrfs_heuristic_compress = { 0 };
735731

736732
static const struct btrfs_compress_op * const btrfs_compress_op[] = {
737733
/* The heuristic is represented as compression type 0 */
@@ -807,32 +803,6 @@ static int alloc_workspace_manager(struct btrfs_fs_info *fs_info,
807803
return 0;
808804
}
809805

810-
static void btrfs_init_workspace_manager(struct btrfs_fs_info *fs_info, int type)
811-
{
812-
struct workspace_manager *wsm;
813-
struct list_head *workspace;
814-
815-
wsm = btrfs_compress_op[type]->workspace_manager;
816-
INIT_LIST_HEAD(&wsm->idle_ws);
817-
spin_lock_init(&wsm->ws_lock);
818-
atomic_set(&wsm->total_ws, 0);
819-
init_waitqueue_head(&wsm->ws_wait);
820-
821-
/*
822-
* Preallocate one workspace for each compression type so we can
823-
* guarantee forward progress in the worst case
824-
*/
825-
workspace = alloc_workspace(fs_info, type, 0);
826-
if (IS_ERR(workspace)) {
827-
btrfs_warn(fs_info,
828-
"cannot preallocate compression workspace, will try later");
829-
} else {
830-
atomic_set(&wsm->total_ws, 1);
831-
wsm->free_ws = 1;
832-
list_add(workspace, &wsm->idle_ws);
833-
}
834-
}
835-
836806
static void free_workspace_manager(struct btrfs_fs_info *fs_info,
837807
enum btrfs_compression_type type)
838808
{
@@ -853,20 +823,6 @@ static void free_workspace_manager(struct btrfs_fs_info *fs_info,
853823
kfree(gwsm);
854824
}
855825

856-
static void btrfs_cleanup_workspace_manager(int type)
857-
{
858-
struct workspace_manager *wsman;
859-
struct list_head *ws;
860-
861-
wsman = btrfs_compress_op[type]->workspace_manager;
862-
while (!list_empty(&wsman->idle_ws)) {
863-
ws = wsman->idle_ws.next;
864-
list_del(ws);
865-
free_workspace(type, ws);
866-
atomic_dec(&wsman->total_ws);
867-
}
868-
}
869-
870826
/*
871827
* This finds an available workspace or allocates a new one.
872828
* 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)
11921148
if (!compr_pool.shrinker)
11931149
return -ENOMEM;
11941150

1195-
btrfs_init_workspace_manager(NULL, BTRFS_COMPRESS_NONE);
1196-
btrfs_init_workspace_manager(NULL, BTRFS_COMPRESS_ZLIB);
1197-
btrfs_init_workspace_manager(NULL, BTRFS_COMPRESS_LZO);
1198-
zstd_init_workspace_manager(NULL);
1199-
12001151
spin_lock_init(&compr_pool.lock);
12011152
INIT_LIST_HEAD(&compr_pool.list);
12021153
compr_pool.count = 0;
@@ -1217,10 +1168,6 @@ void __cold btrfs_exit_compress(void)
12171168
btrfs_compr_pool_scan(NULL, NULL);
12181169
shrinker_free(compr_pool.shrinker);
12191170

1220-
btrfs_cleanup_workspace_manager(BTRFS_COMPRESS_NONE);
1221-
btrfs_cleanup_workspace_manager(BTRFS_COMPRESS_ZLIB);
1222-
btrfs_cleanup_workspace_manager(BTRFS_COMPRESS_LZO);
1223-
zstd_cleanup_workspace_manager();
12241171
bioset_exit(&btrfs_compressed_bioset);
12251172
}
12261173

fs/btrfs/compression.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ int zstd_decompress(struct list_head *ws, const u8 *data_in,
183183
size_t destlen);
184184
int zstd_alloc_workspace_manager(struct btrfs_fs_info *fs_info);
185185
void zstd_free_workspace_manager(struct btrfs_fs_info *fs_info);
186-
void zstd_init_workspace_manager(struct btrfs_fs_info *fs_info);
187-
void zstd_cleanup_workspace_manager(void);
188186
struct list_head *zstd_alloc_workspace(struct btrfs_fs_info *fs_info, int level);
189187
void zstd_free_workspace(struct list_head *ws);
190188
struct list_head *zstd_get_workspace(struct btrfs_fs_info *fs_info, int level);

fs/btrfs/lzo.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ struct workspace {
6868
struct list_head list;
6969
};
7070

71-
static struct workspace_manager wsm;
72-
7371
void lzo_free_workspace(struct list_head *ws)
7472
{
7573
struct workspace *workspace = list_entry(ws, struct workspace, list);
@@ -489,7 +487,6 @@ int lzo_decompress(struct list_head *ws, const u8 *data_in,
489487
}
490488

491489
const struct btrfs_compress_op btrfs_lzo_compress = {
492-
.workspace_manager = &wsm,
493490
.max_level = 1,
494491
.default_level = 1,
495492
};

fs/btrfs/zlib.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ struct workspace {
3434
int level;
3535
};
3636

37-
static struct workspace_manager wsm;
38-
3937
struct list_head *zlib_get_workspace(struct btrfs_fs_info *fs_info, unsigned int level)
4038
{
4139
struct list_head *ws = btrfs_get_workspace(fs_info, BTRFS_COMPRESS_ZLIB, level);
@@ -483,7 +481,6 @@ int zlib_decompress(struct list_head *ws, const u8 *data_in,
483481
}
484482

485483
const struct btrfs_compress_op btrfs_zlib_compress = {
486-
.workspace_manager = &wsm,
487484
.min_level = 1,
488485
.max_level = 9,
489486
.default_level = BTRFS_ZLIB_DEFAULT_LEVEL,

fs/btrfs/zstd.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ struct zstd_workspace_manager {
8686
struct timer_list timer;
8787
};
8888

89-
static struct zstd_workspace_manager wsm;
90-
9189
static size_t zstd_ws_mem_sizes[ZSTD_BTRFS_MAX_LEVEL];
9290

9391
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)
212210
return 0;
213211
}
214212

215-
void zstd_init_workspace_manager(struct btrfs_fs_info *fs_info)
216-
{
217-
struct list_head *ws;
218-
int i;
219-
220-
zstd_calc_ws_mem_sizes();
221-
222-
wsm.ops = &btrfs_zstd_compress;
223-
spin_lock_init(&wsm.lock);
224-
init_waitqueue_head(&wsm.wait);
225-
timer_setup(&wsm.timer, zstd_reclaim_timer_fn, 0);
226-
227-
INIT_LIST_HEAD(&wsm.lru_list);
228-
for (i = 0; i < ZSTD_BTRFS_MAX_LEVEL; i++)
229-
INIT_LIST_HEAD(&wsm.idle_ws[i]);
230-
231-
ws = zstd_alloc_workspace(fs_info, ZSTD_BTRFS_MAX_LEVEL);
232-
if (IS_ERR(ws)) {
233-
btrfs_warn(NULL, "cannot preallocate zstd compression workspace");
234-
} else {
235-
set_bit(ZSTD_BTRFS_MAX_LEVEL - 1, &wsm.active_map);
236-
list_add(ws, &wsm.idle_ws[ZSTD_BTRFS_MAX_LEVEL - 1]);
237-
}
238-
}
239-
240213
void zstd_free_workspace_manager(struct btrfs_fs_info *fs_info)
241214
{
242215
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)
260233
kfree(zwsm);
261234
}
262235

263-
void zstd_cleanup_workspace_manager(void)
264-
{
265-
struct workspace *workspace;
266-
int i;
267-
268-
spin_lock_bh(&wsm.lock);
269-
for (i = 0; i < ZSTD_BTRFS_MAX_LEVEL; i++) {
270-
while (!list_empty(&wsm.idle_ws[i])) {
271-
workspace = container_of(wsm.idle_ws[i].next,
272-
struct workspace, list);
273-
list_del(&workspace->list);
274-
list_del(&workspace->lru_list);
275-
zstd_free_workspace(&workspace->list);
276-
}
277-
}
278-
spin_unlock_bh(&wsm.lock);
279-
280-
timer_delete_sync(&wsm.timer);
281-
}
282-
283236
/*
284237
* Find workspace for given level.
285238
*
@@ -775,8 +728,6 @@ int zstd_decompress(struct list_head *ws, const u8 *data_in,
775728
}
776729

777730
const struct btrfs_compress_op btrfs_zstd_compress = {
778-
/* ZSTD uses own workspace manager */
779-
.workspace_manager = NULL,
780731
.min_level = ZSTD_BTRFS_MIN_LEVEL,
781732
.max_level = ZSTD_BTRFS_MAX_LEVEL,
782733
.default_level = ZSTD_BTRFS_DEFAULT_LEVEL,

0 commit comments

Comments
 (0)