]> git.hungrycats.org Git - linux/commit
btrfs: dev-replace: report the progress of a canceled replace
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:14 +0000 (21:17 -0500)
commitabbb8e716146ffd84a523e376e9ea0590baf2491
treec814cd3afecc488e65b34e3a68b6fcbb9590f744
parentd463cba97c44dc3e587b054eab35a55740fa200c
btrfs: dev-replace: report the progress of a canceled replace

btrfs_dev_replace_progress() returns 0 for a canceled replace, so
"btrfs replace status" says it was canceled "at 0.0%" however far it
got.  The progress cannot be computed after the fact: it is derived from
cursor_left and the size of the source device, and the source device is
forgotten when the replace stops.

Remember the progress when a running replace fails or is canceled
(btrfs_dev_replace_finishing()) and when a suspended replace is canceled
(btrfs_dev_replace_cancel()), and report it for the CANCELED state.  The
value is kept in memory only; a canceled replace loaded from disk after a
remount still reports 0.  It is as coarse as the progress of a running
replace: scrub_enumerate_chunks() moves cursor_left to the end of a chunk
only when the copy of that chunk is complete, so a replace that stops
part way through a chunk is reported at the start of that chunk.

Assisted-by: Claude:claude-opus-5-5
fs/btrfs/dev-replace.c
fs/btrfs/fs.h