]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: factor rtgroup geom write pointer reporting into a helper
authorChristoph Hellwig <hch@lst.de>
Wed, 27 May 2026 12:39:29 +0000 (14:39 +0200)
committerCarlos Maiolino <cem@kernel.org>
Sat, 30 May 2026 06:26:18 +0000 (08:26 +0200)
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>
fs/xfs/xfs_ioctl.c

index 737afcb5652acfb53749dc8d8fe444330b095925..96af6b62ce3991fb7e1b6eae7e69bdb00a5c4846 100644 (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;