]> Git Repo - linux.git/commitdiff
mm: pass pvec directly to find_get_entries
authorMatthew Wilcox (Oracle) <[email protected]>
Fri, 26 Feb 2021 01:16:11 +0000 (17:16 -0800)
committerLinus Torvalds <[email protected]>
Fri, 26 Feb 2021 17:40:59 +0000 (09:40 -0800)
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/[email protected]
Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Reviewed-by: William Kucharski <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Dave Chinner <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Kirill A. Shutemov <[email protected]>
Cc: Yang Shi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/pagemap.h
mm/filemap.c
mm/shmem.c
mm/swap.c

index fdb2c4e44851017010e5928a26371ef74630b2b1..20225b067583ab552a0fc22a22c6bad81cabd12a 100644 (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,
-               pgoff_t end, unsigned int nr_entries, struct page **entries,
-               pgoff_t *indices);
+               pgoff_t end, struct pagevec *pvec, pgoff_t *indices);
 unsigned find_get_pages_range(struct address_space *mapping, pgoff_t *start,
                        pgoff_t end, unsigned int nr_pages,
                        struct page **pages);
index 65cfdff17ac6908bf8ae817d17cfa7469d8c6b02..43700480d897d48eb5dbdb879d9d1c5efddb8d0d 100644 (file)
@@ -1866,14 +1866,12 @@ reset:
  * @mapping:   The address_space to search
  * @start:     The starting page cache index
  * @end:       The final page index (inclusive).
- * @nr_entries:        The maximum number of entries
- * @entries:   Where the resulting entries are placed
+ * @pvec:      Where the resulting entries are placed.
  * @indices:   The cache indices corresponding to the entries in @entries
  *
- * find_get_entries() will search for and return a group of up to
- * @nr_entries entries in the mapping.  The entries are placed at
- * @entries.  find_get_entries() takes a reference against any actual
- * pages it returns.
+ * find_get_entries() will search for and return a batch of entries in
+ * the mapping.  The entries are placed in @pvec.  find_get_entries()
+ * takes a reference on any actual pages it returns.
  *
  * The search returns a group of mapping-contiguous page cache entries
  * 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.
  */
 unsigned find_get_entries(struct address_space *mapping, pgoff_t start,
-               pgoff_t end, unsigned int nr_entries, struct page **entries,
-               pgoff_t *indices)
+               pgoff_t end, struct pagevec *pvec, pgoff_t *indices)
 {
        XA_STATE(xas, &mapping->i_pages, start);
        struct page *page;
        unsigned int ret = 0;
-
-       if (!nr_entries)
-               return 0;
+       unsigned nr_entries = PAGEVEC_SIZE;
 
        rcu_read_lock();
        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;
-               entries[ret] = page;
+               pvec->pages[ret] = page;
                if (++ret == nr_entries)
                        break;
        }
        rcu_read_unlock();
+
+       pvec->nr = ret;
        return ret;
 }
 
index 4aac760aa2d47a30f1f5c8a7fab6e1b0d23c9f80..ee8f21832f98162db93e5e117f421877576e8adf 100644 (file)
@@ -965,9 +965,8 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
        while (index < end) {
                cond_resched();
 
-               pvec.nr = find_get_entries(mapping, index, end - 1,
-                               PAGEVEC_SIZE, pvec.pages, indices);
-               if (!pvec.nr) {
+               if (!find_get_entries(mapping, index, end - 1, &pvec,
+                               indices)) {
                        /* If all gone or hole-punch or unfalloc, we're done */
                        if (index == start || end != -1)
                                break;
index cd9e1ed7e78fbe3600aaf749580c197683e968ca..d20a746a831ec138a110a1720b77c698607b3312 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -1046,9 +1046,7 @@ unsigned pagevec_lookup_entries(struct pagevec *pvec,
                struct address_space *mapping, pgoff_t start, pgoff_t end,
                pgoff_t *indices)
 {
-       pvec->nr = find_get_entries(mapping, start, end, PAGEVEC_SIZE,
-                                   pvec->pages, indices);
-       return pagevec_count(pvec);
+       return find_get_entries(mapping, start, end, pvec, indices);
 }
 
 /**
This page took 0.091263 seconds and 4 git commands to generate.