[PATCH 5/6] fs: make mpage_readpages() take a struct kiocb argument

From: Jens Axboe
Date: Sun May 31 2020 - 22:53:26 EST


The callers already have it, so just pass it in. Have mpage_readpages()
set REQ_NOWAIT, if IOCB_NOWAIT is set in the iocb.

Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
fs/block_dev.c | 2 +-
fs/exfat/inode.c | 2 +-
fs/ext2/inode.c | 2 +-
fs/fat/inode.c | 2 +-
fs/gfs2/aops.c | 2 +-
fs/hpfs/file.c | 2 +-
fs/isofs/inode.c | 2 +-
fs/jfs/inode.c | 2 +-
fs/mpage.c | 17 +++++++++++++----
fs/nilfs2/inode.c | 2 +-
fs/ocfs2/aops.c | 2 +-
fs/omfs/file.c | 2 +-
fs/qnx6/inode.c | 2 +-
fs/reiserfs/inode.c | 2 +-
fs/udf/inode.c | 2 +-
include/linux/mpage.h | 5 +++--
16 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 87a540b42fa7..bbc1bd8078d6 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -617,7 +617,7 @@ static int blkdev_readpage(struct file * file, struct page * page)
static int blkdev_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, blkdev_get_block);
+ return mpage_readpages(mapping, kiocb, pages, nr_pages, blkdev_get_block);
}

static int blkdev_write_begin(struct file *file, struct address_space *mapping,
diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 9905307dfba2..a7757edf5534 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -375,7 +375,7 @@ static int exfat_readpage(struct file *file, struct page *page)
static int exfat_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned int nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, exfat_get_block);
+ return mpage_readpages(mapping, kiocb, pages, nr_pages, exfat_get_block);
}

static int exfat_writepage(struct page *page, struct writeback_control *wbc)
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 3843900d6251..706fc2628a3a 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -881,7 +881,7 @@ static int
ext2_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, ext2_get_block);
+ return mpage_readpages(mapping, kiocb, pages, nr_pages, ext2_get_block);
}

static int
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index ab9dfcbf1bd3..3c47485d7f83 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -213,7 +213,7 @@ static int fat_readpage(struct file *file, struct page *page)
static int fat_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, fat_get_block);
+ return mpage_readpages(mapping, kiocb, pages, nr_pages, fat_get_block);
}

static void fat_write_failed(struct address_space *mapping, loff_t to)
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 37d18f82e5a1..3e26ca463ca3 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -608,7 +608,7 @@ static int gfs2_readpages(struct kiocb *kiocb, struct address_space *mapping,
if (unlikely(ret))
goto out_uninit;
if (!gfs2_is_stuffed(ip))
- ret = mpage_readpages(mapping, pages, nr_pages, gfs2_block_map);
+ ret = mpage_readpages(mapping, kiocb, pages, nr_pages, gfs2_block_map);
gfs2_glock_dq(&gh);
out_uninit:
gfs2_holder_uninit(&gh);
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
index 5b9c537d011c..21df02964219 100644
--- a/fs/hpfs/file.c
+++ b/fs/hpfs/file.c
@@ -128,7 +128,7 @@ static int hpfs_writepage(struct page *page, struct writeback_control *wbc)
static int hpfs_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, hpfs_get_block);
+ return mpage_readpages(mapping, kiocb, pages, nr_pages, hpfs_get_block);
}

static int hpfs_writepages(struct address_space *mapping,
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 071da59b7266..060e8dfbe1a2 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -1186,7 +1186,7 @@ static int isofs_readpage(struct file *file, struct page *page)
static int isofs_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, isofs_get_block);
+ return mpage_readpages(mapping, kiocb, pages, nr_pages, isofs_get_block);
}

static sector_t _isofs_bmap(struct address_space *mapping, sector_t block)
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 503e2e5cb79d..569e4f4123dd 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -299,7 +299,7 @@ static int jfs_readpage(struct file *file, struct page *page)
static int jfs_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, jfs_get_block);
+ return mpage_readpages(mapping, kiocb, pages, nr_pages, jfs_get_block);
}

static void jfs_write_failed(struct address_space *mapping, loff_t to)
diff --git a/fs/mpage.c b/fs/mpage.c
index ccba3c4c4479..9148d1eae8ff 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -138,6 +138,7 @@ struct mpage_readpage_args {
struct page *page;
unsigned int nr_pages;
bool is_readahead;
+ bool nowait;
sector_t last_block_in_bio;
struct buffer_head map_bh;
unsigned long first_logical_block;
@@ -182,6 +183,8 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args)
op_flags = 0;
gfp = mapping_gfp_constraint(page->mapping, GFP_KERNEL);
}
+ if (args->nowait)
+ op_flags |= REQ_NOWAIT;

if (page_has_buffers(page))
goto confused;
@@ -382,12 +385,14 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args)
* This all causes the disk requests to be issued in the correct order.
*/
int
-mpage_readpages(struct address_space *mapping, struct list_head *pages,
- unsigned nr_pages, get_block_t get_block)
+mpage_readpages(struct address_space *mapping, struct kiocb *kiocb,
+ struct list_head *pages, unsigned nr_pages,
+ get_block_t get_block)
{
struct mpage_readpage_args args = {
.get_block = get_block,
.is_readahead = true,
+ .nowait = kiocb->ki_flags & IOCB_NOWAIT,
};
unsigned page_idx;

@@ -406,8 +411,12 @@ mpage_readpages(struct address_space *mapping, struct list_head *pages,
put_page(page);
}
BUG_ON(!list_empty(pages));
- if (args.bio)
- mpage_bio_submit(REQ_OP_READ, REQ_RAHEAD, args.bio);
+ if (args.bio) {
+ int op = REQ_RAHEAD;
+ if (args.nowait)
+ op |= REQ_NOWAIT;
+ mpage_bio_submit(REQ_OP_READ, op, args.bio);
+ }
return 0;
}
EXPORT_SYMBOL(mpage_readpages);
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index a981c9404fbc..3cbc8b7284a4 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -156,7 +156,7 @@ static int nilfs_readpage(struct file *file, struct page *page)
static int nilfs_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned int nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, nilfs_get_block);
+ return mpage_readpages(mapping, kiocb, pages, nr_pages, nilfs_get_block);
}

static int nilfs_writepages(struct address_space *mapping,
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index aa54b0d0d4a1..50ed84f53b20 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -388,7 +388,7 @@ static int ocfs2_readpages(struct kiocb *kiocb, struct address_space *mapping,
if (start >= i_size_read(inode))
goto out_unlock;

- err = mpage_readpages(mapping, pages, nr_pages, ocfs2_get_block);
+ err = mpage_readpages(mapping, kiocb, pages, nr_pages, ocfs2_get_block);

out_unlock:
up_read(&oi->ip_alloc_sem);
diff --git a/fs/omfs/file.c b/fs/omfs/file.c
index 195bb390ba24..384e8c99fc4f 100644
--- a/fs/omfs/file.c
+++ b/fs/omfs/file.c
@@ -292,7 +292,7 @@ static int omfs_readpage(struct file *file, struct page *page)
static int omfs_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, omfs_get_block);
+ return mpage_readpages(mapping, kiocb, pages, nr_pages, omfs_get_block);
}

static int omfs_writepage(struct page *page, struct writeback_control *wbc)
diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c
index c964fd63d4a5..ef603636ca2d 100644
--- a/fs/qnx6/inode.c
+++ b/fs/qnx6/inode.c
@@ -102,7 +102,7 @@ static int qnx6_readpage(struct file *file, struct page *page)
static int qnx6_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, qnx6_get_block);
+ return mpage_readpages(mapping, kiocb, pages, nr_pages, qnx6_get_block);
}

/*
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 01d5ccdaa5b4..50c93c526557 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1164,7 +1164,7 @@ static int
reiserfs_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, reiserfs_get_block);
+ return mpage_readpages(mapping, kiocb, pages, nr_pages, reiserfs_get_block);
}

/*
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index c541ca95f851..c45d4da5e707 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -198,7 +198,7 @@ static int udf_readpage(struct file *file, struct page *page)
static int udf_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, udf_get_block);
+ return mpage_readpages(mapping, kiocb, pages, nr_pages, udf_get_block);
}

static int udf_write_begin(struct file *file, struct address_space *mapping,
diff --git a/include/linux/mpage.h b/include/linux/mpage.h
index 001f1fcf9836..f708c7a442ae 100644
--- a/include/linux/mpage.h
+++ b/include/linux/mpage.h
@@ -14,8 +14,9 @@

struct writeback_control;

-int mpage_readpages(struct address_space *mapping, struct list_head *pages,
- unsigned nr_pages, get_block_t get_block);
+int mpage_readpages(struct address_space *mapping, struct kiocb *kiocb,
+ struct list_head *pages, unsigned nr_pages,
+ get_block_t get_block);
int mpage_readpage(struct page *page, get_block_t get_block);
int mpage_writepages(struct address_space *mapping,
struct writeback_control *wbc, get_block_t get_block);
--
2.26.2


--------------3ADB41F72EDDDE21CDE7CE18
Content-Type: text/x-patch; charset=UTF-8;
name="0004-iomap-set-REQ_NOWAIT-on-bio-if-IOCB_NOWAIT-is-set-in.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename*0="0004-iomap-set-REQ_NOWAIT-on-bio-if-IOCB_NOWAIT-is-set-in.pa";
filename*1="tch"