]> git.hungrycats.org Git - linux/commitdiff
btrfs: scrub: do not count write errors twice, or on the wrong device
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Fri, 16 Oct 2026 08:07:33 +0000 (04:07 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 2 Nov 2026 02:17:13 +0000 (21:17 -0500)
scrub_write_endio() increments the write error counter of stripe->dev
for every sector of a failed write.  The bio layer has already counted
the failure: scrub writes are submitted through
btrfs_submit_repair_write() to a single device, and btrfs_simple_end_io()
calls btrfs_log_dev_io_error() on that device.

For a repair write the device is stripe->dev, so the error is counted
twice.  For a dev-replace write the bio goes to the replace target, which
the bio layer charges correctly, while scrub_write_endio() also charges
the source device, which did not fail.

Drop the extra accounting in scrub_write_endio(); the write_error_bitmap
it maintains is unchanged.

Fixes: ec1f3a207cdf3 ("btrfs: scrub: update device stats when an error is detected")
Assisted-by: Claude:claude-opus-5-5
fs/btrfs/scrub.c

index 98362c91bce43729aa6967b8edcff7a58b37748e..5128e2989016bf14fbe2b7e7def3048148425621 100644 (file)
@@ -1265,9 +1265,6 @@ static void scrub_write_endio(struct btrfs_bio *bbio)
                bitmap_set(&stripe->write_error_bitmap, sector_nr,
                           bio_size >> fs_info->sectorsize_bits);
                spin_unlock_irqrestore(&stripe->write_error_lock, flags);
-               for (int i = 0; i < (bio_size >> fs_info->sectorsize_bits); i++)
-                       btrfs_dev_stat_inc_and_print(stripe->dev,
-                                                    BTRFS_DEV_STAT_WRITE_ERRS);
        }
        bio_put(&bbio->bio);