[v5,16/18] mm/filemap: Don't relock the page after calling readpage
diff mbox series

Message ID 20210122160140.223228-17-willy@infradead.org
State In Next
Commit bd0e557ab34d391a1a9d90fa9e69167717a9f4e9
Headers show
Series
  • Refactor generic_file_buffered_read
Related show

Commit Message

Matthew Wilcox Jan. 22, 2021, 4:01 p.m. UTC
We don't need to get the page lock again; we just need to wait for
the I/O to finish, so use wait_on_page_locked_killable() like the
other callers of ->readpage.

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 | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

Patch
diff mbox series

diff --git a/mm/filemap.c b/mm/filemap.c
index 1fba96dab4b8e..542d9c93732c2 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2227,23 +2227,16 @@  static int filemap_read_page(struct file *file, struct address_space *mapping,
 	error = mapping->a_ops->readpage(file, page);
 	if (error)
 		return error;
-	if (PageUptodate(page))
-		return 0;
 
-	error = lock_page_killable(page);
+	error = wait_on_page_locked_killable(page);
 	if (error)
 		return error;
-	if (!PageUptodate(page)) {
-		if (page->mapping == NULL) {
-			/* page truncated */
-			error = AOP_TRUNCATED_PAGE;
-		} else {
-			shrink_readahead_size_eio(&file->f_ra);
-			error = -EIO;
-		}
-	}
-	unlock_page(page);
-	return error;
+	if (PageUptodate(page))
+		return 0;
+	if (!page->mapping)	/* page truncated */
+		return AOP_TRUNCATED_PAGE;
+	shrink_readahead_size_eio(&file->f_ra);
+	return -EIO;
 }
 
 static bool filemap_range_uptodate(struct address_space *mapping,