diff mbox series

[5/7] iomap: limit buffered I/O size to 128M

Message ID 20250203094322.1809766-6-hch@lst.de (mailing list archive)
State New
Headers show
Series [1/7] block: support integrity generation and verification from file systems | expand

Commit Message

Christoph Hellwig Feb. 3, 2025, 9:43 a.m. UTC
Currently iomap can build extremely large bios (I've seen sizes
up to 480MB).  Limit this to a lower bound so that the soon to
be added per-ioend integrity buffer doesn't go beyond what the
page allocator can support.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/iomap/buffered-io.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Darrick J. Wong Feb. 3, 2025, 10:22 p.m. UTC | #1
On Mon, Feb 03, 2025 at 10:43:09AM +0100, Christoph Hellwig wrote:
> Currently iomap can build extremely large bios (I've seen sizes
> up to 480MB).  Limit this to a lower bound so that the soon to
> be added per-ioend integrity buffer doesn't go beyond what the
> page allocator can support.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/iomap/buffered-io.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 06990e012884..71bb676d4998 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -456,6 +456,7 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter,
>  	sector = iomap_sector(iomap, pos);
>  	if (!ctx->bio ||
>  	    bio_end_sector(ctx->bio) != sector ||
> +	    ctx->bio->bi_iter.bi_size > SZ_128M ||

I imagine this is one of the XXX parts, but we probably shouldn't limit
the bios for !pi filesystems that won't care.

--D

>  	    !bio_add_folio(ctx->bio, folio, plen, poff)) {
>  		if (ctx->bio)
>  			iomap_read_submit_bio(iter, ctx);
> @@ -1674,6 +1675,8 @@ static struct iomap_ioend *iomap_alloc_ioend(struct iomap_writepage_ctx *wpc,
>  static bool iomap_can_add_to_ioend(struct iomap_writepage_ctx *wpc, loff_t pos,
>  		u16 ioend_flags)
>  {
> +	if (wpc->ioend->io_bio.bi_iter.bi_size > SZ_128M)
> +		return false;
>  	if (ioend_flags & IOMAP_IOEND_BOUNDARY)
>  		return false;
>  	if ((ioend_flags & IOMAP_IOEND_NOMERGE_FLAGS) !=
> -- 
> 2.45.2
> 
>
diff mbox series

Patch

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 06990e012884..71bb676d4998 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -456,6 +456,7 @@  static loff_t iomap_readpage_iter(const struct iomap_iter *iter,
 	sector = iomap_sector(iomap, pos);
 	if (!ctx->bio ||
 	    bio_end_sector(ctx->bio) != sector ||
+	    ctx->bio->bi_iter.bi_size > SZ_128M ||
 	    !bio_add_folio(ctx->bio, folio, plen, poff)) {
 		if (ctx->bio)
 			iomap_read_submit_bio(iter, ctx);
@@ -1674,6 +1675,8 @@  static struct iomap_ioend *iomap_alloc_ioend(struct iomap_writepage_ctx *wpc,
 static bool iomap_can_add_to_ioend(struct iomap_writepage_ctx *wpc, loff_t pos,
 		u16 ioend_flags)
 {
+	if (wpc->ioend->io_bio.bi_iter.bi_size > SZ_128M)
+		return false;
 	if (ioend_flags & IOMAP_IOEND_BOUNDARY)
 		return false;
 	if ((ioend_flags & IOMAP_IOEND_NOMERGE_FLAGS) !=