linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
	akpm@linux-foundation.org
Subject: Re: [PATCH 2/4] mpage: mpage_readpages() should submit IO as read-ahead
Date: Thu, 21 Jun 2018 11:47:44 -0700	[thread overview]
Message-ID: <20180621184744.GA77164@jaegeuk-macbookpro.roam.corp.google.com> (raw)
In-Reply-To: <20180621010725.17813-3-axboe@kernel.dk>

On 06/20, Jens Axboe wrote:
> 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 its ->readpages() implementation
> will now get this right.
> 
> Since we're passing in whether the IO is read-ahead or not, we
> don't need to pass in the 'gfp' separately, as it is dependent
> on the IO being read-ahead. Kill off that member.
> 
> Add some documentation notes on ->readpages() being purely for
> read-ahead.
> 
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> ---
>  fs/f2fs/data.c     |  5 +++++
>  fs/mpage.c         | 29 +++++++++++++++++++----------
>  include/linux/fs.h |  4 ++++
>  3 files changed, 28 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 8f931d699287..b7c9b58acf3e 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1421,6 +1421,11 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>  /*
>   * This function was originally taken from fs/mpage.c, and customized for f2fs.
>   * Major change was from block_size == page_size in f2fs by default.
> + *
> + * Note that the aops->readpages() function is ONLY used for read-ahead. If
> + * this function ever deviates from doing just read-ahead, it should either
> + * use ->readpage() or do the necessary surgery to decouple ->readpages()
> + * readom read-ahead.
>   */
>  static int f2fs_mpage_readpages(struct address_space *mapping,
>  			struct list_head *pages, struct page *page,

Hi Jens,

Could you please consider the below change to address your concern?

---
 fs/f2fs/data.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 8f931d699287..c1266b231f62 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -534,7 +534,7 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)
 }
 
 static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
-							 unsigned nr_pages)
+					unsigned nr_pages, unsigned op_flag)
 {
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	struct bio *bio;
@@ -546,7 +546,7 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
 		return ERR_PTR(-ENOMEM);
 	f2fs_target_device(sbi, blkaddr, bio);
 	bio->bi_end_io = f2fs_read_end_io;
-	bio_set_op_attrs(bio, REQ_OP_READ, 0);
+	bio_set_op_attrs(bio, REQ_OP_READ, op_flag);
 
 	if (f2fs_encrypted_file(inode))
 		post_read_steps |= 1 << STEP_DECRYPT;
@@ -571,7 +571,7 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
 static int f2fs_submit_page_read(struct inode *inode, struct page *page,
 							block_t blkaddr)
 {
-	struct bio *bio = f2fs_grab_read_bio(inode, blkaddr, 1);
+	struct bio *bio = f2fs_grab_read_bio(inode, blkaddr, 1, 0);
 
 	if (IS_ERR(bio))
 		return PTR_ERR(bio);
@@ -1424,7 +1424,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
  */
 static int f2fs_mpage_readpages(struct address_space *mapping,
 			struct list_head *pages, struct page *page,
-			unsigned nr_pages)
+			unsigned nr_pages, bool is_readahead)
 {
 	struct bio *bio = NULL;
 	sector_t last_block_in_bio = 0;
@@ -1514,7 +1514,8 @@ static int f2fs_mpage_readpages(struct address_space *mapping,
 			bio = NULL;
 		}
 		if (bio == NULL) {
-			bio = f2fs_grab_read_bio(inode, block_nr, nr_pages);
+			bio = f2fs_grab_read_bio(inode, block_nr, nr_pages,
+					is_readahead ? REQ_RAHEAD : 0);
 			if (IS_ERR(bio)) {
 				bio = NULL;
 				goto set_error_page;
@@ -1558,7 +1559,7 @@ static int f2fs_read_data_page(struct file *file, struct page *page)
 	if (f2fs_has_inline_data(inode))
 		ret = f2fs_read_inline_data(inode, page);
 	if (ret == -EAGAIN)
-		ret = f2fs_mpage_readpages(page->mapping, NULL, page, 1);
+		ret = f2fs_mpage_readpages(page->mapping, NULL, page, 1, false);
 	return ret;
 }
 
@@ -1575,7 +1576,7 @@ static int f2fs_read_data_pages(struct file *file,
 	if (f2fs_has_inline_data(inode))
 		return 0;
 
-	return f2fs_mpage_readpages(mapping, pages, NULL, nr_pages);
+	return f2fs_mpage_readpages(mapping, pages, NULL, nr_pages, true);
 }
 
 static int encrypt_one_page(struct f2fs_io_info *fio)
-- 
2.17.0.441.gb46fe60e1d-goog

  parent reply	other threads:[~2018-06-21 18:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-21  1:07 [PATCH v4 0/4] Submit ->readpages() " Jens Axboe
2018-06-21  1:07 ` [PATCH 1/4] mpage: add argument structure for do_mpage_readpage() Jens Axboe
2018-06-21  1:07 ` [PATCH 2/4] mpage: mpage_readpages() should submit IO as read-ahead Jens Axboe
2018-06-21 17:27   ` Randy Dunlap
2018-06-21 17:29     ` Jens Axboe
2018-06-21 18:47   ` Jaegeuk Kim [this message]
2018-06-21 19:18     ` Jens Axboe
2018-06-21 19:32       ` Jaegeuk Kim
2018-06-21 19:32         ` Jens Axboe
2018-06-21  1:07 ` [PATCH 3/4] btrfs: readpages() " Jens Axboe
2018-06-21  1:07 ` [PATCH 4/4] ext4: " Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2018-05-30 14:42 [PATCHSET v3 0/4] Submit ->readpages() " Jens Axboe
2018-05-30 14:42 ` [PATCH 2/4] mpage: mpage_readpages() should submit " Jens Axboe
2018-05-29 22:17 [PATCHSET v2 0/4] Submit ->readpages() " Jens Axboe
2018-05-29 22:17 ` [PATCH 2/4] mpage: mpage_readpages() should submit " 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=20180621184744.GA77164@jaegeuk-macbookpro.roam.corp.google.com \
    --to=jaegeuk@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --subject='Re: [PATCH 2/4] mpage: mpage_readpages() should submit IO as read-ahead' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).