Skip to contentSkip to conversation

Zoned XFS code improvements

PATCH Superseded Damien Le Moal 2 participants 7 messages Mar 15 – Mar 16 XFS filesystem

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Zoned XFS code improvements

All,

here are 3 simple patches to cleanup/improve the code for zoned XFS. Overall, there is no functional changes introduced beside the change of information displayed in /proc/self/mountstats (patch 2).

Damien Le Moal (3):
xfs: improve xfs_select_zone_nowait()
xfs: improve xfs_zoned_show_stats()
xfs: improve xfs_zoned_need_gc()

 fs/xfs/xfs_zone_alloc.c |  9 +++++----
 fs/xfs/xfs_zone_gc.c    | 24 ++++++++++++++++++------
 fs/xfs/xfs_zone_info.c  |  6 ++++--
 3 files changed, 27 insertions(+), 12 deletions(-)

base-commit: f8544b654f22b1138ba12bc0971a96963b20311d

Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/3 xfs: improve xfs_select_zone_nowait()

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.

---
 fs/xfs/xfs_zone_alloc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
fs/xfs/xfs_zone_alloc.c +5 -4
index 7d712d5a5ce0..a05418ac6a95 100644
@@ -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)
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH 1/3] xfs: improve xfs_select_zone_nowait()

Quoted 8 lines · Damien Le Moal

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.

#3 lore raw

PATCH 2/3 xfs: improve xfs_zoned_show_stats()

In reply to Damien Le Moal

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.

---
 fs/xfs/xfs_zone_info.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/xfs/xfs_zone_info.c +4 -2
index 53eabbc3334c..85613799edde 100644
@@ -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) {
Signature · 1 line
2.53.0
#4 lore raw

Re: [PATCH 2/3] xfs: improve xfs_zoned_show_stats()

Quoted 4 lines · Damien Le Moal

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?

#5 lore raw

PATCH 3/3 xfs: improve xfs_zoned_need_gc()

In reply to Damien Le Moal

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.

---
 fs/xfs/xfs_zone_gc.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
fs/xfs/xfs_zone_gc.c +18 -6
index 309f70098524..0ff710fa0ee7 100644
@@ -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 *
Signature · 1 line
2.53.0
#6 lore raw

Re: [PATCH 3/3] xfs: improve xfs_zoned_need_gc()

Looks good modolu the subject line.