]> git.hungrycats.org Git - linux/commit
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)
commit38f6a462f327b6d784eba16c863f991da82783ce
tree3ea7a569c046e6617936b7c9a7d492c152198460
parentb3281fe3706819e0af40bd44efff8d90e7877c71
btrfs: scrub: do not count write errors twice, or on the wrong device

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