From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: atwellwea@gmail.com, Qu Wenruo <wqu@suse.com>,
David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: count failed RAID1 scrub repair writes as uncorrectable
Date: Sun, 29 Nov 2026 07:42:13 +1030 [thread overview]
Message-ID: <fb362e93-183f-439c-b06b-3769b255ff67@gmx.com> (raw)
In-Reply-To: <20261128-btrfs-scrub-write-error-revalidated-v1-1-be9f21eede17@gmail.com>
在 2026/11/29 07:21, Wesley Atwell via B4 Relay 写道:
> From: Wesley Atwell <atwellwea@gmail.com>
>
> When scrub reads a damaged sector from one RAID1 mirror, it can recover
> that sector from the other mirror and attempt to write it back. If the
> repair write fails, scrub currently reports the sector as corrected:
> the final read-error bitmap is clear, while the separate write-error
> bitmap is ignored by the ordinary stripe reporter.
>
> In a QEMU guest on the Btrfs for-next tree, btrfs scrub start -B on a
> local RAID1 filesystem returned success and reported 16 corrected,
> zero uncorrectable sectors after targeted read and repair-write EIO.
> The damaged mirror sector remained unchanged on disk, even though the
> file was still readable from its good copy. A healthy scrub reported no
> errors, and a writable-repair control restored the damaged sector.
Duplicated unnecessary info. Delete the whole paragraph.
>
> Include failed repair writes in the reporter's final error bitmap and
> clear the write-error bitmap when a scrub stripe is reused. With the
> same failed-write workload, scrub now exits 3, reports 16
> uncorrectable and zero corrected sectors, and no longer logs those
> sectors as fixed up. The healthy and successful-repair controls still
> pass. This change addresses the tested mirror-based reporting path;
> RAID56 parity scrub aggregates errors separately.
>
> OpenAI Codex identified the reporting omission, drafted this change
> and changelog, and prepared the QEMU scrub workload. The task asked it
> to find software-only crypto and filesystem defects, prove a failure
> during a legitimate Linux workload on an unmodified kernel, and fix
> only findings that passed the real-user evidence gate. The unmodified
> and changed kernels were tested on the Btrfs for-next base with healthy,
> failed-write and successful-repair cases; an independent review checked
> the source paths and raw on-disk result.
Make the LLM word salad short, and no one cares which agent you use.
If you need to explicit show how to test, you shouldn't submit such patch.
To be honest, if you know nothing and fully rely on agents to do
everything, you should stop and just send out a bug report.
This will save everyone time.
>
> Fixes: 0096580713ff ("btrfs: scrub: introduce error reporting functionality for scrub_stripe")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wesley Atwell <atwellwea@gmail.com>
> ---
> The patch makes ordinary mirror scrub accounting include sectors whose
> repair writes fail after a successful read from another mirror.
>
> The task asked Codex to investigate filesystem defects, prove real-user
> impact on an unmodified kernel, and fix only findings that passed that gate.
> ---
> fs/btrfs/scrub.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
> index c8da03e14094..b6dc7b5ec763 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -1023,7 +1023,9 @@ static void scrub_stripe_report_errors(struct scrub_ctx *sctx,
> struct btrfs_fs_info *fs_info = sctx->fs_info;
> struct btrfs_device *dev = NULL;
> const unsigned long extent_bitmap = scrub_bitmap_read_has_extent(stripe);
> - const unsigned long error_bitmap = scrub_bitmap_read_error(stripe);
> + unsigned long error_bitmap;
> + unsigned long read_error_bitmap;
> + unsigned long flags;
> u64 physical = 0;
> int nr_data_sectors = 0;
> int nr_meta_sectors = 0;
> @@ -1063,6 +1065,12 @@ static void scrub_stripe_report_errors(struct scrub_ctx *sctx,
> }
>
> skip:
> + read_error_bitmap = scrub_bitmap_read_error(stripe);
> + spin_lock_irqsave(&stripe->write_error_lock, flags);
Why need to take this lock at all?
All IO should end before reaching this function.
In fact, if a lock is really needed, then the read_error_bitmap() read
is already racy.
> + bitmap_or(&error_bitmap, &read_error_bitmap, &stripe->write_error_bitmap,
> + stripe->nr_sectors);
> + spin_unlock_irqrestore(&stripe->write_error_lock, flags);
> +
> for_each_set_bit(sector_nr, &extent_bitmap, stripe->nr_sectors) {
> const u64 sector_logical = stripe->logical +
> ((u64)sector_nr << fs_info->sectorsize_bits);
> @@ -1796,6 +1804,12 @@ static int scrub_find_fill_first_stripe(struct btrfs_block_group *bg,
>
> static void scrub_reset_stripe(struct scrub_stripe *stripe)
> {
> + unsigned long flags;
> +
> + spin_lock_irqsave(&stripe->write_error_lock, flags);
Again, why?
> + stripe->write_error_bitmap = 0;
> + spin_unlock_irqrestore(&stripe->write_error_lock, flags);
> +
> scrub_stripe_reset_bitmaps(stripe);
>
> stripe->nr_meta_extents = 0;
>
> ---
> base-commit: 14bf1d1d36414abf5f7f5b8e69a1810617c5f22f
> change-id: 20261128-btrfs-scrub-write-error-revalidated-c00a17629d27
>
> Best regards,
next prev parent reply other threads:[~2026-11-28 21:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 20:51 Wesley Atwell via B4 Relay
2026-11-28 21:12 ` Qu Wenruo [this message]
2026-11-28 23:31 ` Wesley Atwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fb362e93-183f-439c-b06b-3769b255ff67@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=atwellwea@gmail.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@kernel.org \
--cc=wqu@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®