Commit 7379e302 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] __add_to_swap_cache and add_to_pagecache() simplification

Simplify the logic in there a bit.
parent b6c418dc
......@@ -252,17 +252,15 @@ int add_to_page_cache(struct page *page, struct address_space *mapping,
int error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM);
if (error == 0) {
page_cache_get(page);
spin_lock_irq(&mapping->tree_lock);
error = radix_tree_insert(&mapping->page_tree, offset, page);
if (!error) {
page_cache_get(page);
SetPageLocked(page);
page->mapping = mapping;
page->index = offset;
mapping->nrpages++;
pagecache_acct(1);
} else {
page_cache_release(page);
}
spin_unlock_irq(&mapping->tree_lock);
radix_tree_preload_end();
......
......@@ -68,18 +68,17 @@ static int __add_to_swap_cache(struct page *page,
BUG_ON(PagePrivate(page));
error = radix_tree_preload(gfp_mask);
if (!error) {
page_cache_get(page);
spin_lock_irq(&swapper_space.tree_lock);
error = radix_tree_insert(&swapper_space.page_tree,
entry.val, page);
if (!error) {
page_cache_get(page);
SetPageLocked(page);
SetPageSwapCache(page);
page->private = entry.val;
total_swapcache_pages++;
pagecache_acct(1);
} else
page_cache_release(page);
}
spin_unlock_irq(&swapper_space.tree_lock);
radix_tree_preload_end();
}
......
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