diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 07f636732199..afc9a1a5a884 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1817,10 +1817,10 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) } if ((iflags ^ masked_flags) & F2FS_COMPR_FL) { - if (S_ISREG(inode->i_mode) && - (masked_flags & F2FS_COMPR_FL || i_size_read(inode) || - F2FS_HAS_BLOCKS(inode))) - return -EINVAL; + if (S_ISREG(inode->i_mode) && (masked_flags & F2FS_COMPR_FL)) { + if (f2fs_disable_compressed_file(inode)) + return -EINVAL; + } if (iflags & F2FS_NOCOMP_FL) return -EINVAL; if (iflags & F2FS_COMPR_FL) {