]> git.hungrycats.org Git - linux/commit
btrfs: stripe_alloc: count nocow run lifecycles and stranded stripes in sysfs
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sat, 19 Sep 2026 17:18:20 +0000 (13:18 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sun, 8 Nov 2026 23:37:51 +0000 (18:37 -0500)
commitb891ae52d0cd1b7d4f1a3758bcb61cd8766bb26e
tree06ecf88524ec056926891ba78bdc5d1193862bc8
parentaaee499b35f826a089cbdcf3cce9fd26b382dc3a
btrfs: stripe_alloc: count nocow run lifecycles and stranded stripes in sysfs

Add a stripe_run_stats file beside stripe_park_stats with lifetime
counters for the paths the previous two patches touched, so a test can
show that it exercised them rather than merely passed: private NOCOW
runs opened, claim candidates refused for overlapping a live run, bytes
of whole stripes the scans found stranded behind live runs, and rescans
requested by a freed run to credit its stripes back.

A persistent nocow run whose allocations have all been freed is dead: it
owns no data and only strands the whole stripes in its range (99% of the
free whole stripes of every read-write group sat inside such runs after an
fsstress fallocate load).  btrfs_stripe_run_note_free(), from
btrfs_add_free_space(), clears the live bits of freed sectors inside a
persistent run, and close_block_group_stripe_runs() closes a persistent
run that handed out space, has nothing in flight and no live bit set, on
the normal commit path that frees it and marks its group for the rescan.
A run with any live byte stays open, so a slowly appended nocow file still
burns no stripe per commit; a run whose map was retired is never taken as
dead.  The free path only clears bits under bg->stripe_run_lock.
nocow_run_dead_closed counts the closes.

Assisted-by: Claude:claude-fable-5
Assisted-by: Claude:claude-opus-5-5
fs/btrfs/block-group.c
fs/btrfs/fs.h
fs/btrfs/sysfs.c