]> git.hungrycats.org Git - linux/commit
btrfs: stripe_alloc: attribute each data read-modify-write to why padding declined
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Wed, 30 Sep 2026 22:07:52 +0000 (18:07 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sun, 8 Nov 2026 23:38:07 +0000 (18:38 -0500)
commit6958045ffcf8e798cb2dab0657b6468d10559846
tree42acdb0f13152f4b7034ba5a4e176691984cc7de
parent7cb773f12e1e66457345bab7e13b9bcbd25e86cf
btrfs: stripe_alloc: attribute each data read-modify-write to why padding declined

data_rmw counts read-modify-writes, and the pad_decline_* counters count
the pad oracle's refusals, but a refusal does not always lead to a read
(a full stripe or a cached one does not read), so the two cannot be
subtracted: nothing says which RMWs the allocator explains.  With
allow_rmw empty, a data RMW in a stripe_alloc group is expected in two
places only:

 - at the open run's own frontier (the pad verdict UNCOVERED): the
   sectors it reads belong to the same run, in the same transaction,
   and are not durable yet;

 - from relocation writing into its own preallocated extents, which no
   root but the data reloc tree references until relocation moves the
   pointers after writeback.

Record the pad oracle's verdict on the rbio (rmw_try_pad_full()) and,
at the RMW site, split data_rmw by it (data_rmw_<reason>, with
data_rmw_not_tried when the oracle was not consulted and
data_rmw_pad_ok_nomem when it agreed but the zero pages could not be
allocated).  NO_RUN is the oracle's catch-all exit, so split it further
by the exit taken (data_rmw_norun_*) and count those in a read-only
group (data_rmw_norun_bg_ro).  Count the data RMWs written by the data
reloc inode outside the frontier (data_rmw_reloc_writer, disjoint from
data_rmw_uncovered).  All in stripe_park_stats.

A test can then assert that data_rmw - data_rmw_uncovered -
data_rmw_reloc_writer is zero on a stripe_alloc filesystem, on a
production kernel, with reclaim relocating during the run -- which it
could not do from the totals alone.

The cost is a byte of state per rbio and a few counter increments per
RMW, plus one block group lookup for NO_RUN RMWs.

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