On 2021/5/18 5:18, Eric Biggers wrote:
On Fri, May 14, 2021 at 09:15:54AM +0800, Chao Yu wrote:
On 2021/5/14 5:17, Eric Biggers wrote:
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.
Correct, any other case we missed for a writable file? let us know.
Thanks,
Well, files become read-only once fs-verity is enabled on them, but that happens
after the blocks past i_size are written in the first place. That part still
uses ->write_begin(), ->write_end(), ->writepages(), etc.
Yup, the scenario we concern here is there is a writable file which has
compressed
cluster crossing filesize, and then it appends data starting from filesize.
Thanks,
- Eric
.
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel