summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2026-03-31 18:26:05 +0300
committerCarlos Maiolino <cem@kernel.org>2026-04-07 14:16:59 +0300
commit02367990bdcbeabb0ffd3e8e227e5f79a04186fc (patch)
tree6c9ea155048623e415d61652edbfd29484ccf3ec
parent553a13e2076d64774910d597977a17022625763d (diff)
downloadlinux-02367990bdcbeabb0ffd3e8e227e5f79a04186fc.tar.xz
xfs: refactor xfs_mount_zones
xfs_mount_zones has grown a bit too big and unorganized. Split the zone reporting loop into a separate helper, hiding the rtg variable there. Print the mount message last, and also keep the VFS writeback chunk size last instead of in the middle of the logic to calculate the free/available blocks. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r--fs/xfs/xfs_zone_alloc.c54
1 files changed, 34 insertions, 20 deletions
diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
index 06e2cb79030e..e9f1d9d08620 100644
--- a/fs/xfs/xfs_zone_alloc.c
+++ b/fs/xfs/xfs_zone_alloc.c
@@ -1230,6 +1230,29 @@ xfs_free_zone_info(
kfree(zi);
}
+static int
+xfs_report_zones(
+ struct xfs_mount *mp,
+ struct xfs_init_zones *iz)
+{
+ struct xfs_rtgroup *rtg = NULL;
+
+ while ((rtg = xfs_rtgroup_next(mp, rtg))) {
+ xfs_rgblock_t write_pointer;
+ int error;
+
+ error = xfs_query_write_pointer(iz, rtg, &write_pointer);
+ if (!error)
+ error = xfs_init_zone(iz, rtg, write_pointer);
+ if (error) {
+ xfs_rtgroup_rele(rtg);
+ return error;
+ }
+ }
+
+ return 0;
+}
+
int
xfs_mount_zones(
struct xfs_mount *mp)
@@ -1238,7 +1261,6 @@ xfs_mount_zones(
.zone_capacity = mp->m_groups[XG_TYPE_RTG].blocks,
.zone_size = xfs_rtgroup_raw_size(mp),
};
- struct xfs_rtgroup *rtg = NULL;
int error;
if (!mp->m_rtdev_targp) {
@@ -1268,9 +1290,13 @@ xfs_mount_zones(
if (!mp->m_zone_info)
return -ENOMEM;
- xfs_info(mp, "%u zones of %u blocks (%u max open zones)",
- mp->m_sb.sb_rgcount, iz.zone_capacity, mp->m_max_open_zones);
- trace_xfs_zones_mount(mp);
+ error = xfs_report_zones(mp, &iz);
+ if (error)
+ goto out_free_zone_info;
+
+ xfs_set_freecounter(mp, XC_FREE_RTAVAILABLE, iz.available);
+ xfs_set_freecounter(mp, XC_FREE_RTEXTENTS,
+ iz.available + iz.reclaimable);
/*
* The writeback code switches between inodes regularly to provide
@@ -1296,22 +1322,6 @@ xfs_mount_zones(
XFS_FSB_TO_B(mp, min(iz.zone_capacity, XFS_MAX_BMBT_EXTLEN)) >>
PAGE_SHIFT;
- while ((rtg = xfs_rtgroup_next(mp, rtg))) {
- xfs_rgblock_t write_pointer;
-
- error = xfs_query_write_pointer(&iz, rtg, &write_pointer);
- if (!error)
- error = xfs_init_zone(&iz, rtg, write_pointer);
- if (error) {
- xfs_rtgroup_rele(rtg);
- goto out_free_zone_info;
- }
- }
-
- xfs_set_freecounter(mp, XC_FREE_RTAVAILABLE, iz.available);
- xfs_set_freecounter(mp, XC_FREE_RTEXTENTS,
- iz.available + iz.reclaimable);
-
/*
* The user may configure GC to free up a percentage of unused blocks.
* By default this is 0. GC will always trigger at the minimum level
@@ -1322,6 +1332,10 @@ xfs_mount_zones(
error = xfs_zone_gc_mount(mp);
if (error)
goto out_free_zone_info;
+
+ xfs_info(mp, "%u zones of %u blocks (%u max open zones)",
+ mp->m_sb.sb_rgcount, iz.zone_capacity, mp->m_max_open_zones);
+ trace_xfs_zones_mount(mp);
return 0;
out_free_zone_info: