diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2023-09-08 15:41:42 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-11-28 17:20:11 +0000 |
commit | 00de7280a5156f356d6ec3d50f448b6df244b146 (patch) | |
tree | a582d6eadffacba1a720bbf9fe02e32db7c20826 /fs/f2fs | |
parent | 9de9f078bdf58e70653f9db91abf7dd9f87bf98b (diff) | |
download | linux-starfive-00de7280a5156f356d6ec3d50f448b6df244b146.tar.gz linux-starfive-00de7280a5156f356d6ec3d50f448b6df244b146.tar.bz2 linux-starfive-00de7280a5156f356d6ec3d50f448b6df244b146.zip |
f2fs: set the default compress_level on ioctl
commit f5f3bd903a5d3e3b2ba89f11e0e29db25e60c048 upstream.
Otherwise, we'll get a broken inode.
# touch $FILE
# f2fs_io setflags compression $FILE
# f2fs_io set_coption 2 8 $FILE
[ 112.227612] F2FS-fs (dm-51): sanity_check_compress_inode: inode (ino=8d3fe) has unsupported compress level: 0, run fsck to fix
Cc: stable@vger.kernel.org
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/file.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index d034703eb323..a06f03d23762 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4006,6 +4006,15 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) F2FS_I(inode)->i_compress_algorithm = option.algorithm; F2FS_I(inode)->i_log_cluster_size = option.log_cluster_size; F2FS_I(inode)->i_cluster_size = BIT(option.log_cluster_size); + /* Set default level */ + if (F2FS_I(inode)->i_compress_algorithm == COMPRESS_ZSTD) + F2FS_I(inode)->i_compress_level = F2FS_ZSTD_DEFAULT_CLEVEL; + else + F2FS_I(inode)->i_compress_level = 0; + /* Adjust mount option level */ + if (option.algorithm == F2FS_OPTION(sbi).compress_algorithm && + F2FS_OPTION(sbi).compress_level) + F2FS_I(inode)->i_compress_level = F2FS_OPTION(sbi).compress_level; f2fs_mark_inode_dirty_sync(inode, true); if (!f2fs_is_compress_backend_ready(inode)) |