ext4: use pagevec_lookup_range() in ext4_find_unwritten_pgoff()
[sfrench/cifs-2.6.git] / fs / ext4 / file.c
index 1c73b21fdc133024a4c22fec2b6ad9fed3dfbf8d..7263448097212fba7e0cfbbe2adacbb01d2b1dac 100644 (file)
@@ -464,12 +464,11 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
 
        pagevec_init(&pvec, 0);
        do {
 
        pagevec_init(&pvec, 0);
        do {
-               int i, num;
+               int i;
                unsigned long nr_pages;
 
                unsigned long nr_pages;
 
-               num = min_t(pgoff_t, end - index, PAGEVEC_SIZE - 1) + 1;
-               nr_pages = pagevec_lookup(&pvec, inode->i_mapping, &index,
-                                         (pgoff_t)num);
+               nr_pages = pagevec_lookup_range(&pvec, inode->i_mapping,
+                                       &index, end, PAGEVEC_SIZE);
                if (nr_pages == 0)
                        break;
 
                if (nr_pages == 0)
                        break;
 
@@ -488,9 +487,6 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
                                goto out;
                        }
 
                                goto out;
                        }
 
-                       if (page->index > end)
-                               goto out;
-
                        lock_page(page);
 
                        if (unlikely(page->mapping != inode->i_mapping)) {
                        lock_page(page);
 
                        if (unlikely(page->mapping != inode->i_mapping)) {
@@ -533,12 +529,10 @@ next:
                        unlock_page(page);
                }
 
                        unlock_page(page);
                }
 
-               /* The no. of pages is less than our desired, we are done. */
-               if (nr_pages < num)
-                       break;
                pagevec_release(&pvec);
        } while (index <= end);
 
                pagevec_release(&pvec);
        } while (index <= end);
 
+       /* There are no pages upto endoff - that would be a hole in there. */
        if (whence == SEEK_HOLE && lastoff < endoff) {
                found = 1;
                *offset = lastoff;
        if (whence == SEEK_HOLE && lastoff < endoff) {
                found = 1;
                *offset = lastoff;