Linux filesystem development
 help / color / mirror / Atom feed
* [PATCH] iomap: add a separate bio_set for iomap_split_ioend
@ 2026-06-29 12:52 Christoph Hellwig
  2026-06-29 22:58 ` Darrick J. Wong
  2026-06-30 10:59 ` Christian Brauner
  0 siblings, 2 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-06-29 12:52 UTC (permalink / raw)
  To: brauner; +Cc: djwong, linux-xfs, linux-fsdevel

iomap_split_ioend can split bios that already come from
iomap_ioend_bioset and thus deadlock when the bioset is exhausted.

Add a separate bio_set to avoid this deadlock.

Fixes: 5fcbd555d483 ("iomap: split bios to zone append limits in the submission handlers")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/iomap/ioend.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/fs/iomap/ioend.c b/fs/iomap/ioend.c
index 01287f1ae021..2fbcb06f6938 100644
--- a/fs/iomap/ioend.c
+++ b/fs/iomap/ioend.c
@@ -13,6 +13,7 @@
 
 struct bio_set iomap_ioend_bioset;
 EXPORT_SYMBOL_GPL(iomap_ioend_bioset);
+struct bio_set iomap_ioend_split_bioset;
 
 struct iomap_ioend *iomap_init_ioend(struct inode *inode,
 		struct bio *bio, loff_t file_offset, u16 ioend_flags)
@@ -483,7 +484,8 @@ struct iomap_ioend *iomap_split_ioend(struct iomap_ioend *ioend,
 	sector_offset = ALIGN_DOWN(sector_offset << SECTOR_SHIFT,
 			i_blocksize(ioend->io_inode)) >> SECTOR_SHIFT;
 
-	split = bio_split(bio, sector_offset, GFP_NOFS, &iomap_ioend_bioset);
+	split = bio_split(bio, sector_offset, GFP_NOFS,
+			&iomap_ioend_split_bioset);
 	if (IS_ERR(split))
 		return ERR_CAST(split);
 	split->bi_private = bio->bi_private;
@@ -506,8 +508,23 @@ EXPORT_SYMBOL_GPL(iomap_split_ioend);
 
 static int __init iomap_ioend_init(void)
 {
-	return bioset_init(&iomap_ioend_bioset, 4 * (PAGE_SIZE / SECTOR_SIZE),
+	const unsigned int nr_mempool_entries = 4 * (PAGE_SIZE / SECTOR_SIZE);
+	int error;
+
+	error = bioset_init(&iomap_ioend_bioset, nr_mempool_entries,
 			   offsetof(struct iomap_ioend, io_bio),
 			   BIOSET_NEED_BVECS);
+	if (error)
+		return error;
+	error = bioset_init(&iomap_ioend_split_bioset, nr_mempool_entries,
+			   offsetof(struct iomap_ioend, io_bio),
+			   BIOSET_NEED_BVECS);
+	if (error)
+		goto out_exit_ioend_bioset;
+	return 0;
+
+out_exit_ioend_bioset:
+	bioset_exit(&iomap_ioend_bioset);
+	return error;
 }
 fs_initcall(iomap_ioend_init);
-- 
2.53.0


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

* Re: [PATCH] iomap: add a separate bio_set for iomap_split_ioend
  2026-06-29 12:52 [PATCH] iomap: add a separate bio_set for iomap_split_ioend Christoph Hellwig
@ 2026-06-29 22:58 ` Darrick J. Wong
  2026-06-30  5:17   ` Christoph Hellwig
  2026-06-30 10:59 ` Christian Brauner
  1 sibling, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2026-06-29 22:58 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: brauner, linux-xfs, linux-fsdevel

On Mon, Jun 29, 2026 at 02:52:29PM +0200, Christoph Hellwig wrote:
> iomap_split_ioend can split bios that already come from
> iomap_ioend_bioset and thus deadlock when the bioset is exhausted.
> 
> Add a separate bio_set to avoid this deadlock.

What happens if &iomap_ioend_split_bioset is exhausted?  Won't that also
stall the ioend submission?

<confused>

--D

> Fixes: 5fcbd555d483 ("iomap: split bios to zone append limits in the submission handlers")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/iomap/ioend.c | 21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/iomap/ioend.c b/fs/iomap/ioend.c
> index 01287f1ae021..2fbcb06f6938 100644
> --- a/fs/iomap/ioend.c
> +++ b/fs/iomap/ioend.c
> @@ -13,6 +13,7 @@
>  
>  struct bio_set iomap_ioend_bioset;
>  EXPORT_SYMBOL_GPL(iomap_ioend_bioset);
> +struct bio_set iomap_ioend_split_bioset;
>  
>  struct iomap_ioend *iomap_init_ioend(struct inode *inode,
>  		struct bio *bio, loff_t file_offset, u16 ioend_flags)
> @@ -483,7 +484,8 @@ struct iomap_ioend *iomap_split_ioend(struct iomap_ioend *ioend,
>  	sector_offset = ALIGN_DOWN(sector_offset << SECTOR_SHIFT,
>  			i_blocksize(ioend->io_inode)) >> SECTOR_SHIFT;
>  
> -	split = bio_split(bio, sector_offset, GFP_NOFS, &iomap_ioend_bioset);
> +	split = bio_split(bio, sector_offset, GFP_NOFS,
> +			&iomap_ioend_split_bioset);
>  	if (IS_ERR(split))
>  		return ERR_CAST(split);
>  	split->bi_private = bio->bi_private;
> @@ -506,8 +508,23 @@ EXPORT_SYMBOL_GPL(iomap_split_ioend);
>  
>  static int __init iomap_ioend_init(void)
>  {
> -	return bioset_init(&iomap_ioend_bioset, 4 * (PAGE_SIZE / SECTOR_SIZE),
> +	const unsigned int nr_mempool_entries = 4 * (PAGE_SIZE / SECTOR_SIZE);
> +	int error;
> +
> +	error = bioset_init(&iomap_ioend_bioset, nr_mempool_entries,
>  			   offsetof(struct iomap_ioend, io_bio),
>  			   BIOSET_NEED_BVECS);
> +	if (error)
> +		return error;
> +	error = bioset_init(&iomap_ioend_split_bioset, nr_mempool_entries,
> +			   offsetof(struct iomap_ioend, io_bio),
> +			   BIOSET_NEED_BVECS);
> +	if (error)
> +		goto out_exit_ioend_bioset;
> +	return 0;
> +
> +out_exit_ioend_bioset:
> +	bioset_exit(&iomap_ioend_bioset);
> +	return error;
>  }
>  fs_initcall(iomap_ioend_init);
> -- 
> 2.53.0
> 

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

* Re: [PATCH] iomap: add a separate bio_set for iomap_split_ioend
  2026-06-29 22:58 ` Darrick J. Wong
@ 2026-06-30  5:17   ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-06-30  5:17 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Christoph Hellwig, brauner, linux-xfs, linux-fsdevel

On Mon, Jun 29, 2026 at 03:58:31PM -0700, Darrick J. Wong wrote:
> On Mon, Jun 29, 2026 at 02:52:29PM +0200, Christoph Hellwig wrote:
> > iomap_split_ioend can split bios that already come from
> > iomap_ioend_bioset and thus deadlock when the bioset is exhausted.
> > 
> > Add a separate bio_set to avoid this deadlock.
> 
> What happens if &iomap_ioend_split_bioset is exhausted? 

mempool_alloc will block waiting for an ioend to finish.

> Won't that also stall the ioend submission?

Yes, but at least it won't deadlock, unlike the case where we're
waiting for the parent one to finish.  (multiply a few times
as there is more than one entry in the mempool, which is what's
saving our ass in practice)

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

* Re: [PATCH] iomap: add a separate bio_set for iomap_split_ioend
  2026-06-29 12:52 [PATCH] iomap: add a separate bio_set for iomap_split_ioend Christoph Hellwig
  2026-06-29 22:58 ` Darrick J. Wong
@ 2026-06-30 10:59 ` Christian Brauner
  1 sibling, 0 replies; 4+ messages in thread
From: Christian Brauner @ 2026-06-30 10:59 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: djwong, linux-xfs, linux-fsdevel

On Mon, 29 Jun 2026 14:52:29 +0200, Christoph Hellwig wrote:
> iomap: add a separate bio_set for iomap_split_ioend

Applied to the vfs-7.3.iomap branch of the vfs/vfs.git tree.
Patches in the vfs-7.3.iomap branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.3.iomap

[1/1] iomap: add a separate bio_set for iomap_split_ioend
      https://git.kernel.org/vfs/vfs/c/f2727952b21d


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

end of thread, other threads:[~2026-06-30 10:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 12:52 [PATCH] iomap: add a separate bio_set for iomap_split_ioend Christoph Hellwig
2026-06-29 22:58 ` Darrick J. Wong
2026-06-30  5:17   ` Christoph Hellwig
2026-06-30 10:59 ` Christian Brauner

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