From: Christoph Hellwig Date: Tue, 31 Mar 2026 15:26:05 +0000 (+0200) Subject: xfs: refactor xfs_mount_zones X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=02367990bdcbeabb0ffd3e8e227e5f79a04186fc;p=thirdparty%2Fkernel%2Flinux.git 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 Reviewed-by: Hans Holmberg Reviewed-by: Damien Le Moal Signed-off-by: Carlos Maiolino --- 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: