All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iomap: Submit BIOs at the end of each extent
@ 2020-03-19 15:07 Matthew Wilcox
  2020-03-19 15:18 ` Darrick J. Wong
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Wilcox @ 2020-03-19 15:07 UTC (permalink / raw)
  To: linux-fsdevel, linux-xfs, Darrick J. Wong, Christoph Hellwig,
	Jan Kara, Ritesh Harjani, Dave Chinner
  Cc: Matthew Wilcox (Oracle)

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

By definition, an extent covers a range of consecutive blocks, so
it would be quite rare to be able to just add pages to the BIO from
a previous range.  The only case we can think of is a mapped extent
followed by a hole extent, followed by another mapped extent which has
been allocated immediately after the first extent.  We believe this to
be an unlikely layout for a filesystem to choose and, since the queue
is plugged, those two BIOs would be merged by the block layer.

The reason we care is that ext2/ext4 choose to lay out blocks 0-11
consecutively, followed by the indirect block, and we want to merge those
two BIOs.  If we don't submit the data BIO before asking the filesystem
for the next extent, then the indirect BIO will be submitted first,
and waited for, leading to inefficient I/O patterns.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/iomap/buffered-io.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 83438b3257de..8d26920ddf00 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -388,6 +388,11 @@ iomap_readahead_actor(struct inode *inode, loff_t pos, loff_t length,
 				ctx, iomap, srcmap);
 	}
 
+	if (ctx->bio) {
+		submit_bio(ctx->bio);
+		ctx->bio = NULL;
+	}
+
 	return done;
 }
 
-- 
2.25.1


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

* Re: [PATCH] iomap: Submit BIOs at the end of each extent
  2020-03-19 15:07 [PATCH] iomap: Submit BIOs at the end of each extent Matthew Wilcox
@ 2020-03-19 15:18 ` Darrick J. Wong
  2020-03-19 19:06   ` Matthew Wilcox
  0 siblings, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2020-03-19 15:18 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: linux-fsdevel, linux-xfs, Christoph Hellwig, Jan Kara,
	Ritesh Harjani, Dave Chinner

On Thu, Mar 19, 2020 at 08:07:20AM -0700, Matthew Wilcox wrote:
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> 
> By definition, an extent covers a range of consecutive blocks, so
> it would be quite rare to be able to just add pages to the BIO from
> a previous range.  The only case we can think of is a mapped extent
> followed by a hole extent, followed by another mapped extent which has
> been allocated immediately after the first extent.  We believe this to

Well... userspace can induce that with fallocate(INSERT_RANGE). :)

> be an unlikely layout for a filesystem to choose and, since the queue
> is plugged, those two BIOs would be merged by the block layer.
> 
> The reason we care is that ext2/ext4 choose to lay out blocks 0-11
> consecutively, followed by the indirect block, and we want to merge those
> two BIOs.  If we don't submit the data BIO before asking the filesystem
> for the next extent, then the indirect BIO will be submitted first,
> and waited for, leading to inefficient I/O patterns.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  fs/iomap/buffered-io.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 83438b3257de..8d26920ddf00 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -388,6 +388,11 @@ iomap_readahead_actor(struct inode *inode, loff_t pos, loff_t length,
>  				ctx, iomap, srcmap);
>  	}
>  
> +	if (ctx->bio) {
> +		submit_bio(ctx->bio);
> +		ctx->bio = NULL;
> +	}

Makes sense, but could we have a quick comment here to capture why we're
submitting the bio here?

/*
 * Submit the bio now so that we neither combine IO requests for
 * non-adjacent ranges nor interleave data and metadata requests.
 */

--D

> +
>  	return done;
>  }
>  
> -- 
> 2.25.1
> 

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

* Re: [PATCH] iomap: Submit BIOs at the end of each extent
  2020-03-19 15:18 ` Darrick J. Wong
@ 2020-03-19 19:06   ` Matthew Wilcox
  2020-03-19 19:08     ` Darrick J. Wong
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Wilcox @ 2020-03-19 19:06 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: linux-fsdevel, linux-xfs, Christoph Hellwig, Jan Kara,
	Ritesh Harjani, Dave Chinner

On Thu, Mar 19, 2020 at 08:18:19AM -0700, Darrick J. Wong wrote:
> On Thu, Mar 19, 2020 at 08:07:20AM -0700, Matthew Wilcox wrote:
> > From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> > 
> > By definition, an extent covers a range of consecutive blocks, so
> > it would be quite rare to be able to just add pages to the BIO from
> > a previous range.  The only case we can think of is a mapped extent
> > followed by a hole extent, followed by another mapped extent which has
> > been allocated immediately after the first extent.  We believe this to
> 
> Well... userspace can induce that with fallocate(INSERT_RANGE). :)

It's not impossible, of course ... just unlikely.  Nobody actually uses
INSERT_RANGE anyway.

