linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: akpm@osdl.org
To: torvalds@osdl.org
Cc: linux-mm@kvack.org, akpm@osdl.org
Subject: [patch 02/57] __add_to_swap_cache and add_to_pagecache() simplification
Date: Sat, 22 May 2004 15:01:01 -0700	[thread overview]
Message-ID: <200405222201.i4MM1Wr11300@mail.osdl.org> (raw)


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(-)

diff -puN mm/swap_state.c~__add_to_swap_cache-simplification mm/swap_state.c
--- 25/mm/swap_state.c~__add_to_swap_cache-simplification	2004-05-22 14:56:21.375841904 -0700
+++ 25-akpm/mm/swap_state.c	2004-05-22 14:59:44.832911728 -0700
@@ -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();
 	}
diff -puN mm/filemap.c~__add_to_swap_cache-simplification mm/filemap.c
--- 25/mm/filemap.c~__add_to_swap_cache-simplification	2004-05-22 14:56:21.376841752 -0700
+++ 25-akpm/mm/filemap.c	2004-05-22 14:59:44.199008096 -0700
@@ -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 majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

                 reply	other threads:[~2004-05-22 22:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200405222201.i4MM1Wr11300@mail.osdl.org \
    --to=akpm@osdl.org \
    --cc=linux-mm@kvack.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox