mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
f2fs: compress: fix to check zstd compress level correctly in mount option
[ Upstream commit e39602da752cd1d0462e3fa04074146f6f2803f6 ] f2fs only support to config zstd compress level w/ a positive number due to layout design, but since commite0c1b49f5b("lib: zstd: Upgrade to latest upstream zstd version 1.4.10"), zstd supports negative compress level, so that zstd_min_clevel() may return a negative number, then w/ below mount option, .compress_level can be configed w/ a negative number, which is not allowed to f2fs, let's add check condition to avoid it. mount -o compress_algorithm=zstd:4294967295 /dev/sdx /mnt/f2fs Fixes:00e120b5e4("f2fs: assign default compression level") Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
@@ -649,7 +649,7 @@ static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str)
|
|||||||
#ifdef CONFIG_F2FS_FS_ZSTD
|
#ifdef CONFIG_F2FS_FS_ZSTD
|
||||||
static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str)
|
static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str)
|
||||||
{
|
{
|
||||||
unsigned int level;
|
int level;
|
||||||
int len = 4;
|
int len = 4;
|
||||||
|
|
||||||
if (strlen(str) == len) {
|
if (strlen(str) == len) {
|
||||||
@@ -663,9 +663,15 @@ static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str)
|
|||||||
f2fs_info(sbi, "wrong format, e.g. <alg_name>:<compr_level>");
|
f2fs_info(sbi, "wrong format, e.g. <alg_name>:<compr_level>");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (kstrtouint(str + 1, 10, &level))
|
if (kstrtoint(str + 1, 10, &level))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
/* f2fs does not support negative compress level now */
|
||||||
|
if (level < 0) {
|
||||||
|
f2fs_info(sbi, "do not support negative compress level: %d", level);
|
||||||
|
return -ERANGE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!f2fs_is_compress_level_valid(COMPRESS_ZSTD, level)) {
|
if (!f2fs_is_compress_level_valid(COMPRESS_ZSTD, level)) {
|
||||||
f2fs_info(sbi, "invalid zstd compress level: %d", level);
|
f2fs_info(sbi, "invalid zstd compress level: %d", level);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|||||||
Reference in New Issue
Block a user