Re: [f2fs-dev] [PATCH] f2fs: fix to check compression feature before enabling file compression

Eric Biggers
2022-08-04T18:29:08Z

On Thu, Aug 04, 2022 at 09:41:40PM +0800, Chao Yu wrote:
> From: Chao Yu <chao.yu@oppo.com>
>
> This patch disallow to enable file compression in image which doesn't
> support compression feature.
>
> Signed-off-by: Chao Yu <chao.yu@oppo.com>
> ---
> fs/f2fs/file.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 24f5b02c78e7..4a3f4eaa3fc5 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1872,6 +1872,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
> if (!f2fs_disable_compressed_file(inode))
> return -EINVAL;
> } else {
> + if (!f2fs_sb_has_compression(F2FS_I_SB(inode)))
> + return -EOPNOTSUPP;
> if (!f2fs_may_compress(inode))
> return -EINVAL;
> if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))
> --

How is this different from the same check that occurs earlier in the function?

- Eric