* [PATCH 1/3] xfs: improve xfs_select_zone_nowait()
2026-03-14 23:55 [PATCH 0/3] Zoned XFS code improvements Damien Le Moal
@ 2026-03-14 23:55 ` Damien Le Moal
2026-03-16 9:01 ` Christoph Hellwig
2026-03-14 23:55 ` [PATCH 2/3] xfs: improve xfs_zoned_show_stats() Damien Le Moal
2026-03-14 23:55 ` [PATCH 3/3] xfs: improve xfs_zoned_need_gc() Damien Le Moal
2 siblings, 1 reply; 7+ messages in thread
From: Damien Le Moal @ 2026-03-14 23:55 UTC (permalink / raw)
To: linux-xfs, Carlos Maiolino; +Cc: Christoph Hellwig, Hans Holmberg
Move the check for the return value of the call to
xfs_select_open_zone_mru() inside the if that controls the call to this
function, so that we do not uselessly test again the value of oz when
pack_tight is false.
While at it, also fix a comment typo.
No functional changes.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
fs/xfs/xfs_zone_alloc.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
index 7d712d5a5ce0..a05418ac6a95 100644
--- a/fs/xfs/xfs_zone_alloc.c
+++ b/fs/xfs/xfs_zone_alloc.c
@@ -675,10 +675,11 @@ xfs_select_zone_nowait(
if (oz)
goto out_unlock;
- if (pack_tight)
+ if (pack_tight) {
oz = xfs_select_open_zone_mru(zi, write_hint);
- if (oz)
- goto out_unlock;
+ if (oz)
+ goto out_unlock;
+ }
/*
* See if we can open a new zone and use that so that data for different
@@ -689,7 +690,7 @@ xfs_select_zone_nowait(
goto out_unlock;
/*
- * Try to find an zone that is an ok match to colocate data with.
+ * Try to find a zone that is an ok match to colocate data with.
*/
oz = xfs_select_open_zone_lru(zi, write_hint, XFS_ZONE_ALLOC_OK);
if (oz)
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 1/3] xfs: improve xfs_select_zone_nowait()
2026-03-14 23:55 ` [PATCH 1/3] xfs: improve xfs_select_zone_nowait() Damien Le Moal
@ 2026-03-16 9:01 ` Christoph Hellwig
0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2026-03-16 9:01 UTC (permalink / raw)
To: Damien Le Moal
Cc: linux-xfs, Carlos Maiolino, Christoph Hellwig, Hans Holmberg
On Sun, Mar 15, 2026 at 08:55:06AM +0900, Damien Le Moal wrote:
> Move the check for the return value of the call to
> xfs_select_open_zone_mru() inside the if that controls the call to this
> function, so that we do not uselessly test again the value of oz when
> pack_tight is false.
>
> While at it, also fix a comment typo.
>
> No functional changes.
'improve' is a bit of an odd descriptions as it's wage and subjective.
Maybe try to describe what you're doing a bit better, and to do so
split the patch into the separate parts (even if the one liner
spelling fix is a bit silly otherwise).
The actual functional changes looks good, though.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] xfs: improve xfs_zoned_show_stats()
2026-03-14 23:55 [PATCH 0/3] Zoned XFS code improvements Damien Le Moal
2026-03-14 23:55 ` [PATCH 1/3] xfs: improve xfs_select_zone_nowait() Damien Le Moal
@ 2026-03-14 23:55 ` Damien Le Moal
2026-03-16 9:02 ` Christoph Hellwig
2026-03-14 23:55 ` [PATCH 3/3] xfs: improve xfs_zoned_need_gc() Damien Le Moal
2 siblings, 1 reply; 7+ messages in thread
From: Damien Le Moal @ 2026-03-14 23:55 UTC (permalink / raw)
To: linux-xfs, Carlos Maiolino; +Cc: Christoph Hellwig, Hans Holmberg
Improve the information displayed by /proc/self/mountstats by adding the
total number of zones (RT groups) together with the number of free
zones, and by also showing the number of open zones and the maximum
number of open zones before listing the open zones.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
fs/xfs/xfs_zone_info.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_zone_info.c b/fs/xfs/xfs_zone_info.c
index 53eabbc3334c..85613799edde 100644
--- a/fs/xfs/xfs_zone_info.c
+++ b/fs/xfs/xfs_zone_info.c
@@ -89,10 +89,12 @@ xfs_zoned_show_stats(
!list_empty_careful(&zi->zi_reclaim_reservations));
seq_printf(m, "\tRT GC required: %d\n",
xfs_zoned_need_gc(mp));
+ seq_printf(m, "\tfree zones: %d / %u\n",
+ atomic_read(&zi->zi_nr_free_zones), mp->m_sb.sb_rgcount);
- seq_printf(m, "\tfree zones: %d\n", atomic_read(&zi->zi_nr_free_zones));
- seq_puts(m, "\topen zones:\n");
spin_lock(&zi->zi_open_zones_lock);
+ seq_printf(m, "\topen zones: %u / %u\n",
+ zi->zi_nr_open_zones, mp->m_max_open_zones);
list_for_each_entry(oz, &zi->zi_open_zones, oz_entry)
xfs_show_open_zone(m, oz);
if (zi->zi_open_gc_zone) {
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 2/3] xfs: improve xfs_zoned_show_stats()
2026-03-14 23:55 ` [PATCH 2/3] xfs: improve xfs_zoned_show_stats() Damien Le Moal
@ 2026-03-16 9:02 ` Christoph Hellwig
0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2026-03-16 9:02 UTC (permalink / raw)
To: Damien Le Moal
Cc: linux-xfs, Carlos Maiolino, Christoph Hellwig, Hans Holmberg
On Sun, Mar 15, 2026 at 08:55:07AM +0900, Damien Le Moal wrote:
> Improve the information displayed by /proc/self/mountstats by adding the
> total number of zones (RT groups) together with the number of free
> zones, and by also showing the number of open zones and the maximum
> number of open zones before listing the open zones.
Same comment on the "improve" in the subject, I won't repeat it for the
third patch, promised :)
I am a little bit worried about changing the format of existing lines,
even if this interface is pretty new. Maybe just add new lines for
the total values instead?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] xfs: improve xfs_zoned_need_gc()
2026-03-14 23:55 [PATCH 0/3] Zoned XFS code improvements Damien Le Moal
2026-03-14 23:55 ` [PATCH 1/3] xfs: improve xfs_select_zone_nowait() Damien Le Moal
2026-03-14 23:55 ` [PATCH 2/3] xfs: improve xfs_zoned_show_stats() Damien Le Moal
@ 2026-03-14 23:55 ` Damien Le Moal
2026-03-16 9:03 ` Christoph Hellwig
2 siblings, 1 reply; 7+ messages in thread
From: Damien Le Moal @ 2026-03-14 23:55 UTC (permalink / raw)
To: linux-xfs, Carlos Maiolino; +Cc: Christoph Hellwig, Hans Holmberg
If zonegc_low_space is set to zero (which is the default), the second
condition in xfs_zoned_need_gc() that triggers GC never evaluates to
true, so there is no need to calculate the test threshold and to
evaluate that condition.
While at it, add comments to document the intent of each of the 3 tests
used to determine the return value to control the execution of garbage
collection.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
fs/xfs/xfs_zone_gc.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c
index 309f70098524..0ff710fa0ee7 100644
--- a/fs/xfs/xfs_zone_gc.c
+++ b/fs/xfs/xfs_zone_gc.c
@@ -170,25 +170,37 @@ xfs_zoned_need_gc(
s64 available, free, threshold;
s32 remainder;
+ /* If we have no reclaimable blocks, running GC is useless. */
if (!xfs_zoned_have_reclaimable(mp->m_zone_info))
return false;
+ /*
+ * In order to avoid file fragmentation as much as possible, we should
+ * make sure that we can open enough zones. So trigger GC if the number
+ * of blocks immediately available for writes is lower than the total
+ * number of blocks from all possible open zones.
+ */
available = xfs_estimate_freecounter(mp, XC_FREE_RTAVAILABLE);
-
if (available <
xfs_rtgs_to_rfsbs(mp, mp->m_max_open_zones - XFS_OPEN_GC_ZONES))
return true;
- free = xfs_estimate_freecounter(mp, XC_FREE_RTEXTENTS);
+ /*
+ * For cases where the user wants to be more aggressive with GC,
+ * the sysfs attribute zonegc_low_space may be set to a non zero value,
+ * to indicate that GC should try to maintain at least zonegc_low_space
+ * percent of the free space to be directly available for writing. Check
+ * this here.
+ */
+ if (!mp->m_zonegc_low_space)
+ return false;
+ free = xfs_estimate_freecounter(mp, XC_FREE_RTEXTENTS);
threshold = div_s64_rem(free, 100, &remainder);
threshold = threshold * mp->m_zonegc_low_space +
remainder * div_s64(mp->m_zonegc_low_space, 100);
- if (available < threshold)
- return true;
-
- return false;
+ return available < threshold;
}
static struct xfs_zone_gc_data *
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread