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)
{
struct page *page;
read_lock_irq(&swapper_space.tree_lock);
page = radix_tree_lookup(&swapper_space.page_tree, entry.val);
if (page) {
page_cache_get(page);
page = find_get_page(&swapper_space, entry.val);
if (page)
INC_CACHE_INFO(find_success);
}
read_unlock_irq(&swapper_space.tree_lock);
INC_CACHE_INFO(find_total);
return page;
}
......@@ -344,12 +342,7 @@ struct page *read_swap_cache_async(swp_entry_t entry,
* called after lookup_swap_cache() failed, re-calling
* that would confuse statistics.
*/
read_lock_irq(&swapper_space.tree_lock);
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);
found_page = find_get_page(&swapper_space, entry.val);
if (found_page)
break;
......
......@@ -391,14 +391,8 @@ void free_swap_and_cache(swp_entry_t entry)
p = swap_info_get(entry);
if (p) {
if (swap_entry_free(p, swp_offset(entry)) == 1) {
read_lock_irq(&swapper_space.tree_lock);
page = radix_tree_lookup(&swapper_space.page_tree,
entry.val);
if (page && TestSetPageLocked(page))
page = NULL;
read_unlock_irq(&swapper_space.tree_lock);
}
if (swap_entry_free(p, swp_offset(entry)) == 1)
page = find_trylock_page(&swapper_space, entry.val);
swap_info_put(p);
}
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