Skip to content

Commit e50b122

Browse files
fdmananakdave
authored andcommitted
btrfs: print available space for a block group when dumping a space info
When dumping a space info, we iterate over all its block groups and then print their size and the amounts of bytes used, reserved, pinned, etc. When debugging -ENOSPC problems it's also useful to know how much space is available (free), so calculate that and print it as well. Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent b92e8f5 commit e50b122

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/btrfs/space-info.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,18 @@ void btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
523523
down_read(&info->groups_sem);
524524
again:
525525
list_for_each_entry(cache, &info->block_groups[index], list) {
526+
u64 avail;
527+
526528
spin_lock(&cache->lock);
529+
avail = cache->length - cache->used - cache->pinned -
530+
cache->reserved - cache->delalloc_bytes -
531+
cache->bytes_super - cache->zone_unusable;
527532
btrfs_info(fs_info,
528-
"block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %llu delalloc %llu super %llu zone_unusable %s",
533+
"block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %llu delalloc %llu super %llu zone_unusable (%llu bytes available) %s",
529534
cache->start, cache->length, cache->used, cache->pinned,
530535
cache->reserved, cache->delalloc_bytes,
531536
cache->bytes_super, cache->zone_unusable,
532-
cache->ro ? "[readonly]" : "");
537+
avail, cache->ro ? "[readonly]" : "");
533538
spin_unlock(&cache->lock);
534539
btrfs_dump_free_space(cache, bytes);
535540
}

0 commit comments

Comments
 (0)