aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinchan Kim <[email protected]>2017-05-03 14:55:53 -0700
committerLinus Torvalds <[email protected]>2017-05-03 15:52:11 -0700
commit302128dce142d780417aa548bfd7ef4dfb89fa80 (patch)
tree2d3d00d6b3633f9e3d898c19c14b3a71fd6e97ed
parent643ae61d0f41c48aa7179921fe15ba4b4d8ddfec (diff)
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) Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Minchan Kim <[email protected]> Cc: Hannes Reinecke <[email protected]> Cc: Johannes Thumshirn <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--drivers/block/zram/zram_drv.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 61b0f8374222..d303334e3da3 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -480,17 +480,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);
@@ -978,9 +969,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);
@@ -989,6 +977,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);
}