Skip to content

Commit

Permalink
do_mpage_readpage(): don't submit lots of small bios on boundary
Browse files Browse the repository at this point in the history
While tracing I/O patterns with blktrace (a great tool) a few weeks ago I
identified a minor issue in fs/mpage.c

As the comment above mpage_readpages() says, a fs's get_block function
will set BH_Boundary when it maps a block just before a block for which
extra I/O is required.

Since get_block() can map a range of pages, for all these pages the
BH_Boundary flag will be set.  But we only need to push what I/O we have
accumulated at the last block of this range.

This makes do_mpage_readpage() send out the largest possible bio instead
of a bunch of page-sized ones in the BH_Boundary case.

Signed-off-by: Miquel van Smoorenburg <mikevs@xs4all.net>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Miquel van Smoorenburg authored and Linus Torvalds committed Jan 6, 2009
1 parent 75aa199 commit 38c8e61
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/mpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
goto alloc_new;
}

if (buffer_boundary(map_bh) || (first_hole != blocks_per_page))
relative_block = block_in_file - *first_logical_block;
nblocks = map_bh->b_size >> blkbits;
if ((buffer_boundary(map_bh) && relative_block == nblocks) ||
(first_hole != blocks_per_page))
bio = mpage_bio_submit(READ, bio);
else
*last_block_in_bio = blocks[blocks_per_page - 1];
Expand Down

0 comments on commit 38c8e61

Please sign in to comment.