counters, fixes those three failures and what a failed replace leaves
behind, and adds an option to abort a replace on uncorrectable data.
-Josef Bacik's "btrfs: don't trim the target of a device replace" (5/5 of
-"btrfs: data integrity fixes" v2, 2026-11-03), posted separately, fixes
-another replace data loss: FITRIM during a replace discarded everything
-already copied to the target.
-
Patch 1 commits the CANCELED state when a replace fails or is canceled.
btrfs_dev_replace_finishing() updated the item but did not commit, so
on an idle filesystem the item still said STARTED at unmount and the
Patch 2 stops scrub_write_endio() from counting a failed write a second
time (repair writes) or on the source device (replace writes), on top
-of the bio layer's own count. Fixes: ec1f3a207cdf3.
+of the bio layer's own count. Fixes: ec1f3a207cdf3 ("btrfs: scrub:
+update device stats when an error is detected", v6.16).
Patch 3 counts uncorrectable read errors again. "uncorr. read errs" in
btrfs replace status always showed 0: checksummed sectors were never
Patch 5 counts write errors to the target again. scrub_enumerate_chunks()
stops a replace with -EIO once num_write_errors is non-zero, so that a
failing target does not silently become the new device, but nothing has
-incremented it since the move to scrub_stripe. Fixes: e02ee89baa66c.
+incremented it since the move to scrub_stripe. Fixes: e02ee89baa66c
+("btrfs: scrub: switch scrub_simple_mirror() to scrub_stripe
+infrastructure", v6.4).
Patch 6 fixes a data loss. When the copy of a chunk stops part way,
scrub_enumerate_chunks() still moves cursor_left to the end of the
the same blocks with csum errors on the new device. Reproduced without
the patch and on stock 6.12. Since v6.11 an idle unmount commits
nothing there and hides it; before that, every unmount during a replace
-was exposed. Fixes: 1a1a8b732c7e9.
+was exposed. Fixes: 1a1a8b732c7e9 ("Btrfs: fix race setting block
+group back to RW mode during device replace", v4.7).
Patch 7 reports how far a canceled replace got, instead of "at 0.0%".
fsid is taken for a clone and given a temp-fsid; the replace target
(devid 0, not counted in num_devices) hits both, and the mount fails
with "failed to init dev_replace: -EIO" however often 'btrfs device
-scan' is run. Fixes: bc27d6f0aa0e4, a5b8a5f9f8355.
+scan' is run. Fixes: bc27d6f0aa0e4 ("btrfs: scan but don't register
+device on single device filesystem", v6.7) and a5b8a5f9f8355 ("btrfs:
+support cloned-device mount capability", v6.7).
Patch 10 stops a scrub or a replace at the next extent once the
-filesystem has an error. Since 1acd6831d9877 removed the cancel from
-the error handler, a scrub or replace after e.g. a log sync abort reads
+filesystem has an error. Since 1acd6831d9877 ("Btrfs: avoid risk of a
+deadlock in btrfs_handle_error", v3.8) removed the cancel from the error
+handler, a scrub or replace after e.g. a log sync abort reads
on to the end of the device on the read-only filesystem, and a replace
then stays started anyway. The scrub ioctl now returns -EROFS with the
progress so far; a replace keeps its cursor at the start of the block