Skip to content

Commit 115930c

Browse files
Stefan BehrensJosef Bacik
authored andcommitted
Btrfs: fix wrong write offset when replacing a device
Miao Xie reported the following issue: The filesystem was corrupted after we did a device replace. Steps to reproduce: # mkfs.btrfs -f -m single -d raid10 <device0>..<device3> # mount <device0> <mnt> # btrfs replace start -rfB 1 <device4> <mnt> # umount <mnt> # btrfsck <device4> The reason for the issue is that we changed the write offset by mistake, introduced by commit 625f1c8. We read the data from the source device at first, and then write the data into the corresponding place of the new device. In order to implement the "-r" option, the source location is remapped using btrfs_map_block(). The read takes place on the mapped location, and the write needs to take place on the unmapped location. Currently the write is using the mapped location, and this commit changes it back by undoing the change to the write address that the aforementioned commit added by mistake. Reported-by: Miao Xie <[email protected]> Cc: <[email protected]> # 3.10+ Signed-off-by: Stefan Behrens <[email protected]> Signed-off-by: Josef Bacik <[email protected]>
1 parent d29a9f6 commit 115930c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/scrub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
24952495
ret = scrub_extent(sctx, extent_logical, extent_len,
24962496
extent_physical, extent_dev, flags,
24972497
generation, extent_mirror_num,
2498-
extent_physical);
2498+
extent_logical - logical + physical);
24992499
if (ret)
25002500
goto out;
25012501

0 commit comments

Comments
 (0)