Skip to contentSkip to conversation

zram: use zram_free_page instead of open-coded

PATCH New [email protected] 1 participant 1 message May 3, 2017

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

PATCH 84/102 zram: use zram_free_page instead of open-coded

From: Minchan Kim <[email protected]>
Subject: zram: use zram_free_page instead of open-coded

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)

---

 drivers/block/zram/zram_drv.c |   17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/block/zram/zram_drv.c renamed from drivers/block/zram/zram_drv.c~zram-use-zram_free_page-instead-of-open-coded +2 -11
diff -puN drivers/block/zram/zram_drv.c~zram-use-zram_free_page-instead-of-open-coded drivers/block/zram/zram_drv.c
@@ -480,17 +480,8 @@ static void zram_meta_free(struct zram *
 	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);
@@ -978,9 +969,6 @@ static void zram_reset_device(struct zra
 
 	comp = zram->comp;
 	disksize = zram->disksize;