]> www.infradead.org Git - linux-platform-drivers-x86.git/commitdiff
mm/filemap: don't call ->readpage if IOCB_WAITQ is set
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 24 Feb 2021 20:02:12 +0000 (12:02 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 24 Feb 2021 21:38:28 +0000 (13:38 -0800)
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>
mm/filemap.c

index 43448d4d66f3588245c284deff58bcd1392f7218..8bd1bb375d078fe6e950686820884ab22badfb40 100644 (file)
@@ -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);