]> git.hungrycats.org Git - linux/commit
btrfs: dev-replace: count uncorrectable read errors
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Fri, 16 Oct 2026 08:07:34 +0000 (04:07 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 2 Nov 2026 02:17:13 +0000 (21:17 -0500)
commit71a4f4beb010e99c2ee221b72a43a6c82252e0f6
treefda4c576140f20ec24881a86c24c729676d6fede
parent38f6a462f327b6d784eba16c863f991da82783ce
btrfs: dev-replace: count uncorrectable read errors

btrfs_dev_replace::num_uncorrectable_read_errors is reported by the
dev-replace status ioctl ("uncorr. read errs" in btrfs replace status)
and stored in the dev_replace item, but nothing increments it.

Even before v4.19 only two replace paths counted it: the nodatasum fixup
worker, when it could not repair a sector through the page cache, and
the nocow copy worker, when it could not write a range to the target.
Uncorrectable sectors with checksums, data or metadata, went through
scrub_handle_errored_block(), which counted them in the scrub stats but
not here.  Both paths were removed in v4.19, by commits 9bebe665c3e4
("btrfs: scrub: Remove unused copy_nocow_pages and its callchain") and
8b9b6f255485 ("btrfs: scrub: cleanup the remaining nodatasum fixup
code"), and the scrub_stripe based scrub never counted it either.  Status
always shows 0, however many sectors could not be copied.

Count the sectors that flush_scrub_stripes() does not write to the
replace target because they are covered by an extent but could not be
read or repaired from any copy.  This covers every uncorrectable sector
the replace skips, checksummed or not.

The count is taken before the check for a metadata error, which aborts
the replace, so that the sectors of the batch that aborts it are counted
as well.

Assisted-by: Claude:claude-opus-5-5
fs/btrfs/scrub.c