]> git.hungrycats.org Git - linux/commitdiff
btrfs: stripe_alloc: show per-group trapped bytes in the space info dump
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sat, 19 Sep 2026 17:18:16 +0000 (13:18 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sun, 8 Nov 2026 23:37:50 +0000 (18:37 -0500)
btrfs_dump_space_info() prints each block group's available bytes, and
under stripe_alloc those include the free space trapped in partly used
stripes, which no allocation can use until the group is reclaimed
(stripe_unusable).  An ENOSPC dump then shows space in the groups that
cannot be had.

Print stripe_unusable next to zone_unusable and leave it out of the
available bytes.  A group whose trapped bytes have not been counted yet
(stripe_unusable_ready not set) prints 0 and the old available figure.

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

index 5ead2a20114d82a4ef4e689dc6e3c53b666a990f..e23934e298b27ed5d4403c227eb98094596afd6b 100644 (file)
@@ -903,11 +903,15 @@ again:
 
                spin_lock(&cache->lock);
                avail = btrfs_block_group_available_space(cache);
+               if (READ_ONCE(cache->stripe_unusable_ready))
+                       avail -= min(avail, READ_ONCE(cache->stripe_unusable));
                btrfs_info(fs_info,
-"block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %llu delalloc %llu super %llu zone_unusable (%llu bytes available) %s",
+"block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %llu delalloc %llu super %llu zone_unusable %llu stripe_unusable (%llu bytes available) %s",
                           cache->start, cache->length, cache->used, cache->pinned,
                           cache->reserved, cache->delalloc_bytes,
                           cache->bytes_super, cache->zone_unusable,
+                          READ_ONCE(cache->stripe_unusable_ready) ?
+                                  READ_ONCE(cache->stripe_unusable) : 0,
                           avail, cache->ro ? "[readonly]" : "");
                spin_unlock(&cache->lock);
                btrfs_dump_free_space(cache, bytes);