mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nitin Gupta <ngupta@vflare.org>
To: Greg KH <greg@kroah.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH 5/7] Remove redundant check for zero page
Date: Thu, 28 Jan 2010 21:13:41 +0530	[thread overview]
Message-ID: <1264693423-2694-6-git-send-email-ngupta@vflare.org> (raw)
In-Reply-To: <1264693423-2694-1-git-send-email-ngupta@vflare.org>

ramzswap_free_page() already handles the case for zero filled
pages. So, remove redundant logic for the same in ramzswap_write().

Signed-off-by: Nitin Gupta <ngupta@vflare.org>
---
 drivers/staging/ramzswap/ramzswap_drv.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/ramzswap/ramzswap_drv.c b/drivers/staging/ramzswap/ramzswap_drv.c
index 3035add..7e0a3fa 100644
--- a/drivers/staging/ramzswap/ramzswap_drv.c
+++ b/drivers/staging/ramzswap/ramzswap_drv.c
@@ -593,6 +593,10 @@ static void ramzswap_free_page(struct ramzswap *rzs, size_t index)
 	u32 offset = rzs->table[index].offset;
 
 	if (unlikely(!page)) {
+		/*
+		 * No memory is allocated for zero filled pages.
+		 * Simply clear zero page flag.
+		 */
 		if (rzs_test_flag(rzs, index, RZS_ZERO)) {
 			rzs_clear_flag(rzs, index, RZS_ZERO);
 			rzs_stat_dec(&rzs->stats.pages_zero);
@@ -789,18 +793,9 @@ static int ramzswap_write(struct ramzswap *rzs, struct bio *bio)
 	 * is no longer referenced by any process. So, its now safe
 	 * to free the memory that was allocated for this page.
 	 */
-	if (rzs->table[index].page)
+	if (rzs->table[index].page || rzs_test_flag(rzs, index, RZS_ZERO))
 		ramzswap_free_page(rzs, index);
 
-	/*
-	 * No memory is allocated for zero filled pages.
-	 * Simply clear zero page flag.
-	 */
-	if (rzs_test_flag(rzs, index, RZS_ZERO)) {
-		rzs_stat_dec(&rzs->stats.pages_zero);
-		rzs_clear_flag(rzs, index, RZS_ZERO);
-	}
-
 	mutex_lock(&rzs->lock);
 
 	user_mem = kmap_atomic(page, KM_USER0);
-- 
1.6.2.5


  parent reply	other threads:[~2010-01-28 15:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-28 15:43 [PATCH 0/7][linux-next v2] ramzswap: bug fixes and some cleanups Nitin Gupta
2010-01-28 15:43 ` [PATCH 1/7] Use lock for 64-bit stats Nitin Gupta
2010-01-28 15:43 ` [PATCH 2/7] Flush block device before reset Nitin Gupta
2010-01-28 15:43 ` [PATCH 3/7] Set block size to PAGE_SIZE Nitin Gupta
2010-01-28 15:43 ` [PATCH 4/7] Return proper error code on device create failure Nitin Gupta
2010-01-28 15:43 ` Nitin Gupta [this message]
2010-01-28 15:49 ` [PATCH 6/7] Handle case for invalid backing swap Nitin Gupta
2010-01-28 15:51 ` [PATCH 7/7] Update copyright notice Nitin Gupta

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=1264693423-2694-6-git-send-email-ngupta@vflare.org \
    --to=ngupta@vflare.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    /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

all inboxes | Powered by JetHome®