xfs: factor rtgroup geom write pointer reporting into a helper

Sticks out a bit better if we add a separate helper for it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
Christoph Hellwig 2026-05-27 14:39:29 +02:00 committed by Carlos Maiolino
parent c316bb56bf
commit 2fa29c1a16

View File

@ -409,6 +409,26 @@ xfs_ioc_ag_geometry(
return 0;
}
static void
xfs_rtgroup_report_write_pointer(
struct xfs_rtgroup *rtg,
struct xfs_rtgroup_geometry *rgeo)
{
xfs_rtgroup_lock(rtg, XFS_RTGLOCK_RMAP);
if (rtg->rtg_open_zone) {
rgeo->rg_writepointer = rtg->rtg_open_zone->oz_allocated;
} else {
xfs_rgblock_t highest_rgbno = xfs_rtrmap_highest_rgbno(rtg);
if (highest_rgbno == NULLRGBLOCK)
rgeo->rg_writepointer = 0;
else
rgeo->rg_writepointer = highest_rgbno + 1;
}
xfs_rtgroup_unlock(rtg, XFS_RTGLOCK_RMAP);
rgeo->rg_flags |= XFS_RTGROUP_GEOM_WRITEPOINTER;
}
STATIC int
xfs_ioc_rtgroup_geometry(
struct xfs_mount *mp,
@ -416,7 +436,6 @@ xfs_ioc_rtgroup_geometry(
{
struct xfs_rtgroup *rtg;
struct xfs_rtgroup_geometry rgeo;
xfs_rgblock_t highest_rgbno;
int error;
if (copy_from_user(&rgeo, arg, sizeof(rgeo)))
@ -435,21 +454,8 @@ xfs_ioc_rtgroup_geometry(
error = xfs_rtgroup_get_geometry(rtg, &rgeo);
if (error)
goto out_put_rtg;
if (xfs_has_zoned(mp)) {
xfs_rtgroup_lock(rtg, XFS_RTGLOCK_RMAP);
if (rtg->rtg_open_zone) {
rgeo.rg_writepointer = rtg->rtg_open_zone->oz_allocated;
} else {
highest_rgbno = xfs_rtrmap_highest_rgbno(rtg);
if (highest_rgbno == NULLRGBLOCK)
rgeo.rg_writepointer = 0;
else
rgeo.rg_writepointer = highest_rgbno + 1;
}
xfs_rtgroup_unlock(rtg, XFS_RTGLOCK_RMAP);
rgeo.rg_flags |= XFS_RTGROUP_GEOM_WRITEPOINTER;
}
if (xfs_has_zoned(mp))
xfs_rtgroup_report_write_pointer(rtg, &rgeo);
if (copy_to_user(arg, &rgeo, sizeof(rgeo)))
error = -EFAULT;