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
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);