fs: fix performance regression in clean_bdev_aliases()
[sfrench/cifs-2.6.git] / fs / buffer.c
index 5715dac7821fe1c49a1c1ecd8f6b12192f3f1d1c..7e531bb356bd3ad58757f550fdec459106644d44 100644 (file)
@@ -1627,20 +1627,18 @@ void clean_bdev_aliases(struct block_device *bdev, sector_t block, sector_t len)
        struct pagevec pvec;
        pgoff_t index = block >> (PAGE_SHIFT - bd_inode->i_blkbits);
        pgoff_t end;
-       int i;
+       int i, count;
        struct buffer_head *bh;
        struct buffer_head *head;
 
        end = (block + len - 1) >> (PAGE_SHIFT - bd_inode->i_blkbits);
        pagevec_init(&pvec, 0);
-       while (index <= end && pagevec_lookup(&pvec, bd_mapping, index,
-                       min(end - index, (pgoff_t)PAGEVEC_SIZE - 1) + 1)) {
-               for (i = 0; i < pagevec_count(&pvec); i++) {
+       while (pagevec_lookup_range(&pvec, bd_mapping, &index, end,
+                                   PAGEVEC_SIZE)) {
+               count = pagevec_count(&pvec);
+               for (i = 0; i < count; i++) {
                        struct page *page = pvec.pages[i];
 
-                       index = page->index;
-                       if (index > end)
-                               break;
                        if (!page_has_buffers(page))
                                continue;
                        /*
@@ -1670,7 +1668,9 @@ unlock_page:
                }
                pagevec_release(&pvec);
                cond_resched();
-               index++;
+               /* End of range already reached? */
+               if (index > end || !index)
+                       break;
        }
 }
 EXPORT_SYMBOL(clean_bdev_aliases);
@@ -3552,7 +3552,8 @@ page_cache_seek_hole_data(struct inode *inode, loff_t offset, loff_t length,
                unsigned want, 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(&pvec, inode->i_mapping, &index,
+                                         want);
                if (nr_pages == 0)
                        break;
 
@@ -3594,7 +3595,6 @@ page_cache_seek_hole_data(struct inode *inode, loff_t offset, loff_t length,
                if (nr_pages < want)
                        break;
 
-               index = pvec.pages[i - 1]->index + 1;
                pagevec_release(&pvec);
        } while (index < end);