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