All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: zoned: improve logging message for auto reclaim
@ 2021-06-28 18:16 Johannes Thumshirn
  2021-06-28 20:15 ` David Sterba
  2021-06-30 10:06 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2021-06-28 18:16 UTC (permalink / raw)
  To: David Sterba; +Cc: Johannes Thumshirn, linux-btrfs, Naohiro Aota

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.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/block-group.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 38b127b9edfc..98296eef561e 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -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,
@@ -1534,13 +1535,22 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
 			goto next;
 		}
 
+		/*
+		 * Cache the zone_unusable value before tunring 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, div_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)
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: zoned: improve logging message for auto reclaim
  2021-06-28 18:16 [PATCH] btrfs: zoned: improve logging message for auto reclaim Johannes Thumshirn
@ 2021-06-28 20:15 ` David Sterba
  2021-06-30 10:06 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2021-06-28 20:15 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: David Sterba, linux-btrfs, Naohiro Aota

On Tue, Jun 29, 2021 at 03:16:46AM +0900, Johannes Thumshirn wrote:
> -		btrfs_info(fs_info, "reclaiming chunk %llu with %llu%% used",
> -				bg->start, div_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));

Btw, the bg->used also needs div64_u64, I had a patch somewhere but
can't find it so please fix it as you're touching the code.

Regarding the message, it would not show in non-zoned mode so it should
be ok to print it unconditionally. Once the background reclaim is also
done for regular fs the 'unusable' might be confusing but we can fix
that if neccesary, printing int + string conditionally needs some magic.

I'll add this patch to misc-next, switching the div helpers could happen
in the reverse order but I'll fix that eventually.

>  		trace_btrfs_reclaim_block_group(bg);
>  		ret = btrfs_relocate_chunk(fs_info, bg->start);
>  		if (ret)
> -- 
> 2.31.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: zoned: improve logging message for auto reclaim
  2021-06-28 18:16 [PATCH] btrfs: zoned: improve logging message for auto reclaim Johannes Thumshirn
  2021-06-28 20:15 ` David Sterba
@ 2021-06-30 10:06 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2021-06-30 10:06 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: David Sterba, linux-btrfs, Naohiro Aota

On Tue, Jun 29, 2021 at 03:16:46AM +0900, Johannes Thumshirn wrote:
> 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.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-30 10:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 18:16 [PATCH] btrfs: zoned: improve logging message for auto reclaim Johannes Thumshirn
2021-06-28 20:15 ` David Sterba
2021-06-30 10:06 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.