]> git.hungrycats.org Git - linux/commitdiff
btrfs: stripe_alloc: count whole stripes stranded behind live runs as trapped (reclai...
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sat, 19 Sep 2026 17:18:19 +0000 (13:18 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sun, 8 Nov 2026 23:37:59 +0000 (18:37 -0500)
The hunks of "btrfs: stripe_alloc: count whole stripes stranded behind
live runs as trapped" (earlier in this series) that need code from
"btrfs: stripe_alloc: hand groups full of trapped free space to the
reclaim worker", which comes after it in this series: they are applied
here, once "btrfs: stripe_alloc: hand groups full of trapped free space
to the reclaim worker" is in, instead of with the rest of "btrfs:
stripe_alloc: count whole stripes stranded behind live runs as trapped".

Assisted-by: Claude:claude-fable-5
Assisted-by: Claude:claude-opus-5-5
fs/btrfs/free-space-cache.c

index 8de7f03061eff2fc53f5b2c0f6f5d167b83ae3ec..b9e88f239c8ff11ccbcddb08c753000ff78e1853 100644 (file)
@@ -3655,7 +3655,13 @@ bool btrfs_stripe_bg_wants_reclaim(struct btrfs_block_group *bg)
        struct btrfs_space_info *sinfo = bg->space_info;
        const int thresh = READ_ONCE(sinfo->bg_reclaim_threshold);
        const u64 used = READ_ONCE(bg->used);
-       const u64 trapped = READ_ONCE(bg->stripe_unusable);
+       const u64 unusable = READ_ONCE(bg->stripe_unusable);
+       /*
+        * Stripes stranded behind live runs are trapped for admission but not
+        * for reclaim: they come back by themselves when the run is freed, and
+        * relocating the group would only force that.
+        */
+       const u64 trapped = unusable - min(unusable, READ_ONCE(bg->stripe_stranded));
        u64 elsewhere;
        u64 promised;