lkml.org 
[lkml]   [2021]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v5 08/18] mm/filemap: Don't call ->readpage if IOCB_WAITQ is set
    Date
    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.

    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Reviewed-by: Kent Overstreet <kent.overstreet@gmail.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    ---
    mm/filemap.c | 14 ++------------
    1 file changed, 2 insertions(+), 12 deletions(-)

    diff --git a/mm/filemap.c b/mm/filemap.c
    index abd596931f699..ee1255a88106f 100644
    --- a/mm/filemap.c
    +++ b/mm/filemap.c
    @@ -2167,16 +2167,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
    *
    @@ -2228,7 +2218,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);
    @@ -2249,7 +2239,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);
    --
    2.29.2
    \
     
     \ /
      Last update: 2021-01-22 17:10    [W:6.171 / U:0.072 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site