]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: Change the expanding write sequence to fix snapshot related bug.
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Thu, 27 Mar 2014 02:51:58 +0000 (02:51 +0000)
committerChris Mason <clm@fb.com>
Mon, 7 Apr 2014 16:08:42 +0000 (09:08 -0700)
commitb56885545be1c3279a31e2da4819fa68c44d2223
tree204d2121e02075ef4a5c23b3011010a537a556da
parentd09c650fed8acd078459ff725b746bd68d7d3738
btrfs: Change the expanding write sequence to fix snapshot related bug.

When testing fsstress with snapshot making background, some snapshot
following problem.

Snapshot 270:
inode 323: size 0

Snapshot 271:
inode 323: size 349145
|-------Hole---|---------Empty gap-------|-------Hole-----|
0     122880 172032       349145

Snapshot 272:
inode 323: size 349145
|-------Hole---|------------Data---------|-------Hole-----|
0     122880 172032       349145

The fsstress operation on inode 323 is the following:
write:  offset  126832  len 43124
truncate:  size  349145

Since the write with offset is consist of 2 operations:
1. punch hole
2. write data
Hole punching is faster than data write, so hole punching in write
and truncate is done first and then buffered write, so the snapshot 271 got
empty gap, which will not pass btrfsck.

To fix the bug, this patch will change the write sequence which will
first punch a hole covering the write end if a hole is needed.

Reported-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/file.c