* [PATCH RESEND] Btrfs: fix wrong write offset when replacing a device
@ 2013-07-04 14:14 Stefan Behrens
2013-07-05 8:57 ` Miao Xie
2013-07-05 12:32 ` Josef Bacik
0 siblings, 2 replies; 3+ messages in thread
From: Stefan Behrens @ 2013-07-04 14:14 UTC (permalink / raw)
To: linux-btrfs
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 625f1c8dc.
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 <miaox@cn.fujitsu.com>
Cc: <stable@vger.kernel.org> # 3.10+
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
---
Resent to add stable@vger.kernel.org since the regression was added
in 3.10 RC1.
fs/btrfs/scrub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 4ba2a69..64a157b 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -2495,7 +2495,7 @@ again:
ret = scrub_extent(sctx, extent_logical, extent_len,
extent_physical, extent_dev, flags,
generation, extent_mirror_num,
- extent_physical);
+ extent_logical - logical + physical);
if (ret)
goto out;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] Btrfs: fix wrong write offset when replacing a device
2013-07-04 14:14 [PATCH RESEND] Btrfs: fix wrong write offset when replacing a device Stefan Behrens
@ 2013-07-05 8:57 ` Miao Xie
2013-07-05 12:32 ` Josef Bacik
1 sibling, 0 replies; 3+ messages in thread
From: Miao Xie @ 2013-07-05 8:57 UTC (permalink / raw)
To: Stefan Behrens; +Cc: linux-btrfs
On thu, 4 Jul 2013 16:14:23 +0200, Stefan Behrens wrote:
> 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 625f1c8dc.
>
> 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 <miaox@cn.fujitsu.com>
> Cc: <stable@vger.kernel.org> # 3.10+
> Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Thanks!
Reviewed-and-Tested-by: Miao Xie <miaox@cn.fujitsu.com>
> ---
> Resent to add stable@vger.kernel.org since the regression was added
> in 3.10 RC1.
>
> fs/btrfs/scrub.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
> index 4ba2a69..64a157b 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -2495,7 +2495,7 @@ again:
> ret = scrub_extent(sctx, extent_logical, extent_len,
> extent_physical, extent_dev, flags,
> generation, extent_mirror_num,
> - extent_physical);
> + extent_logical - logical + physical);
> if (ret)
> goto out;
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] Btrfs: fix wrong write offset when replacing a device
2013-07-04 14:14 [PATCH RESEND] Btrfs: fix wrong write offset when replacing a device Stefan Behrens
2013-07-05 8:57 ` Miao Xie
@ 2013-07-05 12:32 ` Josef Bacik
1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2013-07-05 12:32 UTC (permalink / raw)
To: Stefan Behrens; +Cc: linux-btrfs
On Thu, Jul 04, 2013 at 04:14:23PM +0200, Stefan Behrens wrote:
> 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 625f1c8dc.
>
> 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.
>
I'd like to see a xfstest for this please so we can make sure something like
this doesn't happen in the future. You can use SCRATCH_DEV_POOL to have
multiple devices. Please cc linux-btrfs when you submit it so I can review it
and hopefully get it in faster. Thanks,
Josef
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-05 12:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-04 14:14 [PATCH RESEND] Btrfs: fix wrong write offset when replacing a device Stefan Behrens
2013-07-05 8:57 ` Miao Xie
2013-07-05 12:32 ` Josef Bacik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).