> > be an unlikely layout for a filesystem to choose and, since the queue
> > is plugged, those two BIOs would be merged by the block layer.
> > 
> > The reason we care is that ext2/ext4 choose to lay out blocks 0-11
> > consecutively, followed by the indirect block, and we want to merge those
> > two BIOs.  If we don't submit the data BIO before asking the filesystem
> > for the next extent, then the indirect BIO will be submitted first,
> > and waited for, leading to inefficient I/O patterns.
> > 
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> > ---
> >  fs/iomap/buffered-io.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> > index 83438b3257de..8d26920ddf00 100644
> > --- a/fs/iomap/buffered-io.c
> > +++ b/fs/iomap/buffered-io.c
> > @@ -388,6 +388,11 @@ iomap_readahead_actor(struct inode *inode, loff_t pos, loff_t length,
> >  				ctx, iomap, srcmap);
> >  	}
> >  
> > +	if (ctx->bio) {
> > +		submit_bio(ctx->bio);
> > +		ctx->bio = NULL;
> > +	}
> 
> Makes sense, but could we have a quick comment here to capture why we're
> submitting the bio here?
> 
> /*
>  * Submit the bio now so that we neither combine IO requests for
>  * non-adjacent ranges nor interleave data and metadata requests.
>  */

How about:

         * Submitting the bio here leads to better I/O patterns for
         * filesystems which need to do metadata reads to find the
         * next range.

I also realised we can add:

@@ -454,8 +459,6 @@ iomap_readpages(struct address_space *mapping, struct list_head *pages,
        }
        ret = 0;
 done:
-       if (ctx.bio)
-               submit_bio(ctx.bio);
        if (ctx.cur_page) {
                if (!ctx.cur_page_in_bio)
                        unlock_page(ctx.cur_page);

since we always subit the bio in readpages_actor.

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

* Re: [PATCH] iomap: Submit BIOs at the end of each extent
  2020-03-19 19:06   ` Matthew Wilcox
@ 2020-03-19 19:08     ` Darrick J. Wong
  0 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2020-03-19 19:08 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: linux-fsdevel, linux-xfs, Christoph Hellwig, Jan Kara,
	Ritesh Harjani, Dave Chinner

On Thu, Mar 19, 2020 at 12:06:46PM -0700, Matthew Wilcox wrote:
> On Thu, Mar 19, 2020 at 08:18:19AM -0700, Darrick J. Wong wrote:
> > On Thu, Mar 19, 2020 at 08:07:20AM -0700, Matthew Wilcox wrote:
> > > From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> > > 
> > > By definition, an extent covers a range of consecutive blocks, so
> > > it would be quite rare to be able to just add pages to the BIO from
> > > a previous range.  The only case we can think of is a mapped extent
> > > followed by a hole extent, followed by another mapped extent which has
> > > been allocated immediately after the first extent.  We believe this to
> > 
> > Well... userspace can induce that with fallocate(INSERT_RANGE). :)
> 
> It's not impossible, of course ... just unlikely.  Nobody actually uses
> INSERT_RANGE anyway.
> 
> > > be an unlikely layout for a filesystem to choose and, since the queue
> > > is plugged, those two BIOs would be merged by the block layer.
> > > 
> > > The reason we care is that ext2/ext4 choose to lay out blocks 0-11
> > > consecutively, followed by the indirect block, and we want to merge those
> > > two BIOs.  If we don't submit the data BIO before asking the filesystem
> > > for the next extent, then the indirect BIO will be submitted first,
> > > and waited for, leading to inefficient I/O patterns.
> > > 
> > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> > > ---
> > >  fs/iomap/buffered-io.c | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > > 
> > > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> > > index 83438b3257de..8d26920ddf00 100644
> > > --- a/fs/iomap/buffered-io.c
> > > +++ b/fs/iomap/buffered-io.c
> > > @@ -388,6 +388,11 @@ iomap_readahead_actor(struct inode *inode, loff_t pos, loff_t length,
> > >  				ctx, iomap, srcmap);
> > >  	}
> > >  
> > > +	if (ctx->bio) {
> > > +		submit_bio(ctx->bio);
> > > +		ctx->bio = NULL;
> > > +	}
> > 
> > Makes sense, but could we have a quick comment here to capture why we're
> > submitting the bio here?
> > 
> > /*
> >  * Submit the bio now so that we neither combine IO requests for
> >  * non-adjacent ranges nor interleave data and metadata requests.
> >  */
> 
> How about:
> 
>          * Submitting the bio here leads to better I/O patterns for
>          * filesystems which need to do metadata reads to find the
>          * next range.

Oooh I like your version better.

> I also realised we can add:
> 
> @@ -454,8 +459,6 @@ iomap_readpages(struct address_space *mapping, struct list_head *pages,
>         }
>         ret = 0;
>  done:
> -       if (ctx.bio)
> -               submit_bio(ctx.bio);
>         if (ctx.cur_page) {
>                 if (!ctx.cur_page_in_bio)
>                         unlock_page(ctx.cur_page);
> 
> since we always subit the bio in readpages_actor.

<nod> I'll keep an eye out for v2. :)

--D

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

end of thread, other threads:[~2020-03-19 19:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 15:07 [PATCH] iomap: Submit BIOs at the end of each extent Matthew Wilcox
2020-03-19 15:18 ` Darrick J. Wong
2020-03-19 19:06   ` Matthew Wilcox
2020-03-19 19:08     ` Darrick J. Wong

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.