Skip to content

Commit 519a5a2

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: compress: fix to disallow enabling compress on non-empty file
Compressed inode and normal inode has different layout, so we should disallow enabling compress on non-empty file to avoid race condition during inode .i_addr array parsing and updating. Signed-off-by: Chao Yu <yuchao0@huawei.com> [Jaegeuk Kim: Fix missing condition] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent c68d6c8 commit 519a5a2

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/f2fs/file.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,6 +1821,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
18211821
if (iflags & F2FS_COMPR_FL) {
18221822
if (!f2fs_may_compress(inode))
18231823
return -EINVAL;
1824+
if (S_ISREG(inode->i_mode) && inode->i_size)
1825+
return -EINVAL;
18241826

18251827
set_compress_context(inode);
18261828
}

0 commit comments

Comments
 (0)