1
0
Fork 0

mm: pass pvec directly to find_get_entries

All callers of find_get_entries() use a pvec, so pass it directly instead
of manipulating it in the caller.

Link: https://lkml.kernel.org/r/20201112212641.27837-14-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Yang Shi <yang.shi@linux.alibaba.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
master
Matthew Wilcox (Oracle) 2021-02-25 17:16:11 -08:00 committed by Linus Torvalds
parent 38cefeb337
commit cf2039af1a
4 changed files with 13 additions and 20 deletions

View File

@ -451,8 +451,7 @@ static inline struct page *find_subpage(struct page *head, pgoff_t index)
} }
unsigned find_get_entries(struct address_space *mapping, pgoff_t start, unsigned find_get_entries(struct address_space *mapping, pgoff_t start,
pgoff_t end, unsigned int nr_entries, struct page **entries, pgoff_t end, struct pagevec *pvec, pgoff_t *indices);
pgoff_t *indices);
unsigned find_get_pages_range(struct address_space *mapping, pgoff_t *start, unsigned find_get_pages_range(struct address_space *mapping, pgoff_t *start,
pgoff_t end, unsigned int nr_pages, pgoff_t end, unsigned int nr_pages,
struct page **pages); struct page **pages);

View File

@ -1866,14 +1866,12 @@ reset:
* @mapping: The address_space to search * @mapping: The address_space to search
* @start: The starting page cache index * @start: The starting page cache index
* @end: The final page index (inclusive). * @end: The final page index (inclusive).
* @nr_entries: The maximum number of entries * @pvec: Where the resulting entries are placed.
* @entries: Where the resulting entries are placed
* @indices: The cache indices corresponding to the entries in @entries * @indices: The cache indices corresponding to the entries in @entries
* *
* find_get_entries() will search for and return a group of up to * find_get_entries() will search for and return a batch of entries in
* @nr_entries entries in the mapping. The entries are placed at * the mapping. The entries are placed in @pvec. find_get_entries()
* @entries. find_get_entries() takes a reference against any actual * takes a reference on any actual pages it returns.
* pages it returns.
* *
* The search returns a group of mapping-contiguous page cache entries * The search returns a group of mapping-contiguous page cache entries
* with ascending indexes. There may be holes in the indices due to * with ascending indexes. There may be holes in the indices due to
@ -1890,15 +1888,12 @@ reset:
* Return: the number of pages and shadow entries which were found. * Return: the number of pages and shadow entries which were found.
*/ */
unsigned find_get_entries(struct address_space *mapping, pgoff_t start, unsigned find_get_entries(struct address_space *mapping, pgoff_t start,
pgoff_t end, unsigned int nr_entries, struct page **entries, pgoff_t end, struct pagevec *pvec, pgoff_t *indices)
pgoff_t *indices)
{ {
XA_STATE(xas, &mapping->i_pages, start); XA_STATE(xas, &mapping->i_pages, start);
struct page *page; struct page *page;
unsigned int ret = 0; unsigned int ret = 0;
unsigned nr_entries = PAGEVEC_SIZE;
if (!nr_entries)
return 0;
rcu_read_lock(); rcu_read_lock();
while ((page = find_get_entry(&xas, end, XA_PRESENT))) { while ((page = find_get_entry(&xas, end, XA_PRESENT))) {
@ -1913,11 +1908,13 @@ unsigned find_get_entries(struct address_space *mapping, pgoff_t start,
} }
indices[ret] = xas.xa_index; indices[ret] = xas.xa_index;
entries[ret] = page; pvec->pages[ret] = page;
if (++ret == nr_entries) if (++ret == nr_entries)
break; break;
} }
rcu_read_unlock(); rcu_read_unlock();
pvec->nr = ret;
return ret; return ret;
} }

View File

@ -965,9 +965,8 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
while (index < end) { while (index < end) {
cond_resched(); cond_resched();
pvec.nr = find_get_entries(mapping, index, end - 1, if (!find_get_entries(mapping, index, end - 1, &pvec,
PAGEVEC_SIZE, pvec.pages, indices); indices)) {
if (!pvec.nr) {
/* If all gone or hole-punch or unfalloc, we're done */ /* If all gone or hole-punch or unfalloc, we're done */
if (index == start || end != -1) if (index == start || end != -1)
break; break;

View File

@ -1046,9 +1046,7 @@ unsigned pagevec_lookup_entries(struct pagevec *pvec,
struct address_space *mapping, pgoff_t start, pgoff_t end, struct address_space *mapping, pgoff_t start, pgoff_t end,
pgoff_t *indices) pgoff_t *indices)
{ {
pvec->nr = find_get_entries(mapping, start, end, PAGEVEC_SIZE, return find_get_entries(mapping, start, end, pvec, indices);
pvec->pages, indices);
return pagevec_count(pvec);
} }
/** /**