Skip to content

Commit 5f93e77

Browse files
morbidrsakdave
authored andcommitted
btrfs: zoned: print unusable percentage when reclaiming block groups
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>
1 parent 54afaae commit 5f93e77

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

fs/btrfs/block-group.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
15011501
mutex_lock(&fs_info->reclaim_bgs_lock);
15021502
spin_lock(&fs_info->unused_bgs_lock);
15031503
while (!list_empty(&fs_info->reclaim_bgs)) {
1504+
u64 zone_unusable;
15041505
int ret = 0;
15051506

15061507
bg = list_first_entry(&fs_info->reclaim_bgs,
@@ -1534,13 +1535,22 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
15341535
goto next;
15351536
}
15361537

1538+
/*
1539+
* Cache the zone_unusable value before turning the block group
1540+
* to read only. As soon as the blog group is read only it's
1541+
* zone_unusable value gets moved to the block group's read-only
1542+
* bytes and isn't available for calculations anymore.
1543+
*/
1544+
zone_unusable = bg->zone_unusable;
15371545
ret = inc_block_group_ro(bg, 0);
15381546
up_write(&space_info->groups_sem);
15391547
if (ret < 0)
15401548
goto next;
15411549

1542-
btrfs_info(fs_info, "reclaiming chunk %llu with %llu%% used",
1543-
bg->start, div64_u64(bg->used * 100, bg->length));
1550+
btrfs_info(fs_info,
1551+
"reclaiming chunk %llu with %llu%% used %llu%% unusable",
1552+
bg->start, div_u64(bg->used * 100, bg->length),
1553+
div64_u64(zone_unusable * 100, bg->length));
15441554
trace_btrfs_reclaim_block_group(bg);
15451555
ret = btrfs_relocate_chunk(fs_info, bg->start);
15461556
if (ret)

0 commit comments

Comments
 (0)