Commit 01b1ec7c authored by Marcelo Tosatti's avatar Marcelo Tosatti Committed by Linus Torvalds

[PATCH] use find_trylock_page in free_swap_and_cache instead of hand coding

Use find_*_page helpers in swap code instead handcoding it.
Signed-off-by: default avatarMarcelo Tosatti <marcelo.tosatti@cyclades.com>
Acked-by: default avatarHugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 577a3dd8
...@@ -315,13 +315,11 @@ struct page * lookup_swap_cache(swp_entry_t entry) ...@@ -315,13 +315,11 @@ struct page * lookup_swap_cache(swp_entry_t entry)
{ {
struct page *page; struct page *page;
read_lock_irq(&swapper_space.tree_lock); page = find_get_page(&swapper_space, entry.val);
page = radix_tree_lookup(&swapper_space.page_tree, entry.val);
if (page) { if (page)
page_cache_get(page);
INC_CACHE_INFO(find_success); INC_CACHE_INFO(find_success);
}
read_unlock_irq(&swapper_space.tree_lock);
INC_CACHE_INFO(find_total); INC_CACHE_INFO(find_total);
return page; return page;
} }
...@@ -344,12 +342,7 @@ struct page *read_swap_cache_async(swp_entry_t entry, ...@@ -344,12 +342,7 @@ struct page *read_swap_cache_async(swp_entry_t entry,
* called after lookup_swap_cache() failed, re-calling * called after lookup_swap_cache() failed, re-calling
* that would confuse statistics. * that would confuse statistics.
*/ */
read_lock_irq(&swapper_space.tree_lock); found_page = find_get_page(&swapper_space, entry.val);
found_page = radix_tree_lookup(&swapper_space.page_tree,
entry.val);
if (found_page)
page_cache_get(found_page);
read_unlock_irq(&swapper_space.tree_lock);
if (found_page) if (found_page)
break; break;
......
...@@ -391,14 +391,8 @@ void free_swap_and_cache(swp_entry_t entry) ...@@ -391,14 +391,8 @@ void free_swap_and_cache(swp_entry_t entry)
p = swap_info_get(entry); p = swap_info_get(entry);
if (p) { if (p) {
if (swap_entry_free(p, swp_offset(entry)) == 1) { if (swap_entry_free(p, swp_offset(entry)) == 1)
read_lock_irq(&swapper_space.tree_lock); page = find_trylock_page(&swapper_space, entry.val);
page = radix_tree_lookup(&swapper_space.page_tree,
entry.val);
if (page && TestSetPageLocked(page))
page = NULL;
read_unlock_irq(&swapper_space.tree_lock);
}
swap_info_put(p); swap_info_put(p);
} }
if (page) { if (page) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment