* [PATCH] btrfs: fix replace/scrub failure with metadata_uuid
@ 2023-07-28 6:48 Anand Jain
2023-08-01 7:45 ` Anand Jain
2023-08-11 15:52 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Anand Jain @ 2023-07-28 6:48 UTC (permalink / raw)
To: linux-btrfs; +Cc: Anand Jain
Fstests with POST_MKFS_CMD="btrfstune -m" (as in the mailing list)
reported a few of the test cases failing.
The failure scenario can be summaried and simplified as follows:
$ mkfs.btrfs -fq -draid1 -mraid1 /dev/sdb1 /dev/sdb2 :0
$ btrfstune -m /dev/sdb1 :0
$ wipefs -a /dev/sdb1 :0
$ mount -o degraded /dev/sdb2 /btrfs :0
$ btrfs replace start -B -f -r 1 /dev/sdb1 /btrfs :1
STDERR:
ERROR: ioctl(DEV_REPLACE_START) failed on "/btrfs": Input/output error
[11290.583502] BTRFS warning (device sdb2): tree block 22036480 mirror 2 has bad fsid, has 99835c32-49f0-4668-9e66-dc277a96b4a6 want da40350c-33ac-4872-92a8-4948ed8c04d0
[11290.586580] BTRFS error (device sdb2): unable to fix up (regular) error at logical 22020096 on dev /dev/sdb8 physical 1048576
As above, the replace is failing because we are verifying the header with
fs_devices::fsid instead of fs_devices::metadata_uuid, despite the
metadata_uuid actually being present.
To fix this, use fs_devices::metadata_uuid;
(We copy fsid into fs_devices::metadata_uuid if there is no
metadata_uuid, so its fine).
Fixes: a3ddbaebc7c9 ("btrfs: scrub: introduce a helper to verify one metadata block")
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/scrub.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index db076e12f442..8381174bda15 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -605,7 +605,8 @@ static void scrub_verify_one_metadata(struct scrub_stripe *stripe, int sector_nr
btrfs_stack_header_bytenr(header), logical);
return;
}
- if (memcmp(header->fsid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE) != 0) {
+ if (memcmp(header->fsid, fs_info->fs_devices->metadata_uuid,
+ BTRFS_FSID_SIZE) != 0) {
bitmap_set(&stripe->meta_error_bitmap, sector_nr, sectors_per_tree);
bitmap_set(&stripe->error_bitmap, sector_nr, sectors_per_tree);
btrfs_warn_rl(fs_info,
--
2.38.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: fix replace/scrub failure with metadata_uuid
2023-07-28 6:48 [PATCH] btrfs: fix replace/scrub failure with metadata_uuid Anand Jain
@ 2023-08-01 7:45 ` Anand Jain
2023-08-11 15:52 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Anand Jain @ 2023-08-01 7:45 UTC (permalink / raw)
To: linux-btrfs
Gentle ping?
Thx.
On 28/07/2023 14:48, Anand Jain wrote:
> Fstests with POST_MKFS_CMD="btrfstune -m" (as in the mailing list)
> reported a few of the test cases failing.
>
> The failure scenario can be summaried and simplified as follows:
>
> $ mkfs.btrfs -fq -draid1 -mraid1 /dev/sdb1 /dev/sdb2 :0
> $ btrfstune -m /dev/sdb1 :0
> $ wipefs -a /dev/sdb1 :0
> $ mount -o degraded /dev/sdb2 /btrfs :0
> $ btrfs replace start -B -f -r 1 /dev/sdb1 /btrfs :1
> STDERR:
> ERROR: ioctl(DEV_REPLACE_START) failed on "/btrfs": Input/output error
>
> [11290.583502] BTRFS warning (device sdb2): tree block 22036480 mirror 2 has bad fsid, has 99835c32-49f0-4668-9e66-dc277a96b4a6 want da40350c-33ac-4872-92a8-4948ed8c04d0
> [11290.586580] BTRFS error (device sdb2): unable to fix up (regular) error at logical 22020096 on dev /dev/sdb8 physical 1048576
>
> As above, the replace is failing because we are verifying the header with
> fs_devices::fsid instead of fs_devices::metadata_uuid, despite the
> metadata_uuid actually being present.
>
> To fix this, use fs_devices::metadata_uuid;
>
> (We copy fsid into fs_devices::metadata_uuid if there is no
> metadata_uuid, so its fine).
>
> Fixes: a3ddbaebc7c9 ("btrfs: scrub: introduce a helper to verify one metadata block")
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> fs/btrfs/scrub.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
> index db076e12f442..8381174bda15 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -605,7 +605,8 @@ static void scrub_verify_one_metadata(struct scrub_stripe *stripe, int sector_nr
> btrfs_stack_header_bytenr(header), logical);
> return;
> }
> - if (memcmp(header->fsid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE) != 0) {
> + if (memcmp(header->fsid, fs_info->fs_devices->metadata_uuid,
> + BTRFS_FSID_SIZE) != 0) {
> bitmap_set(&stripe->meta_error_bitmap, sector_nr, sectors_per_tree);
> bitmap_set(&stripe->error_bitmap, sector_nr, sectors_per_tree);
> btrfs_warn_rl(fs_info,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: fix replace/scrub failure with metadata_uuid
2023-07-28 6:48 [PATCH] btrfs: fix replace/scrub failure with metadata_uuid Anand Jain
2023-08-01 7:45 ` Anand Jain
@ 2023-08-11 15:52 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2023-08-11 15:52 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
On Fri, Jul 28, 2023 at 02:48:13PM +0800, Anand Jain wrote:
> Fstests with POST_MKFS_CMD="btrfstune -m" (as in the mailing list)
> reported a few of the test cases failing.
>
> The failure scenario can be summaried and simplified as follows:
>
> $ mkfs.btrfs -fq -draid1 -mraid1 /dev/sdb1 /dev/sdb2 :0
> $ btrfstune -m /dev/sdb1 :0
> $ wipefs -a /dev/sdb1 :0
> $ mount -o degraded /dev/sdb2 /btrfs :0
> $ btrfs replace start -B -f -r 1 /dev/sdb1 /btrfs :1
> STDERR:
> ERROR: ioctl(DEV_REPLACE_START) failed on "/btrfs": Input/output error
>
> [11290.583502] BTRFS warning (device sdb2): tree block 22036480 mirror 2 has bad fsid, has 99835c32-49f0-4668-9e66-dc277a96b4a6 want da40350c-33ac-4872-92a8-4948ed8c04d0
> [11290.586580] BTRFS error (device sdb2): unable to fix up (regular) error at logical 22020096 on dev /dev/sdb8 physical 1048576
>
> As above, the replace is failing because we are verifying the header with
> fs_devices::fsid instead of fs_devices::metadata_uuid, despite the
> metadata_uuid actually being present.
>
> To fix this, use fs_devices::metadata_uuid;
>
> (We copy fsid into fs_devices::metadata_uuid if there is no
> metadata_uuid, so its fine).
>
> Fixes: a3ddbaebc7c9 ("btrfs: scrub: introduce a helper to verify one metadata block")
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-11 15:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-28 6:48 [PATCH] btrfs: fix replace/scrub failure with metadata_uuid Anand Jain
2023-08-01 7:45 ` Anand Jain
2023-08-11 15:52 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox