aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/buffer.c10
-rw-r--r--fs/ext4/file.c4
-rw-r--r--fs/ext4/inode.c8
-rw-r--r--fs/fscache/page.c5
-rw-r--r--fs/hugetlbfs/inode.c17
-rw-r--r--fs/nilfs2/page.c3
-rw-r--r--fs/ramfs/file-nommu.c2
-rw-r--r--include/linux/pagemap.h2
-rw-r--r--include/linux/pagevec.h2
-rw-r--r--mm/filemap.c11
-rw-r--r--mm/swap.c5
11 files changed, 32 insertions, 37 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index 5715dac7821f..5b20893708e2 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1633,13 +1633,12 @@ void clean_bdev_aliases(struct block_device *bdev, sector_t block, sector_t len)
1633 1633
1634 end = (block + len - 1) >> (PAGE_SHIFT - bd_inode->i_blkbits); 1634 end = (block + len - 1) >> (PAGE_SHIFT - bd_inode->i_blkbits);
1635 pagevec_init(&pvec, 0); 1635 pagevec_init(&pvec, 0);
1636 while (index <= end && pagevec_lookup(&pvec, bd_mapping, index, 1636 while (index <= end && pagevec_lookup(&pvec, bd_mapping, &index,
1637 min(end - index, (pgoff_t)PAGEVEC_SIZE - 1) + 1)) { 1637 min(end - index, (pgoff_t)PAGEVEC_SIZE - 1) + 1)) {
1638 for (i = 0; i < pagevec_count(&pvec); i++) { 1638 for (i = 0; i < pagevec_count(&pvec); i++) {
1639 struct page *page = pvec.pages[i]; 1639 struct page *page = pvec.pages[i];
1640 1640
1641 index = page->index; 1641 if (page->index > end)
1642 if (index > end)
1643 break; 1642 break;
1644 if (!page_has_buffers(page)) 1643 if (!page_has_buffers(page))
1645 continue; 1644 continue;
@@ -1670,7 +1669,6 @@ unlock_page:
1670 } 1669 }
1671 pagevec_release(&pvec); 1670 pagevec_release(&pvec);
1672 cond_resched(); 1671 cond_resched();
1673 index++;
1674 } 1672 }
1675} 1673}
1676EXPORT_SYMBOL(clean_bdev_aliases); 1674EXPORT_SYMBOL(clean_bdev_aliases);
@@ -3552,7 +3550,8 @@ page_cache_seek_hole_data(struct inode *inode, loff_t offset, loff_t length,
3552 unsigned want, nr_pages, i; 3550 unsigned want, nr_pages, i;
3553 3551
3554 want = min_t(unsigned, end - index, PAGEVEC_SIZE); 3552 want = min_t(unsigned, end - index, PAGEVEC_SIZE);
3555 nr_pages = pagevec_lookup(&pvec, inode->i_mapping, index, want); 3553 nr_pages = pagevec_lookup(&pvec, inode->i_mapping, &index,
3554 want);
3556 if (nr_pages == 0) 3555 if (nr_pages == 0)
3557 break; 3556 break;
3558 3557
@@ -3594,7 +3593,6 @@ page_cache_seek_hole_data(struct inode *inode, loff_t offset, loff_t length,
3594 if (nr_pages < want) 3593 if (nr_pages < want)
3595 break; 3594 break;
3596 3595
3597 index = pvec.pages[i - 1]->index + 1;
3598 pagevec_release(&pvec); 3596 pagevec_release(&pvec);
3599 } while (index < end); 3597 } while (index < end);
3600 3598
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index f28ac999dfba..1c73b21fdc13 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -468,7 +468,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
468 unsigned long nr_pages; 468 unsigned long nr_pages;
469 469
470 num = min_t(pgoff_t, end - index, PAGEVEC_SIZE - 1) + 1; 470 num = min_t(pgoff_t, end - index, PAGEVEC_SIZE - 1) + 1;
471 nr_pages = pagevec_lookup(&pvec, inode->i_mapping, index, 471 nr_pages = pagevec_lookup(&pvec, inode->i_mapping, &index,
472 (pgoff_t)num); 472 (pgoff_t)num);
473 if (nr_pages == 0) 473 if (nr_pages == 0)
474 break; 474 break;
@@ -536,8 +536,6 @@ next:
536 /* The no. of pages is less than our desired, we are done. */ 536 /* The no. of pages is less than our desired, we are done. */
537 if (nr_pages < num) 537 if (nr_pages < num)
538 break; 538 break;
539
540 index = pvec.pages[i - 1]->index + 1;
541 pagevec_release(&pvec); 539 pagevec_release(&pvec);
542 } while (index <= end); 540 } while (index <= end);
543 541
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c774bdc22759..b3ce1c6d9f23 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1720,7 +1720,7 @@ static void mpage_release_unused_pages(struct mpage_da_data *mpd,
1720 1720
1721 pagevec_init(&pvec, 0); 1721 pagevec_init(&pvec, 0);
1722 while (index <= end) { 1722 while (index <= end) {
1723 nr_pages = pagevec_lookup(&pvec, mapping, index, PAGEVEC_SIZE); 1723 nr_pages = pagevec_lookup(&pvec, mapping, &index, PAGEVEC_SIZE);
1724 if (nr_pages == 0) 1724 if (nr_pages == 0)
1725 break; 1725 break;
1726 for (i = 0; i < nr_pages; i++) { 1726 for (i = 0; i < nr_pages; i++) {
@@ -1737,7 +1737,6 @@ static void mpage_release_unused_pages(struct mpage_da_data *mpd,
1737 } 1737 }
1738 unlock_page(page); 1738 unlock_page(page);
1739 } 1739 }
1740 index = pvec.pages[nr_pages - 1]->index + 1;
1741 pagevec_release(&pvec); 1740 pagevec_release(&pvec);
1742 } 1741 }
1743} 1742}
@@ -2348,7 +2347,7 @@ static int mpage_map_and_submit_buffers(struct mpage_da_data *mpd)
2348 2347
2349 pagevec_init(&pvec, 0); 2348 pagevec_init(&pvec, 0);
2350 while (start <= end) { 2349 while (start <= end) {
2351 nr_pages = pagevec_lookup(&pvec, inode->i_mapping, start, 2350 nr_pages = pagevec_lookup(&pvec, inode->i_mapping, &start,
2352 PAGEVEC_SIZE); 2351 PAGEVEC_SIZE);
2353 if (nr_pages == 0) 2352 if (nr_pages == 0)
2354 break; 2353 break;
@@ -2357,8 +2356,6 @@ static int mpage_map_and_submit_buffers(struct mpage_da_data *mpd)
2357 2356
2358 if (page->index > end) 2357 if (page->index > end)
2359 break; 2358 break;
2360 /* Up to 'end' pages must be contiguous */
2361 BUG_ON(page->index != start);
2362 bh = head = page_buffers(page); 2359 bh = head = page_buffers(page);
2363 do { 2360 do {
2364 if (lblk < mpd->map.m_lblk) 2361 if (lblk < mpd->map.m_lblk)
@@ -2403,7 +2400,6 @@ static int mpage_map_and_submit_buffers(struct mpage_da_data *mpd)
2403 pagevec_release(&pvec); 2400 pagevec_release(&pvec);
2404 return err; 2401 return err;
2405 } 2402 }
2406 start++;
2407 } 2403 }
2408 pagevec_release(&pvec); 2404 pagevec_release(&pvec);
2409 } 2405 }
diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index c8c4f79c7ce1..83018861dcd2 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -1178,11 +1178,10 @@ void __fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
1178 pagevec_init(&pvec, 0); 1178 pagevec_init(&pvec, 0);
1179 next = 0; 1179 next = 0;
1180 do { 1180 do {
1181 if (!pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)) 1181 if (!pagevec_lookup(&pvec, mapping, &next, PAGEVEC_SIZE))
1182 break; 1182 break;
1183 for (i = 0; i < pagevec_count(&pvec); i++) { 1183 for (i = 0; i < pagevec_count(&pvec); i++) {
1184 struct page *page = pvec.pages[i]; 1184 struct page *page = pvec.pages[i];
1185 next = page->index;
1186 if (PageFsCache(page)) { 1185 if (PageFsCache(page)) {
1187 __fscache_wait_on_page_write(cookie, page); 1186 __fscache_wait_on_page_write(cookie, page);
1188 __fscache_uncache_page(cookie, page); 1187 __fscache_uncache_page(cookie, page);
@@ -1190,7 +1189,7 @@ void __fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
1190 } 1189 }
1191 pagevec_release(&pvec); 1190 pagevec_release(&pvec);
1192 cond_resched(); 1191 cond_resched();
1193 } while (++next); 1192 } while (next);
1194 1193
1195 _leave(""); 1194 _leave("");
1196} 1195}
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 28d2753be094..b9678ce91e25 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -401,7 +401,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
401 const pgoff_t end = lend >> huge_page_shift(h); 401 const pgoff_t end = lend >> huge_page_shift(h);
402 struct vm_area_struct pseudo_vma; 402 struct vm_area_struct pseudo_vma;
403 struct pagevec pvec; 403 struct pagevec pvec;
404 pgoff_t next; 404 pgoff_t next, index;
405 int i, freed = 0; 405 int i, freed = 0;
406 long lookup_nr = PAGEVEC_SIZE; 406 long lookup_nr = PAGEVEC_SIZE;
407 bool truncate_op = (lend == LLONG_MAX); 407 bool truncate_op = (lend == LLONG_MAX);
@@ -420,7 +420,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
420 /* 420 /*
421 * When no more pages are found, we are done. 421 * When no more pages are found, we are done.
422 */ 422 */
423 if (!pagevec_lookup(&pvec, mapping, next, lookup_nr)) 423 if (!pagevec_lookup(&pvec, mapping, &next, lookup_nr))
424 break; 424 break;
425 425
426 for (i = 0; i < pagevec_count(&pvec); ++i) { 426 for (i = 0; i < pagevec_count(&pvec); ++i) {
@@ -432,13 +432,13 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
432 * only possible in the punch hole case as end is 432 * only possible in the punch hole case as end is
433 * max page offset in the truncate case. 433 * max page offset in the truncate case.
434 */ 434 */
435 next = page->index; 435 index = page->index;
436 if (next >= end) 436 if (index >= end)
437 break; 437 break;
438 438
439 hash = hugetlb_fault_mutex_hash(h, current->mm, 439 hash = hugetlb_fault_mutex_hash(h, current->mm,
440 &pseudo_vma, 440 &pseudo_vma,
441 mapping, next, 0); 441 mapping, index, 0);
442 mutex_lock(&hugetlb_fault_mutex_table[hash]); 442 mutex_lock(&hugetlb_fault_mutex_table[hash]);
443 443
444 /* 444 /*
@@ -455,8 +455,8 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
455 455
456 i_mmap_lock_write(mapping); 456 i_mmap_lock_write(mapping);
457 hugetlb_vmdelete_list(&mapping->i_mmap, 457 hugetlb_vmdelete_list(&mapping->i_mmap,
458 next * pages_per_huge_page(h), 458 index * pages_per_huge_page(h),
459 (next + 1) * pages_per_huge_page(h)); 459 (index + 1) * pages_per_huge_page(h));
460 i_mmap_unlock_write(mapping); 460 i_mmap_unlock_write(mapping);
461 } 461 }
462 462
@@ -475,14 +475,13 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
475 freed++; 475 freed++;
476 if (!truncate_op) { 476 if (!truncate_op) {
477 if (unlikely(hugetlb_unreserve_pages(inode, 477 if (unlikely(hugetlb_unreserve_pages(inode,
478 next, next + 1, 1))) 478 index, index + 1, 1)))
479 hugetlb_fix_reserve_counts(inode); 479 hugetlb_fix_reserve_counts(inode);
480 } 480 }
481 481
482 unlock_page(page); 482 unlock_page(page);
483 mutex_unlock(&hugetlb_fault_mutex_table[hash]); 483 mutex_unlock(&hugetlb_fault_mutex_table[hash]);
484 } 484 }
485 ++next;
486 huge_pagevec_release(&pvec); 485 huge_pagevec_release(&pvec);
487 cond_resched(); 486 cond_resched();
488 } 487 }
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index f11a3ad2df0c..382a36c72d72 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -312,10 +312,9 @@ void nilfs_copy_back_pages(struct address_space *dmap,
312 312
313 pagevec_init(&pvec, 0); 313 pagevec_init(&pvec, 0);
314repeat: 314repeat:
315 n = pagevec_lookup(&pvec, smap, index, PAGEVEC_SIZE); 315 n = pagevec_lookup(&pvec, smap, &index, PAGEVEC_SIZE);
316 if (!n) 316 if (!n)
317 return; 317 return;
318 index = pvec.pages[n - 1]->index + 1;
319 318
320 for (i = 0; i < pagevec_count(&pvec); i++) { 319 for (i = 0; i < pagevec_count(&pvec); i++) {
321 struct page *page = pvec.pages[i], *dpage; 320 struct page *page = pvec.pages[i], *dpage;
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index 2ef7ce75c062..3ac1f2387083 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -228,7 +228,7 @@ static unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
228 if (!pages) 228 if (!pages)
229 goto out_free; 229 goto out_free;
230 230
231 nr = find_get_pages(inode->i_mapping, pgoff, lpages, pages); 231 nr = find_get_pages(inode->i_mapping, &pgoff, lpages, pages);
232 if (nr != lpages) 232 if (nr != lpages)
233 goto out_free_pages; /* leave if some pages were missing */ 233 goto out_free_pages; /* leave if some pages were missing */
234 234
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 79b36f57c3ba..249b1b5964c7 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -353,7 +353,7 @@ struct page *find_lock_entry(struct address_space *mapping, pgoff_t offset);
353unsigned find_get_entries(struct address_space *mapping, pgoff_t start, 353unsigned find_get_entries(struct address_space *mapping, pgoff_t start,
354 unsigned int nr_entries, struct page **entries, 354 unsigned int nr_entries, struct page **entries,
355 pgoff_t *indices); 355 pgoff_t *indices);
356unsigned find_get_pages(struct address_space *mapping, pgoff_t start, 356unsigned find_get_pages(struct address_space *mapping, pgoff_t *start,
357 unsigned int nr_pages, struct page **pages); 357 unsigned int nr_pages, struct page **pages);
358unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start, 358unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start,
359 unsigned int nr_pages, struct page **pages); 359 unsigned int nr_pages, struct page **pages);
diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h
index b45d391b4540..c395a5bb58b2 100644
--- a/include/linux/pagevec.h
+++ b/include/linux/pagevec.h
@@ -28,7 +28,7 @@ unsigned pagevec_lookup_entries(struct pagevec *pvec,
28 pgoff_t *indices); 28 pgoff_t *indices);
29void pagevec_remove_exceptionals(struct pagevec *pvec); 29void pagevec_remove_exceptionals(struct pagevec *pvec);
30unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping, 30unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping,
31 pgoff_t start, unsigned nr_pages); 31 pgoff_t *start, unsigned nr_pages);
32unsigned pagevec_lookup_tag(struct pagevec *pvec, 32unsigned pagevec_lookup_tag(struct pagevec *pvec,
33 struct address_space *mapping, pgoff_t *index, int tag, 33 struct address_space *mapping, pgoff_t *index, int tag,
34 unsigned nr_pages); 34 unsigned nr_pages);
diff --git a/mm/filemap.c b/mm/filemap.c
index dad935769055..ab9011408d81 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -403,7 +403,7 @@ bool filemap_range_has_page(struct address_space *mapping,
403 return false; 403 return false;
404 404
405 pagevec_init(&pvec, 0); 405 pagevec_init(&pvec, 0);
406 if (!pagevec_lookup(&pvec, mapping, index, 1)) 406 if (!pagevec_lookup(&pvec, mapping, &index, 1))
407 return false; 407 return false;
408 ret = (pvec.pages[0]->index <= end); 408 ret = (pvec.pages[0]->index <= end);
409 pagevec_release(&pvec); 409 pagevec_release(&pvec);
@@ -1569,10 +1569,11 @@ export:
1569 * 1569 *
1570 * The search returns a group of mapping-contiguous pages with ascending 1570 * The search returns a group of mapping-contiguous pages with ascending
1571 * indexes. There may be holes in the indices due to not-present pages. 1571 * indexes. There may be holes in the indices due to not-present pages.
1572 * We also update @start to index the next page for the traversal.
1572 * 1573 *
1573 * find_get_pages() returns the number of pages which were found. 1574 * find_get_pages() returns the number of pages which were found.
1574 */ 1575 */
1575unsigned find_get_pages(struct address_space *mapping, pgoff_t start, 1576unsigned find_get_pages(struct address_space *mapping, pgoff_t *start,
1576 unsigned int nr_pages, struct page **pages) 1577 unsigned int nr_pages, struct page **pages)
1577{ 1578{
1578 struct radix_tree_iter iter; 1579 struct radix_tree_iter iter;
@@ -1583,7 +1584,7 @@ unsigned find_get_pages(struct address_space *mapping, pgoff_t start,
1583 return 0; 1584 return 0;
1584 1585
1585 rcu_read_lock(); 1586 rcu_read_lock();
1586 radix_tree_for_each_slot(slot, &mapping->page_tree, &iter, start) { 1587 radix_tree_for_each_slot(slot, &mapping->page_tree, &iter, *start) {
1587 struct page *head, *page; 1588 struct page *head, *page;
1588repeat: 1589repeat:
1589 page = radix_tree_deref_slot(slot); 1590 page = radix_tree_deref_slot(slot);
@@ -1625,6 +1626,10 @@ repeat:
1625 } 1626 }
1626 1627
1627 rcu_read_unlock(); 1628 rcu_read_unlock();
1629
1630 if (ret)
1631 *start = pages[ret - 1]->index + 1;
1632
1628 return ret; 1633 return ret;
1629} 1634}
1630 1635
diff --git a/mm/swap.c b/mm/swap.c
index 60b1d2a75852..4bffd1198ce5 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -957,12 +957,13 @@ void pagevec_remove_exceptionals(struct pagevec *pvec)
957 * reference against the pages in @pvec. 957 * reference against the pages in @pvec.
958 * 958 *
959 * The search returns a group of mapping-contiguous pages with ascending 959 * The search returns a group of mapping-contiguous pages with ascending
960 * indexes. There may be holes in the indices due to not-present pages. 960 * indexes. There may be holes in the indices due to not-present pages. We
961 * also update @start to index the next page for the traversal.
961 * 962 *
962 * pagevec_lookup() returns the number of pages which were found. 963 * pagevec_lookup() returns the number of pages which were found.
963 */ 964 */
964unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping, 965unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping,
965 pgoff_t start, unsigned nr_pages) 966 pgoff_t *start, unsigned nr_pages)
966{ 967{
967 pvec->nr = find_get_pages(mapping, start, nr_pages, pvec->pages); 968 pvec->nr = find_get_pages(mapping, start, nr_pages, pvec->pages);
968 return pagevec_count(pvec); 969 return pagevec_count(pvec);