Skip to content

Commit 0236799

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
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>
1 parent 553a13e commit 0236799

1 file changed

Lines changed: 34 additions & 20 deletions

File tree

fs/xfs/xfs_zone_alloc.c

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,29 @@ xfs_free_zone_info(
12301230
kfree(zi);
12311231
}
12321232

1233+
static int
1234+
xfs_report_zones(
1235+
struct xfs_mount *mp,
1236+
struct xfs_init_zones *iz)
1237+
{
1238+
struct xfs_rtgroup *rtg = NULL;
1239+
1240+
while ((rtg = xfs_rtgroup_next(mp, rtg))) {
1241+
xfs_rgblock_t write_pointer;
1242+
int error;
1243+
1244+
error = xfs_query_write_pointer(iz, rtg, &write_pointer);
1245+
if (!error)
1246+
error = xfs_init_zone(iz, rtg, write_pointer);
1247+
if (error) {
1248+
xfs_rtgroup_rele(rtg);
1249+
return error;
1250+
}
1251+
}
1252+
1253+
return 0;
1254+
}
1255+
12331256
int
12341257
xfs_mount_zones(
12351258
struct xfs_mount *mp)
@@ -1238,7 +1261,6 @@ xfs_mount_zones(
12381261
.zone_capacity = mp->m_groups[XG_TYPE_RTG].blocks,
12391262
.zone_size = xfs_rtgroup_raw_size(mp),
12401263
};
1241-
struct xfs_rtgroup *rtg = NULL;
12421264
int error;
12431265

12441266
if (!mp->m_rtdev_targp) {
@@ -1268,9 +1290,13 @@ xfs_mount_zones(
12681290
if (!mp->m_zone_info)
12691291
return -ENOMEM;
12701292

1271-
xfs_info(mp, "%u zones of %u blocks (%u max open zones)",
1272-
mp->m_sb.sb_rgcount, iz.zone_capacity, mp->m_max_open_zones);
1273-
trace_xfs_zones_mount(mp);
1293+
error = xfs_report_zones(mp, &iz);
1294+
if (error)
1295+
goto out_free_zone_info;
1296+
1297+
xfs_set_freecounter(mp, XC_FREE_RTAVAILABLE, iz.available);
1298+
xfs_set_freecounter(mp, XC_FREE_RTEXTENTS,
1299+
iz.available + iz.reclaimable);
12741300

12751301
/*
12761302
* The writeback code switches between inodes regularly to provide
@@ -1296,22 +1322,6 @@ xfs_mount_zones(
12961322
XFS_FSB_TO_B(mp, min(iz.zone_capacity, XFS_MAX_BMBT_EXTLEN)) >>
12971323
PAGE_SHIFT;
12981324

1299-
while ((rtg = xfs_rtgroup_next(mp, rtg))) {
1300-
xfs_rgblock_t write_pointer;
1301-
1302-
error = xfs_query_write_pointer(&iz, rtg, &write_pointer);
1303-
if (!error)
1304-
error = xfs_init_zone(&iz, rtg, write_pointer);
1305-
if (error) {
1306-
xfs_rtgroup_rele(rtg);
1307-
goto out_free_zone_info;
1308-
}
1309-
}
1310-
1311-
xfs_set_freecounter(mp, XC_FREE_RTAVAILABLE, iz.available);
1312-
xfs_set_freecounter(mp, XC_FREE_RTEXTENTS,
1313-
iz.available + iz.reclaimable);
1314-
13151325
/*
13161326
* The user may configure GC to free up a percentage of unused blocks.
13171327
* By default this is 0. GC will always trigger at the minimum level
@@ -1322,6 +1332,10 @@ xfs_mount_zones(
13221332
error = xfs_zone_gc_mount(mp);
13231333
if (error)
13241334
goto out_free_zone_info;
1335+
1336+
xfs_info(mp, "%u zones of %u blocks (%u max open zones)",
1337+
mp->m_sb.sb_rgcount, iz.zone_capacity, mp->m_max_open_zones);
1338+
trace_xfs_zones_mount(mp);
13251339
return 0;
13261340

13271341
out_free_zone_info:

0 commit comments

Comments
 (0)