The patch titled Subject: zram: free meta table in zram_meta_free has been added to the -mm tree. Its filename is zram-free-meta-table-in-zram_meta_free.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/zram-free-meta-table-in-zram_meta_free.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/zram-free-meta-table-in-zram_meta_free.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ganesh Mahendran <opensource.ganesh@xxxxxxxxx> Subject: zram: free meta table in zram_meta_free zram_meta_alloc() and zram_meta_free() are a pair. In zram_meta_alloc(), meta table is allocated. So it it better to free it in zram_meta_free(). Signed-off-by: Ganesh Mahendran <opensource.ganesh@xxxxxxxxx> Acked-by: Minchan Kim <minchan@xxxxxxxxxx> Acked-by: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx> Cc: Nitin Gupta <ngupta@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/block/zram/zram_drv.c | 33 +++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff -puN drivers/block/zram/zram_drv.c~zram-free-meta-table-in-zram_meta_free drivers/block/zram/zram_drv.c --- a/drivers/block/zram/zram_drv.c~zram-free-meta-table-in-zram_meta_free +++ a/drivers/block/zram/zram_drv.c @@ -307,8 +307,21 @@ static inline int valid_io_request(struc return 1; } -static void zram_meta_free(struct zram_meta *meta) +static void zram_meta_free(struct zram_meta *meta, u64 disksize) { + size_t num_pages = disksize >> PAGE_SHIFT; + size_t index; + + /* Free all pages that are still in this zram device */ + for (index = 0; index < num_pages; index++) { + unsigned long handle = meta->table[index].handle; + + if (!handle) + continue; + + zs_free(meta->mem_pool, handle); + } + zs_destroy_pool(meta->mem_pool); vfree(meta->table); kfree(meta); @@ -704,9 +717,6 @@ static void zram_bio_discard(struct zram static void zram_reset_device(struct zram *zram, bool reset_capacity) { - size_t index; - struct zram_meta *meta; - down_write(&zram->init_lock); zram->limit_pages = 0; @@ -716,20 +726,9 @@ static void zram_reset_device(struct zra return; } - meta = zram->meta; - /* Free all pages that are still in this zram device */ - for (index = 0; index < zram->disksize >> PAGE_SHIFT; index++) { - unsigned long handle = meta->table[index].handle; - if (!handle) - continue; - - zs_free(meta->mem_pool, handle); - } - zcomp_destroy(zram->comp); zram->max_comp_streams = 1; - - zram_meta_free(zram->meta); + zram_meta_free(zram->meta, zram->disksize); zram->meta = NULL; /* Reset stats */ memset(&zram->stats, 0, sizeof(zram->stats)); @@ -801,7 +800,7 @@ out_destroy_comp: up_write(&zram->init_lock); zcomp_destroy(comp); out_free_meta: - zram_meta_free(meta); + zram_meta_free(meta, disksize); return err; } _ Patches currently in -mm which might be from opensource.ganesh@xxxxxxxxx are zram-free-meta-table-in-zram_meta_free.patch mm-zpool-add-name-argument-to-create-zpool.patch mm-zsmalloc-add-statistics-support.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html