* zoned GC fix v2
@ 2026-07-29 13:02 Christoph Hellwig
2026-07-29 13:02 ` [PATCH 1/2] xfs: add a separate bio_set for spliting GC writes Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Christoph Hellwig @ 2026-07-29 13:02 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: Cc : Hans Holmberg, linux-xfs
Hi Carlos,
this series fixes a potential deadlock in the zoned GC code, and
also adds a comment in the same area while looking at it.
Changes since v1:
- improve a commit log
- improve a code commit
Diffstat:
xfs_zone_gc.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/2] xfs: add a separate bio_set for spliting GC writes 2026-07-29 13:02 zoned GC fix v2 Christoph Hellwig @ 2026-07-29 13:02 ` Christoph Hellwig 2026-07-29 13:02 ` [PATCH 2/2] xfs: add a comment to describe xfs_gc_bio.victim_rtg Christoph Hellwig 2026-08-03 13:22 ` zoned GC fix v2 Carlos Maiolino 2 siblings, 0 replies; 7+ messages in thread From: Christoph Hellwig @ 2026-07-29 13:02 UTC (permalink / raw) To: Carlos Maiolino Cc: Cc : Hans Holmberg, linux-xfs, Damien Le Moal, Darrick J. Wong Allocating the new bio for a split from the same pool as the original one can deadlock under memory pressure as the origin bio could be the last one from the mempool. Add a separate pool for splitting GC write bios to avoid this. Fixes: 080d01c41d44 ("xfs: implement zoned garbage collection") 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_gc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c index f76a09130852..e4f70e024632 100644 --- a/fs/xfs/xfs_zone_gc.c +++ b/fs/xfs/xfs_zone_gc.c @@ -130,6 +130,9 @@ struct xfs_zone_gc_data { /* bioset used to allocate the gc_bios */ struct bio_set bio_set; + /* bioset used when writes need to be split to hardware limits */ + struct bio_set split_bio_set; + /* * Scratchpad to buffer GC data, organized as a ring buffer over * discontiguous folios. scratch_head is where the buffer is filled, @@ -221,6 +224,9 @@ xfs_zone_gc_data_alloc( if (bioset_init(&data->bio_set, 16, offsetof(struct xfs_gc_bio, bio), BIOSET_NEED_BVECS)) goto out_free_recs; + if (bioset_init(&data->split_bio_set, 16, + offsetof(struct xfs_gc_bio, bio), 0)) + goto out_exit_bio_set; for (i = 0; i < XFS_GC_NR_BUFS; i++) { data->scratch_folios[i] = folio_alloc(GFP_KERNEL, get_order(XFS_GC_BUF_SIZE)); @@ -238,6 +244,8 @@ xfs_zone_gc_data_alloc( out_free_scratch: while (--i >= 0) folio_put(data->scratch_folios[i]); + bioset_exit(&data->split_bio_set); +out_exit_bio_set: bioset_exit(&data->bio_set); out_free_recs: kfree(data->iter.recs); @@ -254,6 +262,7 @@ xfs_zone_gc_data_free( for (i = 0; i < XFS_GC_NR_BUFS; i++) folio_put(data->scratch_folios[i]); + bioset_exit(&data->split_bio_set); bioset_exit(&data->bio_set); kfree(data->iter.recs); kfree(data); @@ -810,7 +819,8 @@ xfs_zone_gc_split_write( data->mp->m_sb.sb_blocksize) >> SECTOR_SHIFT; split_len = split_sectors << SECTOR_SHIFT; - split = bio_split(&chunk->bio, split_sectors, GFP_NOFS, &data->bio_set); + split = bio_split(&chunk->bio, split_sectors, GFP_NOFS, + &data->split_bio_set); split_chunk = container_of(split, struct xfs_gc_bio, bio); split_chunk->data = data; ihold(VFS_I(chunk->ip)); -- 2.53.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] xfs: add a comment to describe xfs_gc_bio.victim_rtg 2026-07-29 13:02 zoned GC fix v2 Christoph Hellwig 2026-07-29 13:02 ` [PATCH 1/2] xfs: add a separate bio_set for spliting GC writes Christoph Hellwig @ 2026-07-29 13:02 ` Christoph Hellwig 2026-08-03 13:22 ` zoned GC fix v2 Carlos Maiolino 2 siblings, 0 replies; 7+ messages in thread From: Christoph Hellwig @ 2026-07-29 13:02 UTC (permalink / raw) To: Carlos Maiolino Cc: Cc : Hans Holmberg, linux-xfs, Damien Le Moal, Darrick J. Wong All other fields have comments describing them, add one for this field as well. 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_gc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c index e4f70e024632..7ab8f2218c6a 100644 --- a/fs/xfs/xfs_zone_gc.c +++ b/fs/xfs/xfs_zone_gc.c @@ -103,6 +103,7 @@ struct xfs_gc_bio { /* Open Zone being written to */ struct xfs_open_zone *oz; + /* Realtime group currently being reclaimed */ struct xfs_rtgroup *victim_rtg; /* Bio used for reads and writes, including the bvec used by it */ -- 2.53.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: zoned GC fix v2 2026-07-29 13:02 zoned GC fix v2 Christoph Hellwig 2026-07-29 13:02 ` [PATCH 1/2] xfs: add a separate bio_set for spliting GC writes Christoph Hellwig 2026-07-29 13:02 ` [PATCH 2/2] xfs: add a comment to describe xfs_gc_bio.victim_rtg Christoph Hellwig @ 2026-08-03 13:22 ` Carlos Maiolino 2 siblings, 0 replies; 7+ messages in thread From: Carlos Maiolino @ 2026-08-03 13:22 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Cc : Hans Holmberg, linux-xfs On Wed, 29 Jul 2026 15:02:47 +0200, Christoph Hellwig wrote: > this series fixes a potential deadlock in the zoned GC code, and > also adds a comment in the same area while looking at it. > > Changes since v1: > - improve a commit log > - improve a code commit > > [...] Applied to for-next, thanks! [1/2] xfs: add a separate bio_set for spliting GC writes commit: 63de19199342e2598373cbb99186fa93e9116603 [2/2] xfs: add a comment to describe xfs_gc_bio.victim_rtg commit: ec6978e6bf68fb6f51edd4f700f9a554dc0da894 Best regards, -- Carlos Maiolino <cem@kernel.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* zoned GC fix @ 2026-07-28 8:06 Christoph Hellwig 2026-07-28 8:06 ` [PATCH 1/2] xfs: add a separate bio_set for spliting GC writes Christoph Hellwig 0 siblings, 1 reply; 7+ messages in thread From: Christoph Hellwig @ 2026-07-28 8:06 UTC (permalink / raw) To: Carlos Maiolino; +Cc: Cc : Hans Holmberg, linux-xfs Hi Carlos, this series fixes a potential deadlock in the zoned GC code, and also adds a comment in the same area while looking at it. Diffstat: xfs_zone_gc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] xfs: add a separate bio_set for spliting GC writes 2026-07-28 8:06 zoned GC fix Christoph Hellwig @ 2026-07-28 8:06 ` Christoph Hellwig 2026-07-28 15:27 ` Darrick J. Wong 2026-07-29 4:07 ` Damien Le Moal 0 siblings, 2 replies; 7+ messages in thread From: Christoph Hellwig @ 2026-07-28 8:06 UTC (permalink / raw) To: Carlos Maiolino; +Cc: Cc : Hans Holmberg, linux-xfs Allocating the new bio for a split from the same pool as the original one can deadlock under memory pressure. Add a separate pool for splitting GC write bios to avoid this. Fixes: 080d01c41d44 ("xfs: implement zoned garbage collection") Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/xfs/xfs_zone_gc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c index f76a09130852..e4f70e024632 100644 --- a/fs/xfs/xfs_zone_gc.c +++ b/fs/xfs/xfs_zone_gc.c @@ -130,6 +130,9 @@ struct xfs_zone_gc_data { /* bioset used to allocate the gc_bios */ struct bio_set bio_set; + /* bioset used when writes need to be split to hardware limits */ + struct bio_set split_bio_set; + /* * Scratchpad to buffer GC data, organized as a ring buffer over * discontiguous folios. scratch_head is where the buffer is filled, @@ -221,6 +224,9 @@ xfs_zone_gc_data_alloc( if (bioset_init(&data->bio_set, 16, offsetof(struct xfs_gc_bio, bio), BIOSET_NEED_BVECS)) goto out_free_recs; + if (bioset_init(&data->split_bio_set, 16, + offsetof(struct xfs_gc_bio, bio), 0)) + goto out_exit_bio_set; for (i = 0; i < XFS_GC_NR_BUFS; i++) { data->scratch_folios[i] = folio_alloc(GFP_KERNEL, get_order(XFS_GC_BUF_SIZE)); @@ -238,6 +244,8 @@ xfs_zone_gc_data_alloc( out_free_scratch: while (--i >= 0) folio_put(data->scratch_folios[i]); + bioset_exit(&data->split_bio_set); +out_exit_bio_set: bioset_exit(&data->bio_set); out_free_recs: kfree(data->iter.recs); @@ -254,6 +262,7 @@ xfs_zone_gc_data_free( for (i = 0; i < XFS_GC_NR_BUFS; i++) folio_put(data->scratch_folios[i]); + bioset_exit(&data->split_bio_set); bioset_exit(&data->bio_set); kfree(data->iter.recs); kfree(data); @@ -810,7 +819,8 @@ xfs_zone_gc_split_write( data->mp->m_sb.sb_blocksize) >> SECTOR_SHIFT; split_len = split_sectors << SECTOR_SHIFT; - split = bio_split(&chunk->bio, split_sectors, GFP_NOFS, &data->bio_set); + split = bio_split(&chunk->bio, split_sectors, GFP_NOFS, + &data->split_bio_set); split_chunk = container_of(split, struct xfs_gc_bio, bio); split_chunk->data = data; ihold(VFS_I(chunk->ip)); -- 2.53.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] xfs: add a separate bio_set for spliting GC writes 2026-07-28 8:06 ` [PATCH 1/2] xfs: add a separate bio_set for spliting GC writes Christoph Hellwig @ 2026-07-28 15:27 ` Darrick J. Wong 2026-07-29 4:07 ` Damien Le Moal 1 sibling, 0 replies; 7+ messages in thread From: Darrick J. Wong @ 2026-07-28 15:27 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Carlos Maiolino, Cc : Hans Holmberg, linux-xfs On Tue, Jul 28, 2026 at 10:06:44AM +0200, Christoph Hellwig wrote: > Allocating the new bio for a split from the same pool as the original > one can deadlock under memory pressure. Add a separate pool for > splitting GC write bios to avoid this. > > Fixes: 080d01c41d44 ("xfs: implement zoned garbage collection") > Signed-off-by: Christoph Hellwig <hch@lst.de> Seems fine to me... Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > --- > fs/xfs/xfs_zone_gc.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c > index f76a09130852..e4f70e024632 100644 > --- a/fs/xfs/xfs_zone_gc.c > +++ b/fs/xfs/xfs_zone_gc.c > @@ -130,6 +130,9 @@ struct xfs_zone_gc_data { > /* bioset used to allocate the gc_bios */ > struct bio_set bio_set; > > + /* bioset used when writes need to be split to hardware limits */ > + struct bio_set split_bio_set; > + > /* > * Scratchpad to buffer GC data, organized as a ring buffer over > * discontiguous folios. scratch_head is where the buffer is filled, > @@ -221,6 +224,9 @@ xfs_zone_gc_data_alloc( > if (bioset_init(&data->bio_set, 16, offsetof(struct xfs_gc_bio, bio), > BIOSET_NEED_BVECS)) > goto out_free_recs; > + if (bioset_init(&data->split_bio_set, 16, > + offsetof(struct xfs_gc_bio, bio), 0)) > + goto out_exit_bio_set; > for (i = 0; i < XFS_GC_NR_BUFS; i++) { > data->scratch_folios[i] = > folio_alloc(GFP_KERNEL, get_order(XFS_GC_BUF_SIZE)); > @@ -238,6 +244,8 @@ xfs_zone_gc_data_alloc( > out_free_scratch: > while (--i >= 0) > folio_put(data->scratch_folios[i]); > + bioset_exit(&data->split_bio_set); > +out_exit_bio_set: > bioset_exit(&data->bio_set); > out_free_recs: > kfree(data->iter.recs); > @@ -254,6 +262,7 @@ xfs_zone_gc_data_free( > > for (i = 0; i < XFS_GC_NR_BUFS; i++) > folio_put(data->scratch_folios[i]); > + bioset_exit(&data->split_bio_set); > bioset_exit(&data->bio_set); > kfree(data->iter.recs); > kfree(data); > @@ -810,7 +819,8 @@ xfs_zone_gc_split_write( > data->mp->m_sb.sb_blocksize) >> SECTOR_SHIFT; > split_len = split_sectors << SECTOR_SHIFT; > > - split = bio_split(&chunk->bio, split_sectors, GFP_NOFS, &data->bio_set); > + split = bio_split(&chunk->bio, split_sectors, GFP_NOFS, > + &data->split_bio_set); > split_chunk = container_of(split, struct xfs_gc_bio, bio); > split_chunk->data = data; > ihold(VFS_I(chunk->ip)); > -- > 2.53.0 > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] xfs: add a separate bio_set for spliting GC writes 2026-07-28 8:06 ` [PATCH 1/2] xfs: add a separate bio_set for spliting GC writes Christoph Hellwig 2026-07-28 15:27 ` Darrick J. Wong @ 2026-07-29 4:07 ` Damien Le Moal 1 sibling, 0 replies; 7+ messages in thread From: Damien Le Moal @ 2026-07-29 4:07 UTC (permalink / raw) To: Christoph Hellwig, Carlos Maiolino; +Cc: Cc : Hans Holmberg, linux-xfs On 7/28/26 17:06, Christoph Hellwig wrote: > Allocating the new bio for a split from the same pool as the original > one can deadlock under memory pressure. Add a separate pool for > splitting GC write bios to avoid this. > > Fixes: 080d01c41d44 ("xfs: implement zoned garbage collection") > Signed-off-by: Christoph Hellwig <hch@lst.de> Looks good to me, but the commit message would be better with an explanation of how the deadlock can happen, as I do not think it is that obvious. Regardless, Reviewed-by: Damien Le Moal <dlemoal@kernel.org> -- Damien Le Moal Western Digital Research ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-08-03 13:23 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-29 13:02 zoned GC fix v2 Christoph Hellwig 2026-07-29 13:02 ` [PATCH 1/2] xfs: add a separate bio_set for spliting GC writes Christoph Hellwig 2026-07-29 13:02 ` [PATCH 2/2] xfs: add a comment to describe xfs_gc_bio.victim_rtg Christoph Hellwig 2026-08-03 13:22 ` zoned GC fix v2 Carlos Maiolino -- strict thread matches above, loose matches on Subject: below -- 2026-07-28 8:06 zoned GC fix Christoph Hellwig 2026-07-28 8:06 ` [PATCH 1/2] xfs: add a separate bio_set for spliting GC writes Christoph Hellwig 2026-07-28 15:27 ` Darrick J. Wong 2026-07-29 4:07 ` Damien Le Moal
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.