aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle)2021-02-24 12:02:12 -0800
committerLinus Torvalds2021-02-24 13:38:28 -0800
commit33a0f5c6b34f58e632f1855ff29228d49bc23bcc (patch)
tree42f8642cd1334987903de7ca2c94cde5f9860708
parentf32b5dd721fb8861f3c1b8e7c06ac978236d0236 (diff)
mm/filemap: don't call ->readpage if IOCB_WAITQ is set
The readpage operation can block in many (most?) filesystems, so we should punt to a work queue instead of calling it. This was the last caller of lock_page_for_iocb(), so remove it. Link: https://lkml.kernel.org/r/20210122160140.223228-9-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Kent Overstreet <kent.overstreet@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Miaohe Lin <linmiaohe@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/filemap.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index 43448d4d66f3..8bd1bb375d07 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2154,16 +2154,6 @@ static void shrink_readahead_size_eio(struct file_ra_state *ra)
ra->ra_pages /= 4;
}
-static int lock_page_for_iocb(struct kiocb *iocb, struct page *page)
-{
- if (iocb->ki_flags & IOCB_WAITQ)
- return lock_page_async(page, iocb->ki_waitq);
- else if (iocb->ki_flags & IOCB_NOWAIT)
- return trylock_page(page) ? 0 : -EAGAIN;
- else
- return lock_page_killable(page);
-}
-
/*
* filemap_get_read_batch - Get a batch of pages for read
*
@@ -2215,7 +2205,7 @@ static struct page *filemap_read_page(struct kiocb *iocb, struct file *filp,
struct file_ra_state *ra = &filp->f_ra;
int error;
- if (iocb->ki_flags & (IOCB_NOIO | IOCB_NOWAIT)) {
+ if (iocb->ki_flags & (IOCB_NOIO | IOCB_NOWAIT | IOCB_WAITQ)) {
unlock_page(page);
put_page(page);
return ERR_PTR(-EAGAIN);
@@ -2236,7 +2226,7 @@ static struct page *filemap_read_page(struct kiocb *iocb, struct file *filp,
}
if (!PageUptodate(page)) {
- error = lock_page_for_iocb(iocb, page);
+ error = lock_page_killable(page);
if (unlikely(error)) {
put_page(page);
return ERR_PTR(error);