From: Jens Axboe <axboe@kernel.dk>
To: linux-fsdevel@vger.kernel.org
Cc: viro@zeniv.linux.org.uk, akpm@linux-foundation.org,
Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 1/3] mpage: mpage_readpages() should submit IO as read-ahead
Date: Thu, 24 May 2018 10:02:52 -0600 [thread overview]
Message-ID: <1527177774-21414-2-git-send-email-axboe@kernel.dk> (raw)
In-Reply-To: <1527177774-21414-1-git-send-email-axboe@kernel.dk>
a_ops->readpages() is only ever used for read-ahead, yet we don't
flag the IO being submitted as such. Fix that up. Any file system
that uses mpage_readpages() as it's ->readpages() implementation
will now get this right.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
fs/mpage.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/fs/mpage.c b/fs/mpage.c
index b7e7f570733a..0a5474237f5e 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -146,7 +146,7 @@ static struct bio *
do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
sector_t *last_block_in_bio, struct buffer_head *map_bh,
unsigned long *first_logical_block, get_block_t get_block,
- gfp_t gfp)
+ gfp_t gfp, bool is_readahead)
{
struct inode *inode = page->mapping->host;
const unsigned blkbits = inode->i_blkbits;
@@ -161,6 +161,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
struct block_device *bdev = NULL;
int length;
int fully_mapped = 1;
+ int op_flags = is_readahead ? REQ_RAHEAD : 0;
unsigned nblocks;
unsigned relative_block;
@@ -274,7 +275,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
* This page will go to BIO. Do we need to send this BIO off first?
*/
if (bio && (*last_block_in_bio != blocks[0] - 1))
- bio = mpage_bio_submit(REQ_OP_READ, 0, bio);
+ bio = mpage_bio_submit(REQ_OP_READ, op_flags, bio);
alloc_new:
if (bio == NULL) {
@@ -291,7 +292,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
length = first_hole << blkbits;
if (bio_add_page(bio, page, length, 0) < length) {
- bio = mpage_bio_submit(REQ_OP_READ, 0, bio);
+ bio = mpage_bio_submit(REQ_OP_READ, op_flags, bio);
goto alloc_new;
}
@@ -299,7 +300,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
nblocks = map_bh->b_size >> blkbits;
if ((buffer_boundary(map_bh) && relative_block == nblocks) ||
(first_hole != blocks_per_page))
- bio = mpage_bio_submit(REQ_OP_READ, 0, bio);
+ bio = mpage_bio_submit(REQ_OP_READ, op_flags, bio);
else
*last_block_in_bio = blocks[blocks_per_page - 1];
out:
@@ -307,7 +308,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
confused:
if (bio)
- bio = mpage_bio_submit(REQ_OP_READ, 0, bio);
+ bio = mpage_bio_submit(REQ_OP_READ, op_flags, bio);
if (!PageUptodate(page))
block_read_full_page(page, get_block);
else
@@ -384,13 +385,13 @@ mpage_readpages(struct address_space *mapping, struct list_head *pages,
nr_pages - page_idx,
&last_block_in_bio, &map_bh,
&first_logical_block,
- get_block, gfp);
+ get_block, gfp, true);
}
put_page(page);
}
BUG_ON(!list_empty(pages));
if (bio)
- mpage_bio_submit(REQ_OP_READ, 0, bio);
+ mpage_bio_submit(REQ_OP_READ, REQ_RAHEAD, bio);
return 0;
}
EXPORT_SYMBOL(mpage_readpages);
@@ -409,7 +410,7 @@ int mpage_readpage(struct page *page, get_block_t get_block)
map_bh.b_state = 0;
map_bh.b_size = 0;
bio = do_mpage_readpage(bio, page, 1, &last_block_in_bio,
- &map_bh, &first_logical_block, get_block, gfp);
+ &map_bh, &first_logical_block, get_block, gfp, false);
if (bio)
mpage_bio_submit(REQ_OP_READ, 0, bio);
return 0;
--
2.7.4
next prev parent reply other threads:[~2018-05-24 16:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-24 16:02 [PATCHSET 0/3] Submit ->readpages() IO as read-ahead Jens Axboe
2018-05-24 16:02 ` Jens Axboe [this message]
2018-05-24 19:43 ` [PATCH 1/3] mpage: mpage_readpages() should submit " Andrew Morton
2018-05-24 19:57 ` Matthew Wilcox
2018-05-24 20:24 ` Jens Axboe
2018-05-29 14:36 ` Jens Axboe
2018-05-29 21:59 ` Andrew Morton
2018-05-29 22:18 ` Jens Axboe
2018-05-29 22:37 ` Jens Axboe
2018-05-24 16:02 ` [PATCH 2/3] btrfs: readpages() " Jens Axboe
2018-05-24 16:02 ` [PATCH 3/3] ext4: " Jens Axboe
2018-05-24 20:47 ` Theodore Y. Ts'o
2018-05-24 20:53 ` Jens Axboe
2018-05-24 21:05 ` Jens Axboe
2018-05-25 8:32 ` [PATCHSET 0/3] Submit ->readpages() " Christoph Hellwig
2018-05-25 14:21 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1527177774-21414-2-git-send-email-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.