Skip to content

Commit

Permalink
btrfs: zoned: print unusable percentage when reclaiming block groups
Browse files Browse the repository at this point in the history
When we're automatically reclaiming a zone, because its zone_unusable
value is above the reclaim threshold, we're only logging how much
percent of the zone's capacity are used, but not how much of the
capacity is unusable.

Also print the percentage of the unusable space in the block group
before we're reclaiming it.

Example:

  BTRFS info (device sdg): reclaiming chunk 230686720 with 13% used 86% unusable

CC: stable@vger.kernel.org # 5.13
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Johannes Thumshirn authored and David Sterba committed Jul 7, 2021
1 parent 54afaae commit 5f93e77
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions fs/btrfs/block-group.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
mutex_lock(&fs_info->reclaim_bgs_lock);
spin_lock(&fs_info->unused_bgs_lock);
while (!list_empty(&fs_info->reclaim_bgs)) {
u64 zone_unusable;
int ret = 0;

bg = list_first_entry(&fs_info->reclaim_bgs,
Expand Down Expand Up @@ -1534,13 +1535,22 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
goto next;
}

/*
* Cache the zone_unusable value before turning the block group
* to read only. As soon as the blog group is read only it's
* zone_unusable value gets moved to the block group's read-only
* bytes and isn't available for calculations anymore.
*/
zone_unusable = bg->zone_unusable;
ret = inc_block_group_ro(bg, 0);
up_write(&space_info->groups_sem);
if (ret < 0)
goto next;

btrfs_info(fs_info, "reclaiming chunk %llu with %llu%% used",
bg->start, div64_u64(bg->used * 100, bg->length));
btrfs_info(fs_info,
"reclaiming chunk %llu with %llu%% used %llu%% unusable",
bg->start, div_u64(bg->used * 100, bg->length),
div64_u64(zone_unusable * 100, bg->length));
trace_btrfs_reclaim_block_group(bg);
ret = btrfs_relocate_chunk(fs_info, bg->start);
if (ret)
Expand Down

0 comments on commit 5f93e77

Please sign in to comment.