]> git.hungrycats.org Git - linux/commit
btrfs: stripe_alloc: count and log ordered extents that end with sectors unwritten
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Fri, 9 Oct 2026 23:13:11 +0000 (19:13 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 2 Nov 2026 02:16:30 +0000 (21:16 -0500)
commit653d25e0405c08fda7ecffa69501806167e2f74b
tree50582fdfb0e72fe4aa3c1f0569a0e982fa7290fe
parent18ac62a1a57943123fcc2dceb262473c118c70e7
btrfs: stripe_alloc: count and log ordered extents that end with sectors unwritten

When an ordered extent reports to its stripe run, sectors it allocated
that no write reached are marked written so nothing waits for them (a
failed write, truncated folios, a short direct write, error teardown).
Whether any of these paths can still leave a waiter stuck in practice is
not known: the log settle that motivated the marking seals and frees a
shared LOG run before it would wait.

Count such extents and their unwritten bytes in stripe_run_stats
(unwritten_on_end, unwritten_on_end_bytes) and log each one, rate
limited, with the extent's identity, truncated length and flags, to see
which paths produce them.

One class is harmless and is counted but not logged: an extent marked
TRUNCATED, with no IOERR and not compressed (disk_num_bytes == num_bytes),
whose unwritten sectors are exactly the part truncation cut off,
[disk_bytenr + ALIGN(truncated_len, sectorsize), disk_bytenr +
disk_num_bytes).  It comes from a truncate or O_TRUNC racing writeback and
from a direct write whose bounce-buffer copy faults before copying
anything, and it would bury the lines the message is there to find.
btrfs_open_stripe_write_done_run() returns the lowest unwritten sector so
that the tail can be told from merely as many sectors.  Those extents go to
unwritten_on_end_truncated and unwritten_on_end_truncated_bytes;
unwritten_on_end and unwritten_on_end_bytes count only the logged ones, so
any increase there is worth a look.

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