f2fs: allow set compression option of files without blocks
authorYangtao Li <frank.li@vivo.com>
Mon, 23 Jan 2023 09:46:01 +0000 (17:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 12:57:23 +0000 (13:57 +0100)
[ Upstream commit e6261beb0c629403dc58997294dd521bd23664af ]

Files created by truncate have a size but no blocks, so
they can be allowed to set compression option.

Fixes: e1e8debec656 ("f2fs: add F2FS_IOC_SET_COMPRESS_OPTION ioctl")
Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/file.c

index 758048a885d2418c8fad4ce540dfba17f7c46d91..326c1a4c2a6ac9f6fc4e1d33f59c0eb8f772c9cf 100644 (file)
@@ -3928,7 +3928,7 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
                goto out;
        }
 
-       if (inode->i_size != 0) {
+       if (F2FS_HAS_BLOCKS(inode)) {
                ret = -EFBIG;
                goto out;
        }