From: Dennis Zhou <dennis@kernel.org>
To: David Sterba <dsterba@suse.com>,
Josef Bacik <josef@toxicpanda.com>, Chris Mason <clm@fb.com>,
Omar Sandoval <osandov@osandov.com>,
Nick Terrell <terrelln@fb.com>
Cc: kernel-team@fb.com, linux-btrfs@vger.kernel.org,
linux-kernel@vger.kernel.org, Dennis Zhou <dennis@kernel.org>
Subject: [PATCH 01/11] btrfs: add macros for compression type and level
Date: Mon, 28 Jan 2019 16:24:27 -0500 [thread overview]
Message-ID: <20190128212437.11597-2-dennis@kernel.org> (raw)
In-Reply-To: <20190128212437.11597-1-dennis@kernel.org>
It is very easy to miss places that rely on a certain bitshifting for
decyphering the type_level overloading. Make macros handle this instead.
Signed-off-by: Dennis Zhou <dennis@kernel.org>
---
fs/btrfs/compression.c | 2 +-
fs/btrfs/compression.h | 3 +++
fs/btrfs/zlib.c | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 548057630b69..586f95ac0aea 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -1036,9 +1036,9 @@ int btrfs_compress_pages(unsigned int type_level, struct address_space *mapping,
unsigned long *total_in,
unsigned long *total_out)
{
+ int type = BTRFS_COMPRESS_TYPE(type_level);
struct list_head *workspace;
int ret;
- int type = type_level & 0xF;
workspace = find_workspace(type);
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index ddda9b80bf20..69a9197dadc3 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -25,6 +25,9 @@
#define BTRFS_ZLIB_DEFAULT_LEVEL 3
+#define BTRFS_COMPRESS_TYPE(type_level) (type_level & 0xF)
+#define BTRFS_COMPRESS_LEVEL(type_level) ((type_level & 0xF0) >> 4)
+
struct compressed_bio {
/* number of bios pending for this compressed extent */
refcount_t pending_bios;
diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index 970ff3e35bb3..1480b3eee306 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -393,7 +393,7 @@ static int zlib_decompress(struct list_head *ws, unsigned char *data_in,
static void zlib_set_level(struct list_head *ws, unsigned int type)
{
struct workspace *workspace = list_entry(ws, struct workspace, list);
- unsigned level = (type & 0xF0) >> 4;
+ unsigned int level = BTRFS_COMPRESS_LEVEL(type);
if (level > 9)
level = 9;
--
2.17.1
next prev parent reply other threads:[~2019-01-28 21:24 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-28 21:24 [PATCH 00/11] btrfs: add zstd compression level support Dennis Zhou
2019-01-28 21:24 ` Dennis Zhou [this message]
2019-01-29 7:26 ` [PATCH 01/11] btrfs: add macros for compression type and level Nikolay Borisov
2019-01-29 17:57 ` Josef Bacik
2019-01-29 22:30 ` Omar Sandoval
2019-01-31 16:00 ` David Sterba
2019-01-31 16:17 ` Dennis Zhou
2019-01-28 21:24 ` [PATCH 02/11] btrfs: rename workspaces_list to workspace_manager Dennis Zhou
2019-01-29 7:27 ` Nikolay Borisov
2019-01-29 17:58 ` Josef Bacik
2019-01-28 21:24 ` [PATCH 03/11] btrfs: manage heuristic workspace as index 0 Dennis Zhou
2019-01-29 7:53 ` Nikolay Borisov
2019-01-29 22:43 ` Dennis Zhou
2019-01-29 18:02 ` Josef Bacik
2019-01-31 16:10 ` David Sterba
2019-01-28 21:24 ` [PATCH 04/11] btrfs: unify compression ops with workspace_manager Dennis Zhou
2019-01-29 7:54 ` Nikolay Borisov
2019-01-29 18:03 ` Josef Bacik
2019-01-28 21:24 ` [PATCH 05/11] btrfs: add helper methods for workspace manager init and cleanup Dennis Zhou
2019-01-29 7:58 ` Nikolay Borisov
2019-01-29 18:04 ` Josef Bacik
2019-01-28 21:24 ` [PATCH 06/11] btrfs: add compression interface in (get/put)_workspace() Dennis Zhou
2019-01-29 18:06 ` Josef Bacik
2019-01-28 21:24 ` [PATCH 07/11] btrfs: move to fn pointers for get/put workspaces Dennis Zhou
2019-01-29 8:22 ` Nikolay Borisov
2019-01-29 23:35 ` Dennis Zhou
2019-01-29 18:17 ` Josef Bacik
2019-01-29 18:44 ` Josef Bacik
2019-01-28 21:24 ` [PATCH 08/11] btrfs: plumb level through the compression interface Dennis Zhou
2019-01-29 8:08 ` Nikolay Borisov
2019-01-29 18:17 ` Josef Bacik
2019-01-28 21:24 ` [PATCH 09/11] btrfs: change set_level() to bound the level passed in Dennis Zhou
2019-01-29 8:14 ` Nikolay Borisov
2019-01-30 22:06 ` Dennis Zhou
2019-01-28 21:24 ` [PATCH 10/11] btrfs: zstd use the passed through level instead of default Dennis Zhou
2019-01-29 8:15 ` Nikolay Borisov
2019-01-28 21:24 ` [PATCH 11/11] btrfs: add zstd compression level support Dennis Zhou
2019-01-29 7:25 ` Nikolay Borisov
2019-01-29 22:50 ` Dennis Zhou
2019-01-31 18:10 ` David Sterba
2019-01-31 18:13 ` David Sterba
2019-01-29 17:18 ` [PATCH 00/11] " David Sterba
2019-01-29 21:12 ` Nick Terrell
2019-01-30 17:40 ` Dennis Zhou
2019-01-31 14:04 ` David Sterba
2019-01-31 15:56 ` Dennis Zhou
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=20190128212437.11597-2-dennis@kernel.org \
--to=dennis@kernel.org \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=osandov@osandov.com \
--cc=terrelln@fb.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).