* [PATCH] xfs: add write pointer to xfs_rtgroup_geometry
@ 2026-02-27 3:01 Wilfred Mallawa
2026-02-27 4:06 ` Darrick J. Wong
0 siblings, 1 reply; 4+ messages in thread
From: Wilfred Mallawa @ 2026-02-27 3:01 UTC (permalink / raw)
To: Carlos Maiolino
Cc: linux-xfs, linux-kernel, Christoph Hellwig, Darrick J . Wong,
Wilfred Mallawa
From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
There is currently no XFS ioctl that allows userspace to retrieve the
write pointer for a specific realtime group block for zoned XFS. On zoned
block devices, userspace can obtain this information via zone reports from
the underlying device. However, for zoned XFS operating on regular block
devices, no equivalent mechanism exists.
Access to the realtime group write pointer is useful to userspace
development and analysis tools such as Zonar [1]. So extend the existing
struct xfs_rtgroup_geometry to add a new rg_writepointer field. This field
is valid if XFS_RTGROUP_GEOM_WRITEPOINTER flag is set. The rg_writepointer
field specifies the location of the current writepointer as a sector offset
into the respective rtgroup.
[1] https://lwn.net/Articles/1059364/
Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
---
fs/xfs/libxfs/xfs_fs.h | 6 +++++-
fs/xfs/xfs_ioctl.c | 20 ++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
index d165de607d17..ca63ae67f16c 100644
--- a/fs/xfs/libxfs/xfs_fs.h
+++ b/fs/xfs/libxfs/xfs_fs.h
@@ -995,7 +995,9 @@ struct xfs_rtgroup_geometry {
__u32 rg_sick; /* o: sick things in ag */
__u32 rg_checked; /* o: checked metadata in ag */
__u32 rg_flags; /* i/o: flags for this ag */
- __u32 rg_reserved[27]; /* o: zero */
+ __u32 rg_reserved0; /* o: preserve alignment */
+ __u64 rg_writepointer; /* o: write pointer sector for zoned */
+ __u32 rg_reserved[24]; /* o: zero */
};
#define XFS_RTGROUP_GEOM_SICK_SUPER (1U << 0) /* superblock */
#define XFS_RTGROUP_GEOM_SICK_BITMAP (1U << 1) /* rtbitmap */
@@ -1003,6 +1005,8 @@ struct xfs_rtgroup_geometry {
#define XFS_RTGROUP_GEOM_SICK_RMAPBT (1U << 3) /* reverse mappings */
#define XFS_RTGROUP_GEOM_SICK_REFCNTBT (1U << 4) /* reference counts */
+#define XFS_RTGROUP_GEOM_WRITEPOINTER (1U << 0) /* write pointer */
+
/* Health monitor event domains */
/* affects the whole fs */
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index facffdc8dca8..86bd8fc0c41d 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -37,12 +37,15 @@
#include "xfs_ioctl.h"
#include "xfs_xattr.h"
#include "xfs_rtbitmap.h"
+#include "xfs_rtrmap_btree.h"
#include "xfs_file.h"
#include "xfs_exchrange.h"
#include "xfs_handle.h"
#include "xfs_rtgroup.h"
#include "xfs_healthmon.h"
#include "xfs_verify_media.h"
+#include "xfs_zone_priv.h"
+#include "xfs_zone_alloc.h"
#include <linux/mount.h>
#include <linux/fileattr.h>
@@ -413,6 +416,7 @@ xfs_ioc_rtgroup_geometry(
{
struct xfs_rtgroup *rtg;
struct xfs_rtgroup_geometry rgeo;
+ xfs_rgblock_t highest_rgbno, write_pointer;
int error;
if (copy_from_user(&rgeo, arg, sizeof(rgeo)))
@@ -433,6 +437,22 @@ xfs_ioc_rtgroup_geometry(
if (error)
return error;
+ if (xfs_has_zoned(mp)) {
+ xfs_rtgroup_lock(rtg, XFS_RTGLOCK_RMAP);
+ if (rtg->rtg_open_zone) {
+ write_pointer = rtg->rtg_open_zone->oz_allocated;
+ } else {
+ highest_rgbno = xfs_rtrmap_highest_rgbno(rtg);
+ if (highest_rgbno == NULLRGBLOCK)
+ write_pointer = 0;
+ else
+ write_pointer = highest_rgbno + 1;
+ }
+ xfs_rtgroup_unlock(rtg, XFS_RTGLOCK_RMAP);
+ rgeo.rg_writepointer = XFS_FSB_TO_BB(mp, write_pointer);
+ rgeo.rg_flags |= XFS_RTGROUP_GEOM_WRITEPOINTER;
+ }
+
if (copy_to_user(arg, &rgeo, sizeof(rgeo)))
return -EFAULT;
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] xfs: add write pointer to xfs_rtgroup_geometry
2026-02-27 3:01 [PATCH] xfs: add write pointer to xfs_rtgroup_geometry Wilfred Mallawa
@ 2026-02-27 4:06 ` Darrick J. Wong
2026-02-27 5:16 ` Wilfred Mallawa
0 siblings, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2026-02-27 4:06 UTC (permalink / raw)
To: Wilfred Mallawa
Cc: Carlos Maiolino, linux-xfs, linux-kernel, Christoph Hellwig,
Wilfred Mallawa
On Fri, Feb 27, 2026 at 01:01:06PM +1000, Wilfred Mallawa wrote:
> From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
>
> There is currently no XFS ioctl that allows userspace to retrieve the
> write pointer for a specific realtime group block for zoned XFS. On zoned
> block devices, userspace can obtain this information via zone reports from
> the underlying device. However, for zoned XFS operating on regular block
> devices, no equivalent mechanism exists.
>
> Access to the realtime group write pointer is useful to userspace
> development and analysis tools such as Zonar [1]. So extend the existing
> struct xfs_rtgroup_geometry to add a new rg_writepointer field. This field
> is valid if XFS_RTGROUP_GEOM_WRITEPOINTER flag is set. The rg_writepointer
> field specifies the location of the current writepointer as a sector offset
> into the respective rtgroup.
>
> [1] https://lwn.net/Articles/1059364/
> Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> ---
> fs/xfs/libxfs/xfs_fs.h | 6 +++++-
> fs/xfs/xfs_ioctl.c | 20 ++++++++++++++++++++
> 2 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
> index d165de607d17..ca63ae67f16c 100644
> --- a/fs/xfs/libxfs/xfs_fs.h
> +++ b/fs/xfs/libxfs/xfs_fs.h
> @@ -995,7 +995,9 @@ struct xfs_rtgroup_geometry {
> __u32 rg_sick; /* o: sick things in ag */
> __u32 rg_checked; /* o: checked metadata in ag */
> __u32 rg_flags; /* i/o: flags for this ag */
> - __u32 rg_reserved[27]; /* o: zero */
> + __u32 rg_reserved0; /* o: preserve alignment */
> + __u64 rg_writepointer; /* o: write pointer sector for zoned */
Hrm. It's not possible to advance the write pointer less than a single
xfs fsblock, right? zoned rt requires rt groups, so that means the
write pointer within a rtgroup has to be a xfs_rgblock_t (32bit) value,
so shouldn't this be a __u32 field?
(aside from that, the wp extraction code itself looks reasonable)
--D
> + __u32 rg_reserved[24]; /* o: zero */
> };
> #define XFS_RTGROUP_GEOM_SICK_SUPER (1U << 0) /* superblock */
> #define XFS_RTGROUP_GEOM_SICK_BITMAP (1U << 1) /* rtbitmap */
> @@ -1003,6 +1005,8 @@ struct xfs_rtgroup_geometry {
> #define XFS_RTGROUP_GEOM_SICK_RMAPBT (1U << 3) /* reverse mappings */
> #define XFS_RTGROUP_GEOM_SICK_REFCNTBT (1U << 4) /* reference counts */
>
> +#define XFS_RTGROUP_GEOM_WRITEPOINTER (1U << 0) /* write pointer */
> +
> /* Health monitor event domains */
>
> /* affects the whole fs */
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index facffdc8dca8..86bd8fc0c41d 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -37,12 +37,15 @@
> #include "xfs_ioctl.h"
> #include "xfs_xattr.h"
> #include "xfs_rtbitmap.h"
> +#include "xfs_rtrmap_btree.h"
> #include "xfs_file.h"
> #include "xfs_exchrange.h"
> #include "xfs_handle.h"
> #include "xfs_rtgroup.h"
> #include "xfs_healthmon.h"
> #include "xfs_verify_media.h"
> +#include "xfs_zone_priv.h"
> +#include "xfs_zone_alloc.h"
>
> #include <linux/mount.h>
> #include <linux/fileattr.h>
> @@ -413,6 +416,7 @@ xfs_ioc_rtgroup_geometry(
> {
> struct xfs_rtgroup *rtg;
> struct xfs_rtgroup_geometry rgeo;
> + xfs_rgblock_t highest_rgbno, write_pointer;
> int error;
>
> if (copy_from_user(&rgeo, arg, sizeof(rgeo)))
> @@ -433,6 +437,22 @@ xfs_ioc_rtgroup_geometry(
> if (error)
> return error;
>
> + if (xfs_has_zoned(mp)) {
> + xfs_rtgroup_lock(rtg, XFS_RTGLOCK_RMAP);
> + if (rtg->rtg_open_zone) {
> + write_pointer = rtg->rtg_open_zone->oz_allocated;
> + } else {
> + highest_rgbno = xfs_rtrmap_highest_rgbno(rtg);
> + if (highest_rgbno == NULLRGBLOCK)
> + write_pointer = 0;
> + else
> + write_pointer = highest_rgbno + 1;
> + }
> + xfs_rtgroup_unlock(rtg, XFS_RTGLOCK_RMAP);
> + rgeo.rg_writepointer = XFS_FSB_TO_BB(mp, write_pointer);
> + rgeo.rg_flags |= XFS_RTGROUP_GEOM_WRITEPOINTER;
> + }
> +
> if (copy_to_user(arg, &rgeo, sizeof(rgeo)))
> return -EFAULT;
> return 0;
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] xfs: add write pointer to xfs_rtgroup_geometry
2026-02-27 4:06 ` Darrick J. Wong
@ 2026-02-27 5:16 ` Wilfred Mallawa
2026-02-27 13:52 ` hch
0 siblings, 1 reply; 4+ messages in thread
From: Wilfred Mallawa @ 2026-02-27 5:16 UTC (permalink / raw)
To: djwong@kernel.org
Cc: hch, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
cem@kernel.org
[snip]
> > [1] https://lwn.net/Articles/1059364/
> > Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> > ---
> > fs/xfs/libxfs/xfs_fs.h | 6 +++++-
> > fs/xfs/xfs_ioctl.c | 20 ++++++++++++++++++++
> > 2 files changed, 25 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
> > index d165de607d17..ca63ae67f16c 100644
> > --- a/fs/xfs/libxfs/xfs_fs.h
> > +++ b/fs/xfs/libxfs/xfs_fs.h
> > @@ -995,7 +995,9 @@ struct xfs_rtgroup_geometry {
> > __u32 rg_sick; /* o: sick things in ag */
> > __u32 rg_checked; /* o: checked metadata in ag */
> > __u32 rg_flags; /* i/o: flags for this ag
> > */
> > - __u32 rg_reserved[27]; /* o: zero */
> > + __u32 rg_reserved0; /* o: preserve alignment */
> > + __u64 rg_writepointer; /* o: write pointer sector for
> > zoned */
>
> Hrm. It's not possible to advance the write pointer less than a
> single
> xfs fsblock, right?
I believe so, perhaps Christoph could chime in?
> zoned rt requires rt groups, so that means the
> write pointer within a rtgroup has to be a xfs_rgblock_t (32bit)
> value,
> so shouldn't this be a __u32 field?
I figured since this is currently returning a basic block offset
(similar to a zone report from a zoned device), it *could* exceed a
U32_MAX for larger zones (?). Does it seem more appropriate to return
the xfs fsblock offset here instead?
Wilfred
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] xfs: add write pointer to xfs_rtgroup_geometry
2026-02-27 5:16 ` Wilfred Mallawa
@ 2026-02-27 13:52 ` hch
0 siblings, 0 replies; 4+ messages in thread
From: hch @ 2026-02-27 13:52 UTC (permalink / raw)
To: Wilfred Mallawa
Cc: djwong@kernel.org, hch, linux-xfs@vger.kernel.org,
linux-kernel@vger.kernel.org, cem@kernel.org
On Fri, Feb 27, 2026 at 05:16:39AM +0000, Wilfred Mallawa wrote:
> > > - __u32 rg_reserved[27]; /* o: zero */
> > > + __u32 rg_reserved0; /* o: preserve alignment */
> > > + __u64 rg_writepointer; /* o: write pointer sector for
> > > zoned */
> >
> > Hrm. It's not possible to advance the write pointer less than a
> > single
> > xfs fsblock, right?
>
> I believe so, perhaps Christoph could chime in?
It's not possible.
>
> > zoned rt requires rt groups, so that means the
> > write pointer within a rtgroup has to be a xfs_rgblock_t (32bit)
> > value,
> > so shouldn't this be a __u32 field?
>
> I figured since this is currently returning a basic block offset
> (similar to a zone report from a zoned device), it *could* exceed a
> U32_MAX for larger zones (?). Does it seem more appropriate to return
> the xfs fsblock offset here instead?
No, the count of blocks in a zone is a xfs_rgblock_t, which is a
uint32_t. So all group/zone relative addressing can and should use
32-bit types.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-27 13:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27 3:01 [PATCH] xfs: add write pointer to xfs_rtgroup_geometry Wilfred Mallawa
2026-02-27 4:06 ` Darrick J. Wong
2026-02-27 5:16 ` Wilfred Mallawa
2026-02-27 13:52 ` hch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox