f2fs: allow to set compression for inlined file
authorJaegeuk Kim <jaegeuk@kernel.org>
Mon, 24 Oct 2022 23:00:35 +0000 (16:00 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 2 Nov 2022 00:56:03 +0000 (17:56 -0700)
The below commit disallows to set compression on empty created file which
has a inline_data. Let's fix it.

Fixes: 7165841d578e ("f2fs: fix to check inline_data during compressed inode conversion")
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index 82cda12582272a0040fe168beb454d787b0e2af1..f96bbfa8b39912f8877cab55d09676bd1f66a86f 100644 (file)
@@ -1915,6 +1915,10 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
                        if (!f2fs_disable_compressed_file(inode))
                                return -EINVAL;
                } else {
+                       /* try to convert inline_data to support compression */
+                       int err = f2fs_convert_inline_inode(inode);
+                       if (err)
+                               return err;
                        if (!f2fs_may_compress(inode))
                                return -EINVAL;
                        if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))