Skip to content

Commit d89c285

Browse files
naotakdave
authored andcommitted
btrfs: do not subtract delalloc from avail bytes
The block group's avail bytes printed when dumping a space info subtract the delalloc_bytes. However, as shown in btrfs_add_reserved_bytes() and btrfs_free_reserved_bytes(), it is added or subtracted along with "reserved" for the delalloc case, which means the "delalloc_bytes" is a part of the "reserved" bytes. So, excluding it to calculate the avail space counts delalloc_bytes twice, which can lead to an invalid result. Fixes: e50b122 ("btrfs: print available space for a block group when dumping a space info") CC: [email protected] # 6.6+ Signed-off-by: Naohiro Aota <[email protected]> Reviewed-by: Boris Burkov <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 4785743 commit d89c285

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fs/btrfs/space-info.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,7 @@ void btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
583583

584584
spin_lock(&cache->lock);
585585
avail = cache->length - cache->used - cache->pinned -
586-
cache->reserved - cache->delalloc_bytes -
587-
cache->bytes_super - cache->zone_unusable;
586+
cache->reserved - cache->bytes_super - cache->zone_unusable;
588587
btrfs_info(fs_info,
589588
"block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %llu delalloc %llu super %llu zone_unusable (%llu bytes available) %s",
590589
cache->start, cache->length, cache->used, cache->pinned,

0 commit comments

Comments
 (0)