All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 10/15] btrfs: compression: inline put_workspace
Date: Mon, 14 Oct 2019 14:22:45 +0200	[thread overview]
Message-ID: <243ec8e3ed32c12e7dca0bdafb9934f74ee1b5b6.1571054758.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1571054758.git.dsterba@suse.com>

Similar to get_workspace, majority of the callbacks is trivial, we don't
gain anything by the indirection, so replace them by a switch function.
Trivial callback implementations use the helper.

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

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index de9b06574f42..9b9638557e19 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -39,7 +39,6 @@ int zlib_decompress(struct list_head *ws, unsigned char *data_in,
 struct list_head *zlib_alloc_workspace(unsigned int level);
 void zlib_free_workspace(struct list_head *ws);
 struct list_head *zlib_get_workspace(unsigned int level);
-void zlib_put_workspace(struct list_head *ws);
 
 int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
 		u64 start, struct page **pages, unsigned long *out_pages,
@@ -50,7 +49,6 @@ int lzo_decompress(struct list_head *ws, unsigned char *data_in,
 		size_t destlen);
 struct list_head *lzo_alloc_workspace(unsigned int level);
 void lzo_free_workspace(struct list_head *ws);
-void lzo_put_workspace(struct list_head *ws);
 
 int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
 		u64 start, struct page **pages, unsigned long *out_pages,
@@ -873,11 +871,6 @@ struct heuristic_ws {
 
 static struct workspace_manager heuristic_wsm;
 
-static void heuristic_put_workspace(struct list_head *ws)
-{
-	btrfs_put_workspace(&heuristic_wsm, ws);
-}
-
 static void free_heuristic_ws(struct list_head *ws)
 {
 	struct heuristic_ws *workspace;
@@ -919,7 +912,6 @@ static struct list_head *alloc_heuristic_ws(unsigned int level)
 
 const struct btrfs_compress_op btrfs_heuristic_compress = {
 	.workspace_manager = &heuristic_wsm,
-	.put_workspace = heuristic_put_workspace,
 	.alloc_workspace = alloc_heuristic_ws,
 	.free_workspace = free_heuristic_ws,
 };
@@ -1112,7 +1104,21 @@ void btrfs_put_workspace(struct workspace_manager *wsm, struct list_head *ws)
 
 static void put_workspace(int type, struct list_head *ws)
 {
-	return btrfs_compress_op[type]->put_workspace(ws);
+	struct workspace_manager *wsm;
+
+	wsm = btrfs_compress_op[type]->workspace_manager;
+	switch (type) {
+	case BTRFS_COMPRESS_NONE: return btrfs_put_workspace(wsm, ws);
+	case BTRFS_COMPRESS_ZLIB: return btrfs_put_workspace(wsm, ws);
+	case BTRFS_COMPRESS_LZO:  return btrfs_put_workspace(wsm, ws);
+	case BTRFS_COMPRESS_ZSTD: return zstd_put_workspace(ws);
+	default:
+		/*
+		 * This can't happen, the type is validated several times
+		 * before we get here.
+		 */
+		BUG();
+	}
 }
 
 /*
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index df7274c1a5d8..b8ed97fc6db4 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -125,8 +125,6 @@ struct list_head *btrfs_get_workspace(struct workspace_manager *wsm,
 void btrfs_put_workspace(struct workspace_manager *wsm, struct list_head *ws);
 
 struct btrfs_compress_op {
-	void (*put_workspace)(struct list_head *ws);
-
 	struct list_head *(*alloc_workspace)(unsigned int level);
 
 	void (*free_workspace)(struct list_head *workspace);
diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index 821e5c137971..bbf917c5ff2d 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -63,11 +63,6 @@ struct workspace {
 
 static struct workspace_manager wsm;
 
-void lzo_put_workspace(struct list_head *ws)
-{
-	btrfs_put_workspace(&wsm, ws);
-}
-
 void lzo_free_workspace(struct list_head *ws)
 {
 	struct workspace *workspace = list_entry(ws, struct workspace, list);
@@ -489,7 +484,6 @@ int lzo_decompress(struct list_head *ws, unsigned char *data_in,
 
 const struct btrfs_compress_op btrfs_lzo_compress = {
 	.workspace_manager	= &wsm,
-	.put_workspace		= lzo_put_workspace,
 	.alloc_workspace	= lzo_alloc_workspace,
 	.free_workspace		= lzo_free_workspace,
 	.max_level		= 1,
diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index 7caa468efe94..610765640c8e 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -39,11 +39,6 @@ struct list_head *zlib_get_workspace(unsigned int level)
 	return ws;
 }
 
-void zlib_put_workspace(struct list_head *ws)
-{
-	btrfs_put_workspace(&wsm, ws);
-}
-
 void zlib_free_workspace(struct list_head *ws)
 {
 	struct workspace *workspace = list_entry(ws, struct workspace, list);
@@ -405,7 +400,6 @@ int zlib_decompress(struct list_head *ws, unsigned char *data_in,
 
 const struct btrfs_compress_op btrfs_zlib_compress = {
 	.workspace_manager	= &wsm,
-	.put_workspace		= zlib_put_workspace,
 	.alloc_workspace	= zlib_alloc_workspace,
 	.free_workspace		= zlib_free_workspace,
 	.max_level		= 9,
diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c
index c9fe0e2bd107..a346f1187fae 100644
--- a/fs/btrfs/zstd.c
+++ b/fs/btrfs/zstd.c
@@ -708,7 +708,6 @@ 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,
-	.put_workspace = zstd_put_workspace,
 	.alloc_workspace = zstd_alloc_workspace,
 	.free_workspace = zstd_free_workspace,
 	.max_level	= ZSTD_BTRFS_MAX_LEVEL,
-- 
2.23.0


  parent reply	other threads:[~2019-10-14 12:22 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14 12:22 [PATCH 00/15] Remove callback indirections in compression code David Sterba
2019-10-14 12:22 ` [PATCH 01/15] btrfs: export compression and decompression callbacks David Sterba
2019-10-17  9:39   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 02/15] btrfs: switch compression callbacks to direct calls David Sterba
2019-10-17  9:42   ` Johannes Thumshirn
2019-10-17 11:24     ` David Sterba
2019-10-14 12:22 ` [PATCH 03/15] btrfs: compression: attach workspace manager to the ops David Sterba
2019-10-17 11:08   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 04/15] btrfs: compression: let workspace manager init take only the type David Sterba
2019-10-17 11:03   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 05/15] btrfs: compression: inline init_workspace_manager David Sterba
2019-10-17 11:06   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 06/15] btrfs: compression: let workspace manager cleanup take only the type David Sterba
2019-10-17 11:10   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 07/15] btrfs: compression: inline cleanup_workspace_manager David Sterba
2019-10-17 11:31   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 08/15] btrfs: compression: export alloc/free/get/put callbacks of all algos David Sterba
2019-10-17 11:44   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 09/15] btrfs: compression: inline get_workspace David Sterba
2019-10-17 11:46   ` Johannes Thumshirn
2019-10-14 12:22 ` David Sterba [this message]
2019-10-17 11:49   ` [PATCH 10/15] btrfs: compression: inline put_workspace Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 11/15] btrfs: compression: pass type to btrfs_get_workspace David Sterba
2019-10-17 11:53   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 12/15] btrfs: compression: inline alloc_workspace David Sterba
2019-10-17 11:56   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 13/15] btrfs: compression: pass type to btrfs_put_workspace David Sterba
2019-10-17 11:57   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 14/15] btrfs: compression: inline free_workspace David Sterba
2019-10-17 11:58   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 15/15] btrfs: compression: remove ops pointer from workspace_manager David Sterba
2019-10-17 11:59   ` Johannes Thumshirn
2019-10-17 15:02 ` [PATCH 00/15] Remove callback indirections in compression code Nikolay Borisov
2019-10-17 18:19 ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=243ec8e3ed32c12e7dca0bdafb9934f74ee1b5b6.1571054758.git.dsterba@suse.com \
    --to=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.