Make find_get_entries_tag() update 'start' to index the next page for iteration. Signed-off-by: Jan Kara <jack@xxxxxxx> --- fs/dax.c | 3 +-- include/linux/pagemap.h | 2 +- mm/filemap.c | 8 ++++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index c204445a69b0..4b295c544fd4 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -841,7 +841,7 @@ int dax_writeback_mapping_range(struct address_space *mapping, pagevec_init(&pvec, 0); while (!done) { - pvec.nr = find_get_entries_tag(mapping, start_index, + pvec.nr = find_get_entries_tag(mapping, &start_index, PAGECACHE_TAG_TOWRITE, PAGEVEC_SIZE, pvec.pages, indices); @@ -859,7 +859,6 @@ int dax_writeback_mapping_range(struct address_space *mapping, if (ret < 0) goto out; } - start_index = indices[pvec.nr - 1] + 1; } out: put_dax(dax_dev); diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index df128a56f44b..1dc7e54ec32a 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -365,7 +365,7 @@ static inline unsigned find_get_pages_tag(struct address_space *mapping, return find_get_pages_range_tag(mapping, index, (pgoff_t)-1, tag, nr_pages, pages); } -unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start, +unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t *start, int tag, unsigned int nr_entries, struct page **entries, pgoff_t *indices); diff --git a/mm/filemap.c b/mm/filemap.c index e55100459710..3eb05c91c07a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1731,7 +1731,7 @@ EXPORT_SYMBOL(find_get_pages_range_tag); * Like find_get_entries, except we only return entries which are tagged with * @tag. */ -unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start, +unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t *start, int tag, unsigned int nr_entries, struct page **entries, pgoff_t *indices) { @@ -1744,7 +1744,7 @@ unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start, rcu_read_lock(); radix_tree_for_each_tagged(slot, &mapping->page_tree, - &iter, start, tag) { + &iter, *start, tag) { struct page *head, *page; repeat: page = radix_tree_deref_slot(slot); @@ -1786,6 +1786,10 @@ unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start, break; } rcu_read_unlock(); + + if (ret) + *start = indices[ret - 1] + 1; + return ret; } EXPORT_SYMBOL(find_get_entries_tag); -- 2.12.3