From: Minchan Kim Date: Wed, 3 May 2017 21:55:53 +0000 (-0700) Subject: UPSTREAM: zram: use zram_free_page instead of open-coded X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9b0cba96cf111c77d6eb797c67095021f2b66dc7;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git UPSTREAM: 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/1492052365-16169-7-git-send-email-minchan@kernel.org Signed-off-by: Minchan Kim Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Sergey Senozhatsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit 302128dce142d780417aa548bfd7ef4dfb89fa80) Signed-off-by: Peter Kalauskas Bug: 112488418 Change-Id: Ie38c52dfb1959377936b7cd9158ad1b5a02219bd --- diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index cde2129304d6..2dbd39781254 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -479,17 +479,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); @@ -972,9 +963,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); @@ -983,6 +971,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); }