diff options
author | Jan Kara <jack@suse.cz> | 2017-09-06 19:21:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-06 20:27:26 -0400 |
commit | d72dc8a25afc71ce90ee92bdd77550e9beb85d4d (patch) | |
tree | da47df20fe7bd2672f8368a2545f82e17703820b /mm/filemap.c | |
parent | 26b433d0da062d6e19d75350c0171d3cf8ff560d (diff) |
mm: make pagevec_lookup() update index
Make pagevec_lookup() (and underlying find_get_pages()) update index to
the next page where iteration should continue. Most callers want this
and also pagevec_lookup_tag() already does this.
Link: http://lkml.kernel.org/r/20170726114704.7626-3-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 11 |
1 files changed, 8 insertions, 3 deletions
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 | */ |
1575 | unsigned find_get_pages(struct address_space *mapping, pgoff_t start, | 1576 | unsigned 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; |
1588 | repeat: | 1589 | repeat: |
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 | ||