ocfs2: fix data corruption by fallocate
When fallocate punches holes out of inode size, if original isize is in the middle of last cluster, then the part from isize to the end of the cluster will be zeroed with buffer write, at that time isize is not yet updated to match the new size, if writeback is kicked in, it will invoke ocfs2_writepage()->block_write_full_page() where the pages out of inode size will be dropped. That will cause file corruption. Fix this by zero out eof blocks when extending the inode size. Running the following command with qemu-image 4.2.1 can get a corrupted coverted image file easily. qemu-img convert -p -t none -T none -f qcow2 $qcow_image \ -O qcow2 -o compat=1.1 $qcow_image.conv The usage of fallocate in qemu is like this, it first punches holes out of inode size, then extend the inode size. fallocate(11, FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE, 2276196352, 65536) = 0 fallocate(11, 0, 2276196352, 65536) = 0 v1: https://www.spinics.net/lists/linux-fsdevel/msg193999.html v2: https://lore.kernel.org/linux-fsdevel/20210525093034.GB4112@quack2.suse.cz/T/ Link: https://lkml.kernel.org/r/20210528210648.9124-1-junxiao.bi@oracle.com Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Jan Kara <jack@suse.cz> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Changwei Ge <gechangwei@live.cn> Cc: Gang He <ghe@suse.com> Cc: Jun Piao <piaojun@huawei.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
parent
415f0c83
-
mentioned in commit a1700479
-
mentioned in commit cec4e857
-
mentioned in commit 624fa7ba
-
mentioned in commit 33e03ada
-
mentioned in commit c8d5faee
-
mentioned in commit 0a31dd6f
-
mentioned in commit cc2edb99
-
mentioned in commit f267aeb6
-
mentioned in commit 9449ad33
-
mentioned in commit 97bb422f
-
mentioned in commit bed62967
-
mentioned in commit 4c97ed43
-
mentioned in commit 40b5e3f5
-
mentioned in commit cd98ef88
-
mentioned in commit 61b1d20e
-
mentioned in commit fc3f43d5
-
mentioned in commit 439e209b
-
mentioned in commit 94301459
-
mentioned in commit da4f4916
-
mentioned in commit c9302ab3
-
mentioned in commit 3df2bd99
-
mentioned in commit a24d87b4
-
mentioned in commit eaaa4284
Please register or sign in to comment