]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
shmem: Convert shmem_partial_swap_usage to XArray
authorMatthew Wilcox <willy@infradead.org>
Mon, 4 Dec 2017 08:28:00 +0000 (03:28 -0500)
committerMatthew Wilcox <willy@infradead.org>
Sun, 21 Oct 2018 14:46:40 +0000 (10:46 -0400)
Simpler code because the xarray takes care of things like the limit and
dereferencing the slot.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
mm/shmem.c

index 8e9bbfb7ed154ea0656c93d2983fcda1c6c3486c..5588205f42594ccf067beba03f1a3cb3b69bac47 100644 (file)
@@ -676,29 +676,19 @@ static int shmem_free_swap(struct address_space *mapping,
 unsigned long shmem_partial_swap_usage(struct address_space *mapping,
                                                pgoff_t start, pgoff_t end)
 {
-       struct radix_tree_iter iter;
-       void __rcu **slot;
+       XA_STATE(xas, &mapping->i_pages, start);
        struct page *page;
        unsigned long swapped = 0;
 
        rcu_read_lock();
-
-       radix_tree_for_each_slot(slot, &mapping->i_pages, &iter, start) {
-               if (iter.index >= end)
-                       break;
-
-               page = radix_tree_deref_slot(slot);
-
-               if (radix_tree_deref_retry(page)) {
-                       slot = radix_tree_iter_retry(&iter);
+       xas_for_each(&xas, page, end - 1) {
+               if (xas_retry(&xas, page))
                        continue;
-               }
-
                if (xa_is_value(page))
                        swapped++;
 
                if (need_resched()) {
-                       slot = radix_tree_iter_resume(slot, &iter);
+                       xas_pause(&xas);
                        cond_resched_rcu();
                }
        }