Skip to contentSkip to conversation

__add_to_swap_cache and add_to_pagecache() simplification

PATCH In review [email protected] 1 participant 1 message May 22, 2004

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 2/57 __add_to_swap_cache and add_to_pagecache() simplification

Simplify the logic in there a bit.

---

 25-akpm/mm/filemap.c    |    4 +---
 25-akpm/mm/swap_state.c |    5 ++---
 2 files changed, 3 insertions(+), 6 deletions(-)
mm/swap_state.c renamed from mm/swap_state.c~__add_to_swap_cache-simplification +2 -3
diff -puN mm/swap_state.c~__add_to_swap_cache-simplification mm/swap_state.c
@@ -68,18 +68,17 @@ static int __add_to_swap_cache(struct pa
 	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();
 	}
mm/filemap.c renamed from mm/filemap.c~__add_to_swap_cache-simplification +1 -3
diff -puN mm/filemap.c~__add_to_swap_cache-simplification mm/filemap.c
@@ -252,17 +252,15 @@ int add_to_page_cache(struct page *page,
 	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();

_

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>