* [PATCH] btrfs: return an error for unrepaired RAID56 scrub sectors
@ 2026-10-25 18:03 Cheng Yongkang
2026-10-26 6:52 ` Qu Wenruo
2026-10-26 9:09 ` Filipe Manana
0 siblings, 2 replies; 3+ messages in thread
From: Cheng Yongkang @ 2026-10-25 18:03 UTC (permalink / raw)
To: David Sterba; +Cc: Chris Mason, linux-btrfs, linux-kernel, Cheng Yongkang
scrub_raid56_parity_stripe() returns the leftover value of
scrub_find_fill_first_stripe() (0 or 1) when it detects unrepaired
sectors in a data stripe. Scrub callers only treat negative values as
errors, so the unrepaired state is masked as success and P/Q
regeneration is skipped; a device replace can then copy corrupted data.
Return -EIO so the unrepaired sectors are reported and the corrupt
stripe is not treated as healthy.
The masked-success behavior was reproduced 3/3 times: baseline scrub
returned 0 with "finished ... status: 0", left P/Q unregenerated, and a
device replace copied corruption. With this change scrub returns -EIO
and the replace is canceled; healthy RAID1/RAID5 scrub still succeeds.
Assisted-by: LLM
Signed-off-by: Cheng Yongkang <teel4res@gmail.com>
---
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 479c0e0..ba2e27c 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -2250,7 +2250,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
"scrub: unrepaired sectors detected, full stripe %llu data stripe %u errors %*pbl",
full_stripe_start, i, stripe->nr_sectors,
&error);
- return ret;
+ return -EIO;
}
bitmap_or(&extent_bitmap, &extent_bitmap, &has_extent,
stripe->nr_sectors);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: return an error for unrepaired RAID56 scrub sectors
2026-10-25 18:03 [PATCH] btrfs: return an error for unrepaired RAID56 scrub sectors Cheng Yongkang
@ 2026-10-26 6:52 ` Qu Wenruo
2026-10-26 9:09 ` Filipe Manana
1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2026-10-26 6:52 UTC (permalink / raw)
To: Cheng Yongkang, David Sterba; +Cc: Chris Mason, linux-btrfs, linux-kernel
在 2026/10/26 04:33, Cheng Yongkang 写道:
> scrub_raid56_parity_stripe() returns the leftover value of
> scrub_find_fill_first_stripe() (0 or 1) when it detects unrepaired
> sectors in a data stripe. Scrub callers only treat negative values as
> errors, so the unrepaired state is masked as success and P/Q
> regeneration is skipped; a device replace can then copy corrupted data.
>
> Return -EIO so the unrepaired sectors are reported and the corrupt
> stripe is not treated as healthy.
>
> The masked-success behavior was reproduced 3/3 times: baseline scrub
> returned 0 with "finished ... status: 0", left P/Q unregenerated, and a
> device replace copied corruption. With this change scrub returns -EIO
> and the replace is canceled; healthy RAID1/RAID5 scrub still succeeds.
>
> Assisted-by: LLM
> Signed-off-by: Cheng Yongkang <teel4res@gmail.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
> ---
> 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 479c0e0..ba2e27c 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -2250,7 +2250,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
> "scrub: unrepaired sectors detected, full stripe %llu data stripe %u errors %*pbl",
> full_stripe_start, i, stripe->nr_sectors,
> &error);
> - return ret;
> + return -EIO;
> }
> bitmap_or(&extent_bitmap, &extent_bitmap, &has_extent,
> stripe->nr_sectors);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: return an error for unrepaired RAID56 scrub sectors
2026-10-25 18:03 [PATCH] btrfs: return an error for unrepaired RAID56 scrub sectors Cheng Yongkang
2026-10-26 6:52 ` Qu Wenruo
@ 2026-10-26 9:09 ` Filipe Manana
1 sibling, 0 replies; 3+ messages in thread
From: Filipe Manana @ 2026-10-26 9:09 UTC (permalink / raw)
To: Cheng Yongkang; +Cc: David Sterba, Chris Mason, linux-btrfs, linux-kernel
On Sun, Oct 25, 2026 at 6:05 PM Cheng Yongkang <teel4res@gmail.com> wrote:
>
> scrub_raid56_parity_stripe() returns the leftover value of
> scrub_find_fill_first_stripe() (0 or 1) when it detects unrepaired
> sectors in a data stripe. Scrub callers only treat negative values as
> errors, so the unrepaired state is masked as success and P/Q
> regeneration is skipped; a device replace can then copy corrupted data.
>
> Return -EIO so the unrepaired sectors are reported and the corrupt
> stripe is not treated as healthy.
>
> The masked-success behavior was reproduced 3/3 times: baseline scrub
> returned 0 with "finished ... status: 0", left P/Q unregenerated, and a
> device replace copied corruption. With this change scrub returns -EIO
> and the replace is canceled; healthy RAID1/RAID5 scrub still succeeds.
This information in the last paragraph is rather useless.
Rather than state the obvious, just check why we were not returning an
error when we should have. If you checked the git history, you would
see this is a regression.
Also, add a Fixes tag identifying the commit, as this is a bug and
should be backported to stable kernels.
You should also check the for-next branches (in kernel.org and on
https://github.com/btrfs/linux/commits/for-next/) before sending
patches, as this issue was already fixed:
https://github.com/btrfs/linux/commits/for-next/
>
> Assisted-by: LLM
> Signed-off-by: Cheng Yongkang <teel4res@gmail.com>
> ---
> 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 479c0e0..ba2e27c 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -2250,7 +2250,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
> "scrub: unrepaired sectors detected, full stripe %llu data stripe %u errors %*pbl",
> full_stripe_start, i, stripe->nr_sectors,
> &error);
> - return ret;
> + return -EIO;
> }
> bitmap_or(&extent_bitmap, &extent_bitmap, &has_extent,
> stripe->nr_sectors);
> --
> 2.34.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-26 9:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-25 18:03 [PATCH] btrfs: return an error for unrepaired RAID56 scrub sectors Cheng Yongkang
2026-10-26 6:52 ` Qu Wenruo
2026-10-26 9:09 ` Filipe Manana
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®