Commit 8338141f authored by Jan Kara's avatar Jan Kara Committed by Linus Torvalds

fs: use pagevec_lookup_range() in page_cache_seek_hole_data()

We want only pages from given range in page_cache_seek_hole_data().  Use
pagevec_lookup_range() instead of pagevec_lookup() and remove
unnecessary code.

Note that the check for getting less pages than desired can be removed
because index gets updated by pagevec_lookup_range().

Link: default avatarJan Kara <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 48f2301c
......@@ -3549,11 +3549,10 @@ page_cache_seek_hole_data(struct inode *inode, loff_t offset, loff_t length,
pagevec_init(&pvec, 0);
do {
unsigned want, nr_pages, i;
unsigned nr_pages, i;
want = min_t(unsigned, end - index, PAGEVEC_SIZE);
nr_pages = pagevec_lookup(&pvec, inode->i_mapping, &index,
nr_pages = pagevec_lookup_range(&pvec, inode->i_mapping, &index,
end - 1, PAGEVEC_SIZE);
if (nr_pages == 0)
......@@ -3574,10 +3573,6 @@ page_cache_seek_hole_data(struct inode *inode, loff_t offset, loff_t length,
lastoff < page_offset(page))
goto check_range;
/* Searching done if the page index is out of range. */
if (page->index >= end)
goto not_found;
if (likely(page->mapping == inode->i_mapping) &&
page_has_buffers(page)) {
......@@ -3590,11 +3585,6 @@ page_cache_seek_hole_data(struct inode *inode, loff_t offset, loff_t length,
lastoff = page_offset(page) + PAGE_SIZE;
/* Searching done if fewer pages returned than wanted. */
if (nr_pages < want)
} while (index < end);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment