From: Yangtao Li <frank.li@vivo.com>
To: jaegeuk@kernel.org, chao@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Yangtao Li <frank.li@vivo.com>
Subject: [PATCH 1/4] f2fs: fix to check lz4hc compression when CONFIG_F2FS_FS_LZ4HC is not enabled
Date: Tue, 24 Jan 2023 23:33:43 +0800 [thread overview]
Message-ID: <20230124153346.74881-1-frank.li@vivo.com> (raw)
f2fs supports lz4 compression algorithm and lz4hc compression algorithm,
which the level parameter needs to be passed in. When CONFIG_F2FS_FS_LZ4HC
is not enabled, even if there is no problem with the level parameter, add
the level parameter to the lz4 algorithm will cause the mount to fail.
Let's change it to be the same as other compression algorithms. When the
kernel does not enable the algorithm, ignore this parameter and print msg.
Fixes: 3fde13f817e2 ("f2fs: compress: support compress level")
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
fs/f2fs/super.c | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index d8a65645ee48..ad5df4d5c39a 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -588,19 +588,11 @@ static int f2fs_test_compress_extension(struct f2fs_sb_info *sbi)
return 0;
}
-#ifdef CONFIG_F2FS_FS_LZ4
+#ifdef CONFIG_F2FS_FS_LZ4HC
static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str)
{
-#ifdef CONFIG_F2FS_FS_LZ4HC
unsigned int level;
-#endif
- if (strlen(str) == 3) {
- F2FS_OPTION(sbi).compress_level = 0;
- return 0;
- }
-
-#ifdef CONFIG_F2FS_FS_LZ4HC
str += 3;
if (str[0] != ':') {
@@ -617,10 +609,6 @@ static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str)
F2FS_OPTION(sbi).compress_level = level;
return 0;
-#else
- f2fs_info(sbi, "kernel doesn't support lz4hc compression");
- return -EINVAL;
-#endif
}
#endif
@@ -1085,10 +1073,19 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
#endif
} else if (!strncmp(name, "lz4", 3)) {
#ifdef CONFIG_F2FS_FS_LZ4
- ret = f2fs_set_lz4hc_level(sbi, name);
- if (ret) {
- kfree(name);
- return -EINVAL;
+ if (strlen(name) == 3) {
+ F2FS_OPTION(sbi).compress_level = 0;
+ } else {
+#ifdef CONFIG_F2FS_FS_LZ4HC
+ ret = f2fs_set_lz4hc_level(sbi, name);
+ if (ret) {
+ kfree(name);
+ return -EINVAL;
+ }
+#else
+ f2fs_info(sbi, "kernel doesn't support lz4hc compression");
+ break;
+#endif
}
F2FS_OPTION(sbi).compress_algorithm =
COMPRESS_LZ4;
--
2.25.1
next reply other threads:[~2023-01-24 15:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-24 15:33 Yangtao Li [this message]
2023-01-24 15:33 ` [PATCH 2/4] f2fs: introduce f2fs_set_compress_level() Yangtao Li
2023-01-24 15:33 ` [PATCH 3/4] f2fs: set default compress option only when sb_has_compression Yangtao Li
2023-01-24 15:33 ` [PATCH 4/4] f2fs: merge lz4hc_compress_pages() to lz4_compress_pages() Yangtao Li
2023-01-29 10:21 ` [PATCH 1/4] f2fs: fix to check lz4hc compression when CONFIG_F2FS_FS_LZ4HC is not enabled Chao Yu
2023-01-29 18:12 ` Eric Biggers
2023-04-05 16:20 ` [f2fs-dev] " patchwork-bot+f2fs
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=20230124153346.74881-1-frank.li@vivo.com \
--to=frank.li@vivo.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@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 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).