Zoned XFS code improvements
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
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
@@ -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
PATCH 2/3 xfs: improve xfs_zoned_show_stats()
In reply to Damien Le MoalImprove 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
@@ -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
PATCH 3/3 xfs: improve xfs_zoned_need_gc()
In reply to Damien Le MoalIf 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
@@ -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
Re: [PATCH 1/3] xfs: improve xfs_select_zone_nowait()
In reply to Damien Le MoalQuoted 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 whenpack_tightis 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.
Re: [PATCH 2/3] xfs: improve xfs_zoned_show_stats()
In reply to Damien Le MoalQuoted 4 lines · Damien Le Moal
Improve the information displayed by
/proc/self/mountstatsby 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?
Re: [PATCH 3/3] xfs: improve xfs_zoned_need_gc()
In reply to Damien Le MoalLooks good modolu the subject line.