Skip to content

Commit 09c8c3f

Browse files
chaseyugregkh
authored andcommitted
f2fs: compress: fix to disallow enabling compress on non-empty file
[ Upstream commit 519a5a2 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0d41bd0 commit 09c8c3f

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
@@ -1836,6 +1836,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
18361836
if (iflags & F2FS_COMPR_FL) {
18371837
if (!f2fs_may_compress(inode))
18381838
return -EINVAL;
1839+
if (S_ISREG(inode->i_mode) && inode->i_size)
1840+
return -EINVAL;
18391841

18401842
set_compress_context(inode);
18411843
}

0 commit comments

Comments
 (0)