[PATCH 4/6] iomap: set REQ_NOWAIT on bio if IOCB_NOWAIT is set in kiocb

From: Jens Axboe
Date: Sun May 31 2020 - 22:44:18 EST


Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
fs/iomap/buffered-io.c | 9 +++++++--
fs/xfs/xfs_aops.c | 3 ++-
fs/zonefs/super.c | 5 +++--
include/linux/iomap.h | 5 +++--
4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 89e21961d1ad..4558b455182f 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -215,6 +215,7 @@ struct iomap_readpage_ctx {
struct page *cur_page;
bool cur_page_in_bio;
bool is_readahead;
+ bool nowait;
struct bio *bio;
struct list_head *pages;
};
@@ -321,6 +322,8 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
ctx->bio->bi_opf = REQ_OP_READ;
if (ctx->is_readahead)
ctx->bio->bi_opf |= REQ_RAHEAD;
+ if (ctx->nowait)
+ ctx->bio->bi_opf |= REQ_NOWAIT;
ctx->bio->bi_iter.bi_sector = sector;
bio_set_dev(ctx->bio, iomap->bdev);
ctx->bio->bi_end_io = iomap_read_end_io;
@@ -432,12 +435,14 @@ iomap_readpages_actor(struct inode *inode, loff_t pos, loff_t length,
}

int
-iomap_readpages(struct address_space *mapping, struct list_head *pages,
- unsigned nr_pages, const struct iomap_ops *ops)
+iomap_readpages(struct address_space *mapping, struct kiocb *kiocb,
+ struct list_head *pages, unsigned nr_pages,
+ const struct iomap_ops *ops)
{
struct iomap_readpage_ctx ctx = {
.pages = pages,
.is_readahead = true,
+ .nowait = kiocb->ki_flags & IOCB_NOWAIT,
};
loff_t pos = page_offset(list_entry(pages->prev, struct page, lru));
loff_t last = page_offset(list_entry(pages->next, struct page, lru));
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index bff9a2374ece..bc8ea7cd1441 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -628,7 +628,8 @@ xfs_vm_readpages(
struct list_head *pages,
unsigned nr_pages)
{
- return iomap_readpages(mapping, pages, nr_pages, &xfs_read_iomap_ops);
+ return iomap_readpages(mapping, kiocb, pages, nr_pages,
+ &xfs_read_iomap_ops);
}

static int
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 11812841a5fa..06b4f621a14a 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -79,10 +79,11 @@ static int zonefs_readpage(struct file *unused, struct page *page)
return iomap_readpage(page, &zonefs_iomap_ops);
}

-static int zonefs_readpages(struct kiocb *unused, struct address_space *mapping,
+static int zonefs_readpages(struct kiocb *kiocb, struct address_space *mapping,
struct list_head *pages, unsigned int nr_pages)
{
- return iomap_readpages(mapping, pages, nr_pages, &zonefs_iomap_ops);
+ return iomap_readpages(mapping, kiocb, pages, nr_pages,
+ &zonefs_iomap_ops);
}

/*
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 8b09463dae0d..6b5d802d7227 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -155,8 +155,9 @@ loff_t iomap_apply(struct inode *inode, loff_t pos, loff_t length,
ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from,
const struct iomap_ops *ops);
int iomap_readpage(struct page *page, const struct iomap_ops *ops);
-int iomap_readpages(struct address_space *mapping, struct list_head *pages,
- unsigned nr_pages, const struct iomap_ops *ops);
+int iomap_readpages(struct address_space *mapping, struct kiocb *kiocb,
+ struct list_head *pages, unsigned nr_pages,
+ const struct iomap_ops *ops);
int iomap_set_page_dirty(struct page *page);
int iomap_is_partially_uptodate(struct page *page, unsigned long from,
unsigned long count);
--
2.26.2


--------------3ADB41F72EDDDE21CDE7CE18
Content-Type: text/x-patch; charset=UTF-8;
name="0003-mm-make-generic_file_buffered_read-use-iocb-read-ahe.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename*0="0003-mm-make-generic_file_buffered_read-use-iocb-read-ahe.pa";
filename*1="tch"