]> git.hungrycats.org Git - linux/commit
btrfs: stripe_alloc: hold a stripe of margin across a preallocation
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sat, 12 Sep 2026 00:27:55 +0000 (20:27 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Fri, 18 Sep 2026 21:36:29 +0000 (17:36 -0400)
commit0ba3620a218b66f38a37e80ca8ca3a0aaf30abab
tree2e6314525244cae2ef912ec9eb18f22773734ad8
parent94d5cda6cdb7e72d46478c669130edffa587903b
btrfs: stripe_alloc: hold a stripe of margin across a preallocation

Admission now charges a preallocation the roundup of its bytes to whole
stripes, but that charge lives only for the check: between the
reservation and the allocation only the raw bytes sit in bytes_may_use.
fallocate() is quick, but eight fsstress processes preallocating at the
fill edge were quick together, and each in-flight preallocation short of
a stripe still took a stripe the gate had counted for someone else: the
failure-time dump kept showing admitted writes with the supply gone.

Do for preallocation what the delalloc margin does per outstanding
extent: hold one stripe in bytes_stripe_margin from the successful data
reservation until the caller's allocations are done, at the four users
of btrfs_alloc_data_chunk_ondemand() -- fallocate's range loop, the
zero-range preallocation, relocation's cluster preallocation and the
encoded write's extent reservation.  Released as soon as the claims have
landed, so the hold costs nothing beyond that window.

Assisted-by: Claude:claude-fable-5
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/relocation.c
fs/btrfs/space-info.c
fs/btrfs/space-info.h