Linux XFS filesystem development
 help / color / mirror / Atom feed
* [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.1
@ 2026-05-07 22:11 Darrick J. Wong
  2026-05-07 22:12 ` [PATCH 1/2] xfs: add write pointer to xfs_rtgroup_geometry Darrick J. Wong
  2026-05-07 22:12 ` [PATCH 2/2] xfs: switch (back) to a per-buftarg buffer hash Darrick J. Wong
  0 siblings, 2 replies; 4+ messages in thread
From: Darrick J. Wong @ 2026-05-07 22:11 UTC (permalink / raw)
  To: aalbersh, djwong
  Cc: hch, syzbot+0391d34e801643e2809b, bfoster, cem, wilfred.mallawa,
	linux-xfs

Hi all,

This series ports kernel libxfs code to userspace from 7.1-rc2.

If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.

With a bit of luck, this should all go splendidly.
Comments and questions are, as always, welcome.

--D

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=libxfs-7.1-sync
---
Commits in this patchset:
 * xfs: add write pointer to xfs_rtgroup_geometry
 * xfs: switch (back) to a per-buftarg buffer hash
---
 libxfs/xfs_ag.h |    2 --
 libxfs/xfs_fs.h |    5 ++++-
 libxfs/xfs_ag.c |   13 ++-----------
 3 files changed, 6 insertions(+), 14 deletions(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] xfs: add write pointer to xfs_rtgroup_geometry
  2026-05-07 22:11 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.1 Darrick J. Wong
@ 2026-05-07 22:12 ` Darrick J. Wong
  2026-05-08  8:57   ` Christoph Hellwig
  2026-05-07 22:12 ` [PATCH 2/2] xfs: switch (back) to a per-buftarg buffer hash Darrick J. Wong
  1 sibling, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2026-05-07 22:12 UTC (permalink / raw)
  To: aalbersh, djwong; +Cc: cem, hch, wilfred.mallawa, linux-xfs

From: Wilfred Mallawa <wilfred.mallawa@wdc.com>

Source kernel commit: c6ce65cb17aa9321687d1b8a842487f839e1a548

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 block offset
into the respective rtgroup.

[1] https://lwn.net/Articles/1059364/

Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
---
 libxfs/xfs_fs.h |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)


diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h
index d165de607d179e..185f09f327c00c 100644
--- a/libxfs/xfs_fs.h
+++ b/libxfs/xfs_fs.h
@@ -995,7 +995,8 @@ 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_writepointer;  /* o: write pointer block offset for zoned */
+	__u32 rg_reserved[26];	/* o: zero */
 };
 #define XFS_RTGROUP_GEOM_SICK_SUPER	(1U << 0)  /* superblock */
 #define XFS_RTGROUP_GEOM_SICK_BITMAP	(1U << 1)  /* rtbitmap */
@@ -1003,6 +1004,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 */


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] xfs: switch (back) to a per-buftarg buffer hash
  2026-05-07 22:11 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.1 Darrick J. Wong
  2026-05-07 22:12 ` [PATCH 1/2] xfs: add write pointer to xfs_rtgroup_geometry Darrick J. Wong
@ 2026-05-07 22:12 ` Darrick J. Wong
  1 sibling, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2026-05-07 22:12 UTC (permalink / raw)
  To: aalbersh, djwong
  Cc: bfoster, cem, hch, syzbot+0391d34e801643e2809b, linux-xfs

From: Christoph Hellwig <hch@lst.de>

Source kernel commit: 497560b9ef42a4ab22ada7f1ea975a89cd3c5dfa

The per-AG buffer hashes were added when all buffer lookups took a
per-hash look.  Since then we've made lookups entirely lockless and
removed the need for a hash-wide lock for inserts and removals as
well.  With this there is no need to sharding the hash, so reduce the
used resources by using a per-buftarg hash for all buftargs.

Long after writing this initially, syzbot found a problem in the buffer
cache teardown order, which this happens to fix as well by doing the
entire buffer cache teardown in one places instead of splitting it
between destroying the buftarg and the perag structures.

Link: https://lore.kernel.org/linux-xfs/aLeUdemAZ5wmtZel@dread.disaster.area/
Reported-by: syzbot+0391d34e801643e2809b@syzkaller.appspotmail.com
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Tested-by: syzbot+0391d34e801643e2809b@syzkaller.appspotmail.com
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
---
 libxfs/xfs_ag.h |    2 --
 libxfs/xfs_ag.c |   13 ++-----------
 2 files changed, 2 insertions(+), 13 deletions(-)


diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h
index 3cd4790768ff91..16a9b43a3c270c 100644
--- a/libxfs/xfs_ag.h
+++ b/libxfs/xfs_ag.h
@@ -85,8 +85,6 @@ struct xfs_perag {
 	int		pag_ici_reclaimable;	/* reclaimable inodes */
 	unsigned long	pag_ici_reclaim_cursor;	/* reclaim restart point */
 
-	struct xfs_buf_cache	pag_bcache;
-
 	/* background prealloc block trimming */
 	struct delayed_work	pag_blockgc_work;
 #endif /* __KERNEL__ */
diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c
index fd5f902b052435..1c75ef51056789 100644
--- a/libxfs/xfs_ag.c
+++ b/libxfs/xfs_ag.c
@@ -108,10 +108,7 @@ xfs_perag_uninit(
 	struct xfs_group	*xg)
 {
 #ifdef __KERNEL__
-	struct xfs_perag	*pag = to_perag(xg);
-
-	cancel_delayed_work_sync(&pag->pag_blockgc_work);
-	xfs_buf_cache_destroy(&pag->pag_bcache);
+	cancel_delayed_work_sync(&to_perag(xg)->pag_blockgc_work);
 #endif
 }
 
@@ -233,10 +230,6 @@ xfs_perag_alloc(
 	INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC);
 #endif /* __KERNEL__ */
 
-	error = xfs_buf_cache_init(&pag->pag_bcache);
-	if (error)
-		goto out_free_perag;
-
 	/*
 	 * Pre-calculated geometry
 	 */
@@ -248,12 +241,10 @@ xfs_perag_alloc(
 
 	error = xfs_group_insert(mp, pag_group(pag), index, XG_TYPE_AG);
 	if (error)
-		goto out_buf_cache_destroy;
+		goto out_free_perag;
 
 	return 0;
 
-out_buf_cache_destroy:
-	xfs_buf_cache_destroy(&pag->pag_bcache);
 out_free_perag:
 	kfree(pag);
 	return error;


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] xfs: add write pointer to xfs_rtgroup_geometry
  2026-05-07 22:12 ` [PATCH 1/2] xfs: add write pointer to xfs_rtgroup_geometry Darrick J. Wong
@ 2026-05-08  8:57   ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-05-08  8:57 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: aalbersh, cem, wilfred.mallawa, linux-xfs

Not sure if this should on it's own or with Wilfred's series to document
it and make us in xfs_io?

If the former, maybe Wilfred needs to resend on top of this series?

On Thu, May 07, 2026 at 03:12:14PM -0700, Darrick J. Wong wrote:
> From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> 
> Source kernel commit: c6ce65cb17aa9321687d1b8a842487f839e1a548
> 
> 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 block offset
> into the respective rtgroup.
> 
> [1] https://lwn.net/Articles/1059364/
> 
> Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Carlos Maiolino <cem@kernel.org>
> ---
>  libxfs/xfs_fs.h |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h
> index d165de607d179e..185f09f327c00c 100644
> --- a/libxfs/xfs_fs.h
> +++ b/libxfs/xfs_fs.h
> @@ -995,7 +995,8 @@ 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_writepointer;  /* o: write pointer block offset for zoned */
> +	__u32 rg_reserved[26];	/* o: zero */
>  };
>  #define XFS_RTGROUP_GEOM_SICK_SUPER	(1U << 0)  /* superblock */
>  #define XFS_RTGROUP_GEOM_SICK_BITMAP	(1U << 1)  /* rtbitmap */
> @@ -1003,6 +1004,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 */
> 
> 
---end quoted text---

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-08  8:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 22:11 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.1 Darrick J. Wong
2026-05-07 22:12 ` [PATCH 1/2] xfs: add write pointer to xfs_rtgroup_geometry Darrick J. Wong
2026-05-08  8:57   ` Christoph Hellwig
2026-05-07 22:12 ` [PATCH 2/2] xfs: switch (back) to a per-buftarg buffer hash Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox