diff options
author | Minchan Kim <minchan@kernel.org> | 2017-05-03 17:55:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-03 18:52:11 -0400 |
commit | 302128dce142d780417aa548bfd7ef4dfb89fa80 (patch) | |
tree | 2d3d00d6b3633f9e3d898c19c14b3a71fd6e97ed /drivers/block | |
parent | 643ae61d0f41c48aa7179921fe15ba4b4d8ddfec (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/1492052365-16169-7-git-send-email-minchan@kernel.org
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/zram/zram_drv.c | 17 |
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) | |||
480 | size_t index; | 480 | size_t index; |
481 | 481 | ||
482 | /* Free all pages that are still in this zram device */ | 482 | /* Free all pages that are still in this zram device */ |
483 | for (index = 0; index < num_pages; index++) { | 483 | for (index = 0; index < num_pages; index++) |
484 | unsigned long handle = zram_get_handle(zram, index); | 484 | zram_free_page(zram, index); |
485 | /* | ||
486 | * No memory is allocated for same element filled pages. | ||
487 | * Simply clear same page flag. | ||
488 | */ | ||
489 | if (!handle || zram_test_flag(zram, index, ZRAM_SAME)) | ||
490 | continue; | ||
491 | |||
492 | zs_free(zram->mem_pool, handle); | ||
493 | } | ||
494 | 485 | ||
495 | zs_destroy_pool(zram->mem_pool); | 486 | zs_destroy_pool(zram->mem_pool); |
496 | vfree(zram->table); | 487 | vfree(zram->table); |
@@ -978,9 +969,6 @@ static void zram_reset_device(struct zram *zram) | |||
978 | 969 | ||
979 | comp = zram->comp; | 970 | comp = zram->comp; |
980 | disksize = zram->disksize; | 971 | disksize = zram->disksize; |
981 | |||
982 | /* Reset stats */ | ||
983 | memset(&zram->stats, 0, sizeof(zram->stats)); | ||
984 | zram->disksize = 0; | 972 | zram->disksize = 0; |
985 | 973 | ||
986 | set_capacity(zram->disk, 0); | 974 | set_capacity(zram->disk, 0); |
@@ -989,6 +977,7 @@ static void zram_reset_device(struct zram *zram) | |||
989 | up_write(&zram->init_lock); | 977 | up_write(&zram->init_lock); |
990 | /* I/O operation under all of CPU are done so let's free */ | 978 | /* I/O operation under all of CPU are done so let's free */ |
991 | zram_meta_free(zram, disksize); | 979 | zram_meta_free(zram, disksize); |
980 | memset(&zram->stats, 0, sizeof(zram->stats)); | ||
992 | zcomp_destroy(comp); | 981 | zcomp_destroy(comp); |
993 | } | 982 | } |
994 | 983 | ||