Commit 00e120b5 authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: assign default compression level

Let's avoid any confusion from assigning compress_level=0 for LZ4HC and ZSTD.
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent ccf3ff2b
...@@ -317,8 +317,6 @@ static const struct f2fs_compress_ops f2fs_lz4_ops = { ...@@ -317,8 +317,6 @@ static const struct f2fs_compress_ops f2fs_lz4_ops = {
#endif #endif
#ifdef CONFIG_F2FS_FS_ZSTD #ifdef CONFIG_F2FS_FS_ZSTD
#define F2FS_ZSTD_DEFAULT_CLEVEL 1
static int zstd_init_compress_ctx(struct compress_ctx *cc) static int zstd_init_compress_ctx(struct compress_ctx *cc)
{ {
zstd_parameters params; zstd_parameters params;
...@@ -327,6 +325,7 @@ static int zstd_init_compress_ctx(struct compress_ctx *cc) ...@@ -327,6 +325,7 @@ static int zstd_init_compress_ctx(struct compress_ctx *cc)
unsigned int workspace_size; unsigned int workspace_size;
unsigned char level = F2FS_I(cc->inode)->i_compress_level; unsigned char level = F2FS_I(cc->inode)->i_compress_level;
/* Need to remain this for backward compatibility */
if (!level) if (!level)
level = F2FS_ZSTD_DEFAULT_CLEVEL; level = F2FS_ZSTD_DEFAULT_CLEVEL;
......
...@@ -1440,6 +1440,8 @@ struct compress_data { ...@@ -1440,6 +1440,8 @@ struct compress_data {
#define F2FS_COMPRESSED_PAGE_MAGIC 0xF5F2C000 #define F2FS_COMPRESSED_PAGE_MAGIC 0xF5F2C000
#define F2FS_ZSTD_DEFAULT_CLEVEL 1
#define COMPRESS_LEVEL_OFFSET 8 #define COMPRESS_LEVEL_OFFSET 8
/* compress context */ /* compress context */
......
...@@ -589,14 +589,12 @@ static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str) ...@@ -589,14 +589,12 @@ static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str)
{ {
#ifdef CONFIG_F2FS_FS_LZ4HC #ifdef CONFIG_F2FS_FS_LZ4HC
unsigned int level; unsigned int level;
#endif
if (strlen(str) == 3) { if (strlen(str) == 3) {
F2FS_OPTION(sbi).compress_level = 0; F2FS_OPTION(sbi).compress_level = LZ4HC_DEFAULT_CLEVEL;
return 0; return 0;
} }
#ifdef CONFIG_F2FS_FS_LZ4HC
str += 3; str += 3;
if (str[0] != ':') { if (str[0] != ':') {
...@@ -614,6 +612,10 @@ static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str) ...@@ -614,6 +612,10 @@ static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str)
F2FS_OPTION(sbi).compress_level = level; F2FS_OPTION(sbi).compress_level = level;
return 0; return 0;
#else #else
if (strlen(str) == 3) {
F2FS_OPTION(sbi).compress_level = 0;
return 0;
}
f2fs_info(sbi, "kernel doesn't support lz4hc compression"); f2fs_info(sbi, "kernel doesn't support lz4hc compression");
return -EINVAL; return -EINVAL;
#endif #endif
...@@ -627,7 +629,7 @@ static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str) ...@@ -627,7 +629,7 @@ static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str)
int len = 4; int len = 4;
if (strlen(str) == len) { if (strlen(str) == len) {
F2FS_OPTION(sbi).compress_level = 0; F2FS_OPTION(sbi).compress_level = F2FS_ZSTD_DEFAULT_CLEVEL;
return 0; return 0;
} }
...@@ -640,7 +642,7 @@ static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str) ...@@ -640,7 +642,7 @@ static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str)
if (kstrtouint(str + 1, 10, &level)) if (kstrtouint(str + 1, 10, &level))
return -EINVAL; return -EINVAL;
if (!level || level > zstd_max_clevel()) { if (level < zstd_min_clevel() || level > zstd_max_clevel()) {
f2fs_info(sbi, "invalid zstd compress level: %d", level); f2fs_info(sbi, "invalid zstd compress level: %d", level);
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment