[03/15] btrfs: compression: attach workspace manager to the ops
diff mbox series

Message ID cf0b8745c5aada29f9431a66777f1af5bb4d382f.1571054758.git.dsterba@suse.com
State New
Headers show
Series
  • Remove callback indirections in compression code
Related show

Commit Message

David Sterba Oct. 14, 2019, 12:22 p.m. UTC
There's a lot of indirection when the generic code calls into
algo-specific callbacks to reach the private workspace manager structure
and back to the generic code.

To simplify that, export the workspace manager for heuristic, LZO and
ZLIB, while ZSTD is going to use it's own manager.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/compression.c | 1 +
 fs/btrfs/compression.h | 1 +
 fs/btrfs/lzo.c         | 1 +
 fs/btrfs/zlib.c        | 1 +
 fs/btrfs/zstd.c        | 2 ++
 5 files changed, 6 insertions(+)

Comments

Johannes Thumshirn Oct. 17, 2019, 11:08 a.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>

Patch
diff mbox series

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 87bac8f73a99..e650125b1d2b 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -920,6 +920,7 @@  static struct list_head *alloc_heuristic_ws(unsigned int level)
 }
 
 const struct btrfs_compress_op btrfs_heuristic_compress = {
+	.workspace_manager = &heuristic_wsm,
 	.init_workspace_manager = heuristic_init_workspace_manager,
 	.cleanup_workspace_manager = heuristic_cleanup_workspace_manager,
 	.get_workspace = heuristic_get_workspace,
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index 7db14d3166b5..7091eae063e5 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -140,6 +140,7 @@  struct btrfs_compress_op {
 
 	void (*free_workspace)(struct list_head *workspace);
 
+	struct workspace_manager *workspace_manager;
 	/* Maximum level supported by the compression algorithm */
 	unsigned int max_level;
 	unsigned int default_level;
diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index 9417944ec829..aff105cc80e7 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -503,6 +503,7 @@  int lzo_decompress(struct list_head *ws, unsigned char *data_in,
 }
 
 const struct btrfs_compress_op btrfs_lzo_compress = {
+	.workspace_manager	= &wsm,
 	.init_workspace_manager	= lzo_init_workspace_manager,
 	.cleanup_workspace_manager = lzo_cleanup_workspace_manager,
 	.get_workspace		= lzo_get_workspace,
diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index 8bb6f19ab369..a5e8f0207473 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -414,6 +414,7 @@  int zlib_decompress(struct list_head *ws, unsigned char *data_in,
 }
 
 const struct btrfs_compress_op btrfs_zlib_compress = {
+	.workspace_manager	= &wsm,
 	.init_workspace_manager	= zlib_init_workspace_manager,
 	.cleanup_workspace_manager = zlib_cleanup_workspace_manager,
 	.get_workspace		= zlib_get_workspace,
diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c
index 5f17c741d167..4791e89e43e3 100644
--- a/fs/btrfs/zstd.c
+++ b/fs/btrfs/zstd.c
@@ -707,6 +707,8 @@  int zstd_decompress(struct list_head *ws, unsigned char *data_in,
 }
 
 const struct btrfs_compress_op btrfs_zstd_compress = {
+	/* ZSTD uses own workspace manager */
+	.workspace_manager = NULL,
 	.init_workspace_manager = zstd_init_workspace_manager,
 	.cleanup_workspace_manager = zstd_cleanup_workspace_manager,
 	.get_workspace = zstd_get_workspace,