f2fs: allow compression of files without blocks
authorChao Liu <liuchao@coolpad.com>
Thu, 7 Jul 2022 09:09:24 +0000 (17:09 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sun, 31 Jul 2022 03:17:06 +0000 (20:17 -0700)
Files created by truncate(1) have a size but no blocks, so
they can be allowed to enable compression.

Signed-off-by: Chao Liu <liuchao@coolpad.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index eb43852752a6d4b832c29fabfc26d6bfd5bfabe3..6b1b030830ca5b5938ffa8b7a7cc8a2ee4e174e6 100644 (file)
@@ -1879,7 +1879,7 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
                if (iflags & F2FS_COMPR_FL) {
                        if (!f2fs_may_compress(inode))
                                return -EINVAL;
-                       if (S_ISREG(inode->i_mode) && inode->i_size)
+                       if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))
                                return -EINVAL;
 
                        set_compress_context(inode);