Skip to content

Commit f5f3bd9

Browse files
author
Jaegeuk Kim
committed
f2fs: set the default compress_level on ioctl
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: [email protected] Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 943f7c6 commit f5f3bd9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fs/f2fs/file.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4005,6 +4005,15 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
40054005
F2FS_I(inode)->i_compress_algorithm = option.algorithm;
40064006
F2FS_I(inode)->i_log_cluster_size = option.log_cluster_size;
40074007
F2FS_I(inode)->i_cluster_size = BIT(option.log_cluster_size);
4008+
/* Set default level */
4009+
if (F2FS_I(inode)->i_compress_algorithm == COMPRESS_ZSTD)
4010+
F2FS_I(inode)->i_compress_level = F2FS_ZSTD_DEFAULT_CLEVEL;
4011+
else
4012+
F2FS_I(inode)->i_compress_level = 0;
4013+
/* Adjust mount option level */
4014+
if (option.algorithm == F2FS_OPTION(sbi).compress_algorithm &&
4015+
F2FS_OPTION(sbi).compress_level)
4016+
F2FS_I(inode)->i_compress_level = F2FS_OPTION(sbi).compress_level;
40084017
f2fs_mark_inode_dirty_sync(inode, true);
40094018

40104019
if (!f2fs_is_compress_backend_ready(inode))

0 commit comments

Comments
 (0)