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,
-                                         want);
+               nr_pages = pagevec_lookup_range(&pvec, inode->i_mapping, &index,
+                                               end - 1, PAGEVEC_SIZE);
                if (nr_pages == 0)
                        break;
 
                            lastoff < page_offset(page))
                                goto check_range;
 
-                       /* Searching done if the page index is out of range. */
-                       if (page->index >= end)
-                               goto not_found;
-
                        lock_page(page);
                        if (likely(page->mapping == inode->i_mapping) &&
                            page_has_buffers(page)) {
                        unlock_page(page);
                        lastoff = page_offset(page) + PAGE_SIZE;
                }
-
-               /* Searching done if fewer pages returned than wanted. */
-               if (nr_pages < want)
-                       break;
-
                pagevec_release(&pvec);
        } while (index < end);