btrfs: compression: pass type to btrfs_get_workspace
We can infer the workspace_manager from type and the type will be used in the following patch to call a common helper for alloc_workspace. Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
bd3a5287cc
commit
5907a9bb13
3 changed files with 7 additions and 10 deletions
|
@ -972,9 +972,9 @@ static void btrfs_cleanup_workspace_manager(int type)
|
||||||
* Preallocation makes a forward progress guarantees and we do not return
|
* Preallocation makes a forward progress guarantees and we do not return
|
||||||
* errors.
|
* errors.
|
||||||
*/
|
*/
|
||||||
struct list_head *btrfs_get_workspace(struct workspace_manager *wsm,
|
struct list_head *btrfs_get_workspace(int type, unsigned int level)
|
||||||
unsigned int level)
|
|
||||||
{
|
{
|
||||||
|
struct workspace_manager *wsm;
|
||||||
struct list_head *workspace;
|
struct list_head *workspace;
|
||||||
int cpus = num_online_cpus();
|
int cpus = num_online_cpus();
|
||||||
unsigned nofs_flag;
|
unsigned nofs_flag;
|
||||||
|
@ -984,6 +984,7 @@ struct list_head *btrfs_get_workspace(struct workspace_manager *wsm,
|
||||||
wait_queue_head_t *ws_wait;
|
wait_queue_head_t *ws_wait;
|
||||||
int *free_ws;
|
int *free_ws;
|
||||||
|
|
||||||
|
wsm = btrfs_compress_op[type]->workspace_manager;
|
||||||
idle_ws = &wsm->idle_ws;
|
idle_ws = &wsm->idle_ws;
|
||||||
ws_lock = &wsm->ws_lock;
|
ws_lock = &wsm->ws_lock;
|
||||||
total_ws = &wsm->total_ws;
|
total_ws = &wsm->total_ws;
|
||||||
|
@ -1052,13 +1053,10 @@ again:
|
||||||
|
|
||||||
static struct list_head *get_workspace(int type, int level)
|
static struct list_head *get_workspace(int type, int level)
|
||||||
{
|
{
|
||||||
struct workspace_manager *wsm;
|
|
||||||
|
|
||||||
wsm = btrfs_compress_op[type]->workspace_manager;
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BTRFS_COMPRESS_NONE: return btrfs_get_workspace(wsm, level);
|
case BTRFS_COMPRESS_NONE: return btrfs_get_workspace(type, level);
|
||||||
case BTRFS_COMPRESS_ZLIB: return zlib_get_workspace(level);
|
case BTRFS_COMPRESS_ZLIB: return zlib_get_workspace(level);
|
||||||
case BTRFS_COMPRESS_LZO: return btrfs_get_workspace(wsm, level);
|
case BTRFS_COMPRESS_LZO: return btrfs_get_workspace(type, level);
|
||||||
case BTRFS_COMPRESS_ZSTD: return zstd_get_workspace(level);
|
case BTRFS_COMPRESS_ZSTD: return zstd_get_workspace(level);
|
||||||
default:
|
default:
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -120,8 +120,7 @@ struct workspace_manager {
|
||||||
wait_queue_head_t ws_wait;
|
wait_queue_head_t ws_wait;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct list_head *btrfs_get_workspace(struct workspace_manager *wsm,
|
struct list_head *btrfs_get_workspace(int type, unsigned int level);
|
||||||
unsigned int level);
|
|
||||||
void btrfs_put_workspace(struct workspace_manager *wsm, struct list_head *ws);
|
void btrfs_put_workspace(struct workspace_manager *wsm, struct list_head *ws);
|
||||||
|
|
||||||
struct btrfs_compress_op {
|
struct btrfs_compress_op {
|
||||||
|
|
|
@ -31,7 +31,7 @@ static struct workspace_manager wsm;
|
||||||
|
|
||||||
struct list_head *zlib_get_workspace(unsigned int level)
|
struct list_head *zlib_get_workspace(unsigned int level)
|
||||||
{
|
{
|
||||||
struct list_head *ws = btrfs_get_workspace(&wsm, level);
|
struct list_head *ws = btrfs_get_workspace(BTRFS_COMPRESS_ZLIB, level);
|
||||||
struct workspace *workspace = list_entry(ws, struct workspace, list);
|
struct workspace *workspace = list_entry(ws, struct workspace, list);
|
||||||
|
|
||||||
workspace->level = level;
|
workspace->level = level;
|
||||||
|
|
Loading…
Reference in a new issue