Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1622681 > unrolled thread

[PATCH v2 6/6] zram: use zram_free_page instead of open-coded

Started byMinchan Kim <minchan@kernel.org>
First post2017-04-13 05:10 +0200
Last post2017-04-13 05:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 6/6] zram: use zram_free_page instead of open-coded Minchan Kim <minchan@kernel.org> - 2017-04-13 05:10 +0200

#1622681 — [PATCH v2 6/6] zram: use zram_free_page instead of open-coded

FromMinchan Kim <minchan@kernel.org>
Date2017-04-13 05:10 +0200
Subject[PATCH v2 6/6] zram: use zram_free_page instead of open-coded
Message-ID<tvDiW-5jM-3@gated-at.bofh.it>
The zram_free_page already handles NULL handle case and same page
so use it to reduce error probability.
(Acutaully, I made a mistake when I handled same page feature)

Signed-off-by: Minchan Kim <minchan@kernel.org>
---
 drivers/block/zram/zram_drv.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 22b249444010..210e449af4c6 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -482,17 +482,8 @@ static void zram_meta_free(struct zram *zram, u64 disksize)
 	size_t index;
 
 	/* Free all pages that are still in this zram device */
-	for (index = 0; index < num_pages; index++) {
-		unsigned long handle = zram_get_handle(zram, index);
-		/*
-		 * No memory is allocated for same element filled pages.
-		 * Simply clear same page flag.
-		 */
-		if (!handle || zram_test_flag(zram, index, ZRAM_SAME))
-			continue;
-
-		zs_free(zram->mem_pool, handle);
-	}
+	for (index = 0; index < num_pages; index++)
+		zram_free_page(zram, index);
 
 	zs_destroy_pool(zram->mem_pool);
 	vfree(zram->table);
@@ -976,9 +967,6 @@ static void zram_reset_device(struct zram *zram)
 
 	comp = zram->comp;
 	disksize = zram->disksize;
-
-	/* Reset stats */
-	memset(&zram->stats, 0, sizeof(zram->stats));
 	zram->disksize = 0;
 
 	set_capacity(zram->disk, 0);
@@ -987,6 +975,7 @@ static void zram_reset_device(struct zram *zram)
 	up_write(&zram->init_lock);
 	/* I/O operation under all of CPU are done so let's free */
 	zram_meta_free(zram, disksize);
+	memset(&zram->stats, 0, sizeof(zram->stats));
 	zcomp_destroy(comp);
 }
 
-- 
2.7.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web