diff options
author | Dennis Zhou <dennis@kernel.org> | 2019-02-04 15:20:03 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-02-25 14:13:32 +0100 |
commit | 92ee55303616a18135be91deff51799a5de81f9a (patch) | |
tree | 0a0ae5969e1992e5693fa6d90d30ae9c54b94b6d /fs/btrfs/lzo.c | |
parent | 929f4baf93173372a81ea27371c419c99bbc08d7 (diff) | |
download | linux-92ee55303616a18135be91deff51799a5de81f9a.tar.gz linux-92ee55303616a18135be91deff51799a5de81f9a.tar.bz2 linux-92ee55303616a18135be91deff51799a5de81f9a.zip |
btrfs: move to function pointers for get/put workspaces
The previous patch added generic helpers for get_workspace() and
put_workspace(). Now, we can migrate ownership of the workspace_manager
to be in the compression type code as the compression code itself
doesn't care beyond being able to get a workspace. The init/cleanup and
get/put methods are abstracted so each compression algorithm can decide
how they want to manage their workspaces.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Dennis Zhou <dennis@kernel.org>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/lzo.c')
-rw-r--r-- | fs/btrfs/lzo.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c index 90639140439f..f0837b2c8e94 100644 --- a/fs/btrfs/lzo.c +++ b/fs/btrfs/lzo.c @@ -61,6 +61,28 @@ struct workspace { struct list_head list; }; +static struct workspace_manager wsm; + +static void lzo_init_workspace_manager(void) +{ + btrfs_init_workspace_manager(&wsm, &btrfs_lzo_compress); +} + +static void lzo_cleanup_workspace_manager(void) +{ + btrfs_cleanup_workspace_manager(&wsm); +} + +static struct list_head *lzo_get_workspace(void) +{ + return btrfs_get_workspace(&wsm); +} + +static void lzo_put_workspace(struct list_head *ws) +{ + btrfs_put_workspace(&wsm, ws); +} + static void lzo_free_workspace(struct list_head *ws) { struct workspace *workspace = list_entry(ws, struct workspace, list); @@ -490,6 +512,10 @@ static void lzo_set_level(struct list_head *ws, unsigned int type) } const struct btrfs_compress_op btrfs_lzo_compress = { + .init_workspace_manager = lzo_init_workspace_manager, + .cleanup_workspace_manager = lzo_cleanup_workspace_manager, + .get_workspace = lzo_get_workspace, + .put_workspace = lzo_put_workspace, .alloc_workspace = lzo_alloc_workspace, .free_workspace = lzo_free_workspace, .compress_pages = lzo_compress_pages, |