On Wed, May 12, 2021 at 09:52:19AM +0800, Chao Yu wrote:
> On 2021/5/12 5:50, Jaegeuk Kim wrote:
> > On 05/11, changfeng...@vivo.com wrote:
> > > Hi Jaegeuk:
> > > 
> > > If there're existing clusters beyond i_size, may cause data corruption, 
> > > but
> > > will this happen in normal? maybe some error can cause this, if i_size is
> > > error the data beyond size still can't handle properly.  Is there normal
> > > case can casue existing clusters beyond i_size?
> > 
> > We don't have a rule to sync between i_size and i_blocks.
> 
> I can't image a case that compressed cluster may cross filesize, it looks it's
> a bug if that happened, but I'm not sure I have considered all cases. So, I
> prefer to add a check condition as below, then testing w/ xfstest/por_fsstress
> for a while.
> 
> Subject: [PATCH] f2fs: compress: compressed cluster should not cross i_size
> 
> ---
>  fs/f2fs/data.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 06d1e58d3882..9acca358d578 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -3325,6 +3325,8 @@ static int f2fs_write_begin(struct file *file, struct 
> address_space *mapping,
>                       err = ret;
>                       goto fail;
>               } else if (ret) {
> +                     f2fs_bug_on(sbi, index >=
> +                             DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE));
>                       return 0;
>               }
>       }

If a file has both fs-verity and compression enabled, it can have compressed
clusters past i_size.

- Eric


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to