* [PATCH 1/3] xfs: factor out a xfs_zone_mark_free helper
2026-06-10 5:07 zoned growfs fix v2 Christoph Hellwig
@ 2026-06-10 5:07 ` Christoph Hellwig
2026-06-10 5:07 ` [PATCH 2/3] xfs: add newly added RTGs to the free pool in growfs Christoph Hellwig
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2026-06-10 5:07 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: Damien Le Moal, Hans Holmberg, linux-xfs, Darrick J. Wong
Add a helper for adding a zone to the free pool in preparation of adding
another caller.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
fs/xfs/xfs_zone_alloc.c | 11 +++++++++--
fs/xfs/xfs_zone_alloc.h | 1 +
fs/xfs/xfs_zone_gc.c | 4 +---
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
index 5e297b75a85f..08d8b34f467e 100644
--- a/fs/xfs/xfs_zone_alloc.c
+++ b/fs/xfs/xfs_zone_alloc.c
@@ -944,6 +944,14 @@ xfs_zone_rgbno_is_valid(
rtg_rgno(rtg), XFS_RTG_FREE);
}
+void
+xfs_zone_mark_free(
+ struct xfs_rtgroup *rtg)
+{
+ xfs_group_set_mark(rtg_group(rtg), XFS_RTG_FREE);
+ atomic_inc(&rtg_mount(rtg)->m_zone_info->zi_nr_free_zones);
+}
+
static void
xfs_free_open_zones(
struct xfs_zone_info *zi)
@@ -1082,8 +1090,7 @@ xfs_init_zone(
if (write_pointer == 0) {
/* zone is empty */
- atomic_inc(&zi->zi_nr_free_zones);
- xfs_group_set_mark(rtg_group(rtg), XFS_RTG_FREE);
+ xfs_zone_mark_free(rtg);
iz->available += rtg_blocks(rtg);
} else if (write_pointer < rtg_blocks(rtg)) {
/* zone is open */
diff --git a/fs/xfs/xfs_zone_alloc.h b/fs/xfs/xfs_zone_alloc.h
index 8b2ef98c81ef..abf8358bb266 100644
--- a/fs/xfs/xfs_zone_alloc.h
+++ b/fs/xfs/xfs_zone_alloc.h
@@ -42,6 +42,7 @@ void xfs_zoned_wake_all(struct xfs_mount *mp);
bool xfs_zone_rgbno_is_valid(struct xfs_rtgroup *rtg, xfs_rgnumber_t rgbno);
void xfs_mark_rtg_boundary(struct iomap_ioend *ioend);
+void xfs_zone_mark_free(struct xfs_rtgroup *rtg);
uint64_t xfs_zoned_default_resblks(struct xfs_mount *mp,
enum xfs_free_counter ctr);
void xfs_zoned_show_stats(struct seq_file *m, struct xfs_mount *mp);
diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c
index f03211e4354a..f76a09130852 100644
--- a/fs/xfs/xfs_zone_gc.c
+++ b/fs/xfs/xfs_zone_gc.c
@@ -924,9 +924,7 @@ xfs_zone_gc_finish_reset(
goto out;
}
- xfs_group_set_mark(rtg_group(rtg), XFS_RTG_FREE);
- atomic_inc(&zi->zi_nr_free_zones);
-
+ xfs_zone_mark_free(rtg);
xfs_zoned_add_available(mp, rtg_blocks(rtg));
wake_up_all(&zi->zi_zone_wait);
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 2/3] xfs: add newly added RTGs to the free pool in growfs
2026-06-10 5:07 zoned growfs fix v2 Christoph Hellwig
2026-06-10 5:07 ` [PATCH 1/3] xfs: factor out a xfs_zone_mark_free helper Christoph Hellwig
@ 2026-06-10 5:07 ` Christoph Hellwig
2026-06-10 5:07 ` [PATCH 3/3] xfs: only log freed extents for the current RTG in zoned growfs Christoph Hellwig
2026-06-10 15:37 ` zoned growfs fix v2 Carlos Maiolino
3 siblings, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2026-06-10 5:07 UTC (permalink / raw)
To: Carlos Maiolino
Cc: Damien Le Moal, Hans Holmberg, linux-xfs, stable, Darrick J. Wong
When growing a zoned RT section, the newly added RTGs also need to be
tagged as free in the radix tree and add to the nr_free_zones counters.
Call xfs_add_free_zone to do that, otherwise using up the newly added
space will wait for free zones forever.
Fixes: 01b71e64bb87 ("xfs: support growfs on zoned file systems")
Cc: <stable@vger.kernel.org> # v6.15
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_rtalloc.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 153f3c378f9f..debbcefdf07f 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -933,6 +933,14 @@ xfs_growfs_rt_zoned(
mp->m_features |= XFS_FEAT_REALTIME;
xfs_rtrmapbt_compute_maxlevels(mp);
xfs_rtrefcountbt_compute_maxlevels(mp);
+
+ /*
+ * Finally add the newly added zone to the freelist and add the space
+ * to the available counter. The order is important here: only add
+ * the available space after the zones, as available space guarantees
+ * that zones to back it are available.
+ */
+ xfs_zone_mark_free(rtg);
xfs_zoned_add_available(mp, freed_rtx);
out_free:
kfree(nmp);
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 3/3] xfs: only log freed extents for the current RTG in zoned growfs
2026-06-10 5:07 zoned growfs fix v2 Christoph Hellwig
2026-06-10 5:07 ` [PATCH 1/3] xfs: factor out a xfs_zone_mark_free helper Christoph Hellwig
2026-06-10 5:07 ` [PATCH 2/3] xfs: add newly added RTGs to the free pool in growfs Christoph Hellwig
@ 2026-06-10 5:07 ` Christoph Hellwig
2026-06-10 5:12 ` Darrick J. Wong
2026-06-10 9:15 ` Damien Le Moal
2026-06-10 15:37 ` zoned growfs fix v2 Carlos Maiolino
3 siblings, 2 replies; 11+ messages in thread
From: Christoph Hellwig @ 2026-06-10 5:07 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: Damien Le Moal, Hans Holmberg, linux-xfs
Otherwise a power fail or crash during growfs could lead to an
elevated sb_rblocks counter.
Note that the step function is much simpler compared to the classic RT
allocator as zoned RT sections must be aligned to real time group
boundaries.
Fixes: 01b71e64bb87 ("xfs: support growfs on zoned file systems")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_rtalloc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index debbcefdf07f..7a3f97686989 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -890,8 +890,7 @@ xfs_growfs_rt_sb_fields(
static int
xfs_growfs_rt_zoned(
- struct xfs_rtgroup *rtg,
- xfs_rfsblock_t nrblocks)
+ struct xfs_rtgroup *rtg)
{
struct xfs_mount *mp = rtg_mount(rtg);
struct xfs_mount *nmp;
@@ -903,7 +902,8 @@ xfs_growfs_rt_zoned(
* Calculate new sb and mount fields for this round. Also ensure the
* rtg_extents value is uptodate as the rtbitmap code relies on it.
*/
- nmp = xfs_growfs_rt_alloc_fake_mount(mp, nrblocks,
+ nmp = xfs_growfs_rt_alloc_fake_mount(mp,
+ xfs_rtgs_to_rfsbs(mp, rtg_rgno(rtg) + 1),
mp->m_sb.sb_rextsize);
if (!nmp)
return -ENOMEM;
@@ -1226,7 +1226,7 @@ xfs_growfs_rtg(
}
if (xfs_has_zoned(mp)) {
- error = xfs_growfs_rt_zoned(rtg, nrblocks);
+ error = xfs_growfs_rt_zoned(rtg);
goto out_rele;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH 3/3] xfs: only log freed extents for the current RTG in zoned growfs
2026-06-10 5:07 ` [PATCH 3/3] xfs: only log freed extents for the current RTG in zoned growfs Christoph Hellwig
@ 2026-06-10 5:12 ` Darrick J. Wong
2026-06-10 5:18 ` Christoph Hellwig
2026-06-10 9:15 ` Damien Le Moal
1 sibling, 1 reply; 11+ messages in thread
From: Darrick J. Wong @ 2026-06-10 5:12 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Carlos Maiolino, Damien Le Moal, Hans Holmberg, linux-xfs
On Wed, Jun 10, 2026 at 07:07:21AM +0200, Christoph Hellwig wrote:
> Otherwise a power fail or crash during growfs could lead to an
> elevated sb_rblocks counter.
>
> Note that the step function is much simpler compared to the classic RT
> allocator as zoned RT sections must be aligned to real time group
> boundaries.
>
> Fixes: 01b71e64bb87 ("xfs: support growfs on zoned file systems")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/xfs/xfs_rtalloc.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index debbcefdf07f..7a3f97686989 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -890,8 +890,7 @@ xfs_growfs_rt_sb_fields(
>
> static int
> xfs_growfs_rt_zoned(
> - struct xfs_rtgroup *rtg,
> - xfs_rfsblock_t nrblocks)
> + struct xfs_rtgroup *rtg)
> {
> struct xfs_mount *mp = rtg_mount(rtg);
> struct xfs_mount *nmp;
> @@ -903,7 +902,8 @@ xfs_growfs_rt_zoned(
> * Calculate new sb and mount fields for this round. Also ensure the
> * rtg_extents value is uptodate as the rtbitmap code relies on it.
> */
> - nmp = xfs_growfs_rt_alloc_fake_mount(mp, nrblocks,
> + nmp = xfs_growfs_rt_alloc_fake_mount(mp,
> + xfs_rtgs_to_rfsbs(mp, rtg_rgno(rtg) + 1),
Heh, I forgot we had a helper for this!
Cc: <stable@vger.kernel.org> # v6.15
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> mp->m_sb.sb_rextsize);
> if (!nmp)
> return -ENOMEM;
> @@ -1226,7 +1226,7 @@ xfs_growfs_rtg(
> }
>
> if (xfs_has_zoned(mp)) {
> - error = xfs_growfs_rt_zoned(rtg, nrblocks);
> + error = xfs_growfs_rt_zoned(rtg);
> goto out_rele;
> }
>
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 3/3] xfs: only log freed extents for the current RTG in zoned growfs
2026-06-10 5:12 ` Darrick J. Wong
@ 2026-06-10 5:18 ` Christoph Hellwig
0 siblings, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2026-06-10 5:18 UTC (permalink / raw)
To: Darrick J. Wong
Cc: Christoph Hellwig, Carlos Maiolino, Damien Le Moal, Hans Holmberg,
linux-xfs
On Tue, Jun 09, 2026 at 10:12:18PM -0700, Darrick J. Wong wrote:
> > - nmp = xfs_growfs_rt_alloc_fake_mount(mp, nrblocks,
> > + nmp = xfs_growfs_rt_alloc_fake_mount(mp,
> > + xfs_rtgs_to_rfsbs(mp, rtg_rgno(rtg) + 1),
>
> Heh, I forgot we had a helper for this!
Yeah, if only the person who added it would remember to consistently use
it..
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] xfs: only log freed extents for the current RTG in zoned growfs
2026-06-10 5:07 ` [PATCH 3/3] xfs: only log freed extents for the current RTG in zoned growfs Christoph Hellwig
2026-06-10 5:12 ` Darrick J. Wong
@ 2026-06-10 9:15 ` Damien Le Moal
1 sibling, 0 replies; 11+ messages in thread
From: Damien Le Moal @ 2026-06-10 9:15 UTC (permalink / raw)
To: Christoph Hellwig, Carlos Maiolino; +Cc: Hans Holmberg, linux-xfs
On 2026/06/10 13:07, Christoph Hellwig wrote:
> Otherwise a power fail or crash during growfs could lead to an
> elevated sb_rblocks counter.
>
> Note that the step function is much simpler compared to the classic RT
> allocator as zoned RT sections must be aligned to real time group
> boundaries.
>
> Fixes: 01b71e64bb87 ("xfs: support growfs on zoned file systems")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: zoned growfs fix v2
2026-06-10 5:07 zoned growfs fix v2 Christoph Hellwig
` (2 preceding siblings ...)
2026-06-10 5:07 ` [PATCH 3/3] xfs: only log freed extents for the current RTG in zoned growfs Christoph Hellwig
@ 2026-06-10 15:37 ` Carlos Maiolino
3 siblings, 0 replies; 11+ messages in thread
From: Carlos Maiolino @ 2026-06-10 15:37 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Damien Le Moal, Hans Holmberg, linux-xfs
On Wed, 10 Jun 2026 07:07:18 +0200, Christoph Hellwig wrote:
> this series fixes growfs on zoned file systems, which so far has been
> completely broken. A test to verify it properly will be sent out as
> well.
>
> Changes since v1:
> - rename xfs_add_free_zone to xfs_zone_mark_free
> - use xfs_rtgs_to_rfsbs to avoid overflows
> - improve a commit message
> - add a comment explaining the zoned growfs space accounting logic
>
> [...]
Applied to for-next, thanks!
[1/3] xfs: factor out a xfs_zone_mark_free helper
commit: 16fc9d358d12e6e9cc553162b4064ad58e7fa869
[2/3] xfs: add newly added RTGs to the free pool in growfs
commit: ae3692c7f440c1ff577aae1a51202415ec4a794b
[3/3] xfs: only log freed extents for the current RTG in zoned growfs
commit: 44cccefe65749821d9a13523c8b763bf1262ef73
Best regards,
--
Carlos Maiolino <cem@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread