Messages in this thread | | | Subject | Re: [PATCH 6/9] f2fs: zstd: Switch to the zstd-1.4.6 API | From | Chao Yu <> | Date | Fri, 18 Sep 2020 10:58:35 +0800 |
| |
On 2020/9/18 10:56, Eric Biggers wrote: > On Fri, Sep 18, 2020 at 09:47:32AM +0800, Chao Yu wrote: >> Ah, I got it. >> >> Step of enabling compressed inode is not correct, we should touch an empty >> file, and then use 'chattr +c' on that file to enable compression, otherwise >> the race condition could be complicated to handle. So we need below diff to >> disallow setting compression flag on an non-empty file: >> >> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >> index 8a422400e824..b462db7898fd 100644 >> --- a/fs/f2fs/file.c >> +++ b/fs/f2fs/file.c >> @@ -1836,6 +1836,8 @@ 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 (get_dirty_pages(inode) || fi->i_compr_blocks) >> + return -EINVAL; >> >> set_compress_context(inode); >> } > > Why not: > > if (inode->i_size) > return -EINVAL;
Yeah, I noticed that after replying this email, I've prepared the new patch which including the i_size check.
Thanks for noticing this.
Thanks,
> . >
| |