Re: [PATCH 4/5] zram: remove zram_meta structure
On (04/04/17 14:40), Minchan Kim wrote: > > [..] > > > -struct zram_meta { > > > +struct zram { > > > struct zram_table_entry *table; > > > struct zs_pool *mem_pool; > > > -}; > > > - > > > -struct zram { > > > - struct zram_meta *meta; > > > struct zcomp *comp; > > > struct gendisk *disk; > > > /* Prevent concurrent execution of device init */ > > > > > > we still have several zram_meta_FOO() left overs in zram_drv.c > > I intentionally used that term because I don't think better name > to wrap logis which allocates table and mempool. ah, it was intentional. um, OK, let's keep zram_meta_foo(). -ss
Re: [PATCH 4/5] zram: remove zram_meta structure
On (04/04/17 14:40), Minchan Kim wrote: > > [..] > > > -struct zram_meta { > > > +struct zram { > > > struct zram_table_entry *table; > > > struct zs_pool *mem_pool; > > > -}; > > > - > > > -struct zram { > > > - struct zram_meta *meta; > > > struct zcomp *comp; > > > struct gendisk *disk; > > > /* Prevent concurrent execution of device init */ > > > > > > we still have several zram_meta_FOO() left overs in zram_drv.c > > I intentionally used that term because I don't think better name > to wrap logis which allocates table and mempool. ah, it was intentional. um, OK, let's keep zram_meta_foo(). -ss
Re: [PATCH 4/5] zram: remove zram_meta structure
On Tue, Apr 04, 2017 at 11:31:15AM +0900, Sergey Senozhatsky wrote: < snip > > > [..] > > -struct zram_meta { > > +struct zram { > > struct zram_table_entry *table; > > struct zs_pool *mem_pool; > > -}; > > - > > -struct zram { > > - struct zram_meta *meta; > > struct zcomp *comp; > > struct gendisk *disk; > > /* Prevent concurrent execution of device init */ > > > we still have several zram_meta_FOO() left overs in zram_drv.c I intentionally used that term because I don't think better name to wrap logis which allocates table and mempool. Feel free to suggest if you have better. Thanks.
Re: [PATCH 4/5] zram: remove zram_meta structure
On Tue, Apr 04, 2017 at 11:31:15AM +0900, Sergey Senozhatsky wrote: < snip > > > [..] > > -struct zram_meta { > > +struct zram { > > struct zram_table_entry *table; > > struct zs_pool *mem_pool; > > -}; > > - > > -struct zram { > > - struct zram_meta *meta; > > struct zcomp *comp; > > struct gendisk *disk; > > /* Prevent concurrent execution of device init */ > > > we still have several zram_meta_FOO() left overs in zram_drv.c I intentionally used that term because I don't think better name to wrap logis which allocates table and mempool. Feel free to suggest if you have better. Thanks.
Re: [PATCH 4/5] zram: remove zram_meta structure
On Tue, Apr 04, 2017 at 11:31:15AM +0900, Sergey Senozhatsky wrote: > On (04/03/17 14:17), Minchan Kim wrote: > [..] > > -static struct zram_meta *zram_meta_alloc(char *pool_name, u64 disksize) > > +static bool zram_meta_alloc(struct zram *zram, u64 disksize) > > { > > size_t num_pages; > > - struct zram_meta *meta = kmalloc(sizeof(*meta), GFP_KERNEL); > > - > > - if (!meta) > > - return NULL; > > > > num_pages = disksize >> PAGE_SHIFT; > > - meta->table = vzalloc(num_pages * sizeof(*meta->table)); > > - if (!meta->table) { > > - pr_err("Error allocating zram address table\n"); > > - goto out_error; > > - } > > + zram->table = vzalloc(num_pages * sizeof(*zram->table)); > > + if (!zram->table) > > + return false; > > > > - meta->mem_pool = zs_create_pool(pool_name); > > - if (!meta->mem_pool) { > > - pr_err("Error creating memory pool\n"); > > - goto out_error; > > + zram->mem_pool = zs_create_pool(zram->disk->disk_name); > > + if (!zram->mem_pool) { > > + vfree(zram->table); > > + return false; > > } > > > > - return meta; > > - > > -out_error: > > - vfree(meta->table); > > - kfree(meta); > > - return NULL; > > + return true; > > } > > [..] > > > @@ -1020,7 +989,6 @@ static ssize_t disksize_store(struct device *dev, > > { > > u64 disksize; > > struct zcomp *comp; > > - struct zram_meta *meta; > > struct zram *zram = dev_to_zram(dev); > > int err; > > > > @@ -1029,8 +997,7 @@ static ssize_t disksize_store(struct device *dev, > > return -EINVAL; > > > > disksize = PAGE_ALIGN(disksize); > > - meta = zram_meta_alloc(zram->disk->disk_name, disksize); > > - if (!meta) > > + if (!zram_meta_alloc(zram, disksize)) > > return -ENOMEM; > > > > comp = zcomp_create(zram->compressor); > > @@ -1048,7 +1015,6 @@ static ssize_t disksize_store(struct device *dev, > > goto out_destroy_comp; > > } > > > > - zram->meta = meta; > > zram->comp = comp; > > zram->disksize = disksize; > > set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); > > @@ -1061,7 +1027,7 @@ static ssize_t disksize_store(struct device *dev, > > up_write(>init_lock); > > zcomp_destroy(comp); > > out_free_meta: > > - zram_meta_free(meta, disksize); > > + zram_meta_free(zram, disksize); > > return err; > > } > > OK, I don't think it's the same. > > we used to have > > struct zram_meta *zram_meta_alloc() > { > meta->table = vzalloc() > meta->mem_pool = zs_create_pool(); > return meta; > } > > > disksize_store() > { > meta = zram_meta_alloc(); > if (init_done(zram)) { > pr_info("Cannot change disksize for initialized > device\n"); > goto out_destroy_comp; > } > > zram->meta = meta; > ^^ > } > > now we have > > struct zram_meta *zram_meta_alloc() > { > zram->table = vzalloc() > zram->mem_pool = zs_create_pool(); > return true; > } > > > disksize_store() > { > zram_meta_alloc(); > ^ > if (init_done(zram)) { > pr_info("Cannot change disksize for initialized > device\n"); > goto out_destroy_comp; > } > } > > > by the time we call init_done(zram) on already init device zram->table > and zram->mem_pool are overwritten and lost. right? Right you are. I will fix it! > > > [..] > > -struct zram_meta { > > +struct zram { > > struct zram_table_entry *table; > > struct zs_pool *mem_pool; > > -}; > > - > > -struct zram { > > - struct zram_meta *meta; > > struct zcomp *comp; > > struct gendisk *disk; > > /* Prevent concurrent execution of device init */ > > > we still have several zram_meta_FOO() left overs in zram_drv.c > > -ss
Re: [PATCH 4/5] zram: remove zram_meta structure
On Tue, Apr 04, 2017 at 11:31:15AM +0900, Sergey Senozhatsky wrote: > On (04/03/17 14:17), Minchan Kim wrote: > [..] > > -static struct zram_meta *zram_meta_alloc(char *pool_name, u64 disksize) > > +static bool zram_meta_alloc(struct zram *zram, u64 disksize) > > { > > size_t num_pages; > > - struct zram_meta *meta = kmalloc(sizeof(*meta), GFP_KERNEL); > > - > > - if (!meta) > > - return NULL; > > > > num_pages = disksize >> PAGE_SHIFT; > > - meta->table = vzalloc(num_pages * sizeof(*meta->table)); > > - if (!meta->table) { > > - pr_err("Error allocating zram address table\n"); > > - goto out_error; > > - } > > + zram->table = vzalloc(num_pages * sizeof(*zram->table)); > > + if (!zram->table) > > + return false; > > > > - meta->mem_pool = zs_create_pool(pool_name); > > - if (!meta->mem_pool) { > > - pr_err("Error creating memory pool\n"); > > - goto out_error; > > + zram->mem_pool = zs_create_pool(zram->disk->disk_name); > > + if (!zram->mem_pool) { > > + vfree(zram->table); > > + return false; > > } > > > > - return meta; > > - > > -out_error: > > - vfree(meta->table); > > - kfree(meta); > > - return NULL; > > + return true; > > } > > [..] > > > @@ -1020,7 +989,6 @@ static ssize_t disksize_store(struct device *dev, > > { > > u64 disksize; > > struct zcomp *comp; > > - struct zram_meta *meta; > > struct zram *zram = dev_to_zram(dev); > > int err; > > > > @@ -1029,8 +997,7 @@ static ssize_t disksize_store(struct device *dev, > > return -EINVAL; > > > > disksize = PAGE_ALIGN(disksize); > > - meta = zram_meta_alloc(zram->disk->disk_name, disksize); > > - if (!meta) > > + if (!zram_meta_alloc(zram, disksize)) > > return -ENOMEM; > > > > comp = zcomp_create(zram->compressor); > > @@ -1048,7 +1015,6 @@ static ssize_t disksize_store(struct device *dev, > > goto out_destroy_comp; > > } > > > > - zram->meta = meta; > > zram->comp = comp; > > zram->disksize = disksize; > > set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); > > @@ -1061,7 +1027,7 @@ static ssize_t disksize_store(struct device *dev, > > up_write(>init_lock); > > zcomp_destroy(comp); > > out_free_meta: > > - zram_meta_free(meta, disksize); > > + zram_meta_free(zram, disksize); > > return err; > > } > > OK, I don't think it's the same. > > we used to have > > struct zram_meta *zram_meta_alloc() > { > meta->table = vzalloc() > meta->mem_pool = zs_create_pool(); > return meta; > } > > > disksize_store() > { > meta = zram_meta_alloc(); > if (init_done(zram)) { > pr_info("Cannot change disksize for initialized > device\n"); > goto out_destroy_comp; > } > > zram->meta = meta; > ^^ > } > > now we have > > struct zram_meta *zram_meta_alloc() > { > zram->table = vzalloc() > zram->mem_pool = zs_create_pool(); > return true; > } > > > disksize_store() > { > zram_meta_alloc(); > ^ > if (init_done(zram)) { > pr_info("Cannot change disksize for initialized > device\n"); > goto out_destroy_comp; > } > } > > > by the time we call init_done(zram) on already init device zram->table > and zram->mem_pool are overwritten and lost. right? Right you are. I will fix it! > > > [..] > > -struct zram_meta { > > +struct zram { > > struct zram_table_entry *table; > > struct zs_pool *mem_pool; > > -}; > > - > > -struct zram { > > - struct zram_meta *meta; > > struct zcomp *comp; > > struct gendisk *disk; > > /* Prevent concurrent execution of device init */ > > > we still have several zram_meta_FOO() left overs in zram_drv.c > > -ss
Re: [PATCH 4/5] zram: remove zram_meta structure
On (04/03/17 14:17), Minchan Kim wrote: [..] > -static struct zram_meta *zram_meta_alloc(char *pool_name, u64 disksize) > +static bool zram_meta_alloc(struct zram *zram, u64 disksize) > { > size_t num_pages; > - struct zram_meta *meta = kmalloc(sizeof(*meta), GFP_KERNEL); > - > - if (!meta) > - return NULL; > > num_pages = disksize >> PAGE_SHIFT; > - meta->table = vzalloc(num_pages * sizeof(*meta->table)); > - if (!meta->table) { > - pr_err("Error allocating zram address table\n"); > - goto out_error; > - } > + zram->table = vzalloc(num_pages * sizeof(*zram->table)); > + if (!zram->table) > + return false; > > - meta->mem_pool = zs_create_pool(pool_name); > - if (!meta->mem_pool) { > - pr_err("Error creating memory pool\n"); > - goto out_error; > + zram->mem_pool = zs_create_pool(zram->disk->disk_name); > + if (!zram->mem_pool) { > + vfree(zram->table); > + return false; > } > > - return meta; > - > -out_error: > - vfree(meta->table); > - kfree(meta); > - return NULL; > + return true; > } [..] > @@ -1020,7 +989,6 @@ static ssize_t disksize_store(struct device *dev, > { > u64 disksize; > struct zcomp *comp; > - struct zram_meta *meta; > struct zram *zram = dev_to_zram(dev); > int err; > > @@ -1029,8 +997,7 @@ static ssize_t disksize_store(struct device *dev, > return -EINVAL; > > disksize = PAGE_ALIGN(disksize); > - meta = zram_meta_alloc(zram->disk->disk_name, disksize); > - if (!meta) > + if (!zram_meta_alloc(zram, disksize)) > return -ENOMEM; > > comp = zcomp_create(zram->compressor); > @@ -1048,7 +1015,6 @@ static ssize_t disksize_store(struct device *dev, > goto out_destroy_comp; > } > > - zram->meta = meta; > zram->comp = comp; > zram->disksize = disksize; > set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); > @@ -1061,7 +1027,7 @@ static ssize_t disksize_store(struct device *dev, > up_write(>init_lock); > zcomp_destroy(comp); > out_free_meta: > - zram_meta_free(meta, disksize); > + zram_meta_free(zram, disksize); > return err; > } OK, I don't think it's the same. we used to have struct zram_meta *zram_meta_alloc() { meta->table = vzalloc() meta->mem_pool = zs_create_pool(); return meta; } disksize_store() { meta = zram_meta_alloc(); if (init_done(zram)) { pr_info("Cannot change disksize for initialized device\n"); goto out_destroy_comp; } zram->meta = meta; ^^ } now we have struct zram_meta *zram_meta_alloc() { zram->table = vzalloc() zram->mem_pool = zs_create_pool(); return true; } disksize_store() { zram_meta_alloc(); ^ if (init_done(zram)) { pr_info("Cannot change disksize for initialized device\n"); goto out_destroy_comp; } } by the time we call init_done(zram) on already init device zram->table and zram->mem_pool are overwritten and lost. right? [..] > -struct zram_meta { > +struct zram { > struct zram_table_entry *table; > struct zs_pool *mem_pool; > -}; > - > -struct zram { > - struct zram_meta *meta; > struct zcomp *comp; > struct gendisk *disk; > /* Prevent concurrent execution of device init */ we still have several zram_meta_FOO() left overs in zram_drv.c -ss
Re: [PATCH 4/5] zram: remove zram_meta structure
On (04/03/17 14:17), Minchan Kim wrote: [..] > -static struct zram_meta *zram_meta_alloc(char *pool_name, u64 disksize) > +static bool zram_meta_alloc(struct zram *zram, u64 disksize) > { > size_t num_pages; > - struct zram_meta *meta = kmalloc(sizeof(*meta), GFP_KERNEL); > - > - if (!meta) > - return NULL; > > num_pages = disksize >> PAGE_SHIFT; > - meta->table = vzalloc(num_pages * sizeof(*meta->table)); > - if (!meta->table) { > - pr_err("Error allocating zram address table\n"); > - goto out_error; > - } > + zram->table = vzalloc(num_pages * sizeof(*zram->table)); > + if (!zram->table) > + return false; > > - meta->mem_pool = zs_create_pool(pool_name); > - if (!meta->mem_pool) { > - pr_err("Error creating memory pool\n"); > - goto out_error; > + zram->mem_pool = zs_create_pool(zram->disk->disk_name); > + if (!zram->mem_pool) { > + vfree(zram->table); > + return false; > } > > - return meta; > - > -out_error: > - vfree(meta->table); > - kfree(meta); > - return NULL; > + return true; > } [..] > @@ -1020,7 +989,6 @@ static ssize_t disksize_store(struct device *dev, > { > u64 disksize; > struct zcomp *comp; > - struct zram_meta *meta; > struct zram *zram = dev_to_zram(dev); > int err; > > @@ -1029,8 +997,7 @@ static ssize_t disksize_store(struct device *dev, > return -EINVAL; > > disksize = PAGE_ALIGN(disksize); > - meta = zram_meta_alloc(zram->disk->disk_name, disksize); > - if (!meta) > + if (!zram_meta_alloc(zram, disksize)) > return -ENOMEM; > > comp = zcomp_create(zram->compressor); > @@ -1048,7 +1015,6 @@ static ssize_t disksize_store(struct device *dev, > goto out_destroy_comp; > } > > - zram->meta = meta; > zram->comp = comp; > zram->disksize = disksize; > set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); > @@ -1061,7 +1027,7 @@ static ssize_t disksize_store(struct device *dev, > up_write(>init_lock); > zcomp_destroy(comp); > out_free_meta: > - zram_meta_free(meta, disksize); > + zram_meta_free(zram, disksize); > return err; > } OK, I don't think it's the same. we used to have struct zram_meta *zram_meta_alloc() { meta->table = vzalloc() meta->mem_pool = zs_create_pool(); return meta; } disksize_store() { meta = zram_meta_alloc(); if (init_done(zram)) { pr_info("Cannot change disksize for initialized device\n"); goto out_destroy_comp; } zram->meta = meta; ^^ } now we have struct zram_meta *zram_meta_alloc() { zram->table = vzalloc() zram->mem_pool = zs_create_pool(); return true; } disksize_store() { zram_meta_alloc(); ^ if (init_done(zram)) { pr_info("Cannot change disksize for initialized device\n"); goto out_destroy_comp; } } by the time we call init_done(zram) on already init device zram->table and zram->mem_pool are overwritten and lost. right? [..] > -struct zram_meta { > +struct zram { > struct zram_table_entry *table; > struct zs_pool *mem_pool; > -}; > - > -struct zram { > - struct zram_meta *meta; > struct zcomp *comp; > struct gendisk *disk; > /* Prevent concurrent execution of device init */ we still have several zram_meta_FOO() left overs in zram_drv.c -ss
[PATCH 4/5] zram: remove zram_meta structure
It's redundant now. Instead, remove it and use zram structure directly. Signed-off-by: Minchan Kim--- drivers/block/zram/zram_drv.c | 163 +- drivers/block/zram/zram_drv.h | 6 +- 2 files changed, 65 insertions(+), 104 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 71b0a584bc85..fdb73222841d 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -58,46 +58,46 @@ static inline struct zram *dev_to_zram(struct device *dev) } /* flag operations require table entry bit_spin_lock() being held */ -static int zram_test_flag(struct zram_meta *meta, u32 index, +static int zram_test_flag(struct zram *zram, u32 index, enum zram_pageflags flag) { - return meta->table[index].value & BIT(flag); + return zram->table[index].value & BIT(flag); } -static void zram_set_flag(struct zram_meta *meta, u32 index, +static void zram_set_flag(struct zram *zram, u32 index, enum zram_pageflags flag) { - meta->table[index].value |= BIT(flag); + zram->table[index].value |= BIT(flag); } -static void zram_clear_flag(struct zram_meta *meta, u32 index, +static void zram_clear_flag(struct zram *zram, u32 index, enum zram_pageflags flag) { - meta->table[index].value &= ~BIT(flag); + zram->table[index].value &= ~BIT(flag); } -static inline void zram_set_element(struct zram_meta *meta, u32 index, +static inline void zram_set_element(struct zram *zram, u32 index, unsigned long element) { - meta->table[index].element = element; + zram->table[index].element = element; } -static inline void zram_clear_element(struct zram_meta *meta, u32 index) +static inline void zram_clear_element(struct zram *zram, u32 index) { - meta->table[index].element = 0; + zram->table[index].element = 0; } -static size_t zram_get_obj_size(struct zram_meta *meta, u32 index) +static size_t zram_get_obj_size(struct zram *zram, u32 index) { - return meta->table[index].value & (BIT(ZRAM_FLAG_SHIFT) - 1); + return zram->table[index].value & (BIT(ZRAM_FLAG_SHIFT) - 1); } -static void zram_set_obj_size(struct zram_meta *meta, +static void zram_set_obj_size(struct zram *zram, u32 index, size_t size) { - unsigned long flags = meta->table[index].value >> ZRAM_FLAG_SHIFT; + unsigned long flags = zram->table[index].value >> ZRAM_FLAG_SHIFT; - meta->table[index].value = (flags << ZRAM_FLAG_SHIFT) | size; + zram->table[index].value = (flags << ZRAM_FLAG_SHIFT) | size; } #if PAGE_SIZE != 4096 @@ -252,9 +252,8 @@ static ssize_t mem_used_max_store(struct device *dev, down_read(>init_lock); if (init_done(zram)) { - struct zram_meta *meta = zram->meta; atomic_long_set(>stats.max_used_pages, - zs_get_total_pages(meta->mem_pool)); + zs_get_total_pages(zram->mem_pool)); } up_read(>init_lock); @@ -327,7 +326,6 @@ static ssize_t compact_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct zram *zram = dev_to_zram(dev); - struct zram_meta *meta; down_read(>init_lock); if (!init_done(zram)) { @@ -335,8 +333,7 @@ static ssize_t compact_store(struct device *dev, return -EINVAL; } - meta = zram->meta; - zs_compact(meta->mem_pool); + zs_compact(zram->mem_pool); up_read(>init_lock); return len; @@ -373,8 +370,8 @@ static ssize_t mm_stat_show(struct device *dev, down_read(>init_lock); if (init_done(zram)) { - mem_used = zs_get_total_pages(zram->meta->mem_pool); - zs_pool_stats(zram->meta->mem_pool, _stats); + mem_used = zs_get_total_pages(zram->mem_pool); + zs_pool_stats(zram->mem_pool, _stats); } orig_size = atomic64_read(>stats.pages_stored); @@ -418,32 +415,26 @@ static DEVICE_ATTR_RO(debug_stat); static void zram_slot_lock(struct zram *zram, u32 index) { - struct zram_meta *meta = zram->meta; - - bit_spin_lock(ZRAM_ACCESS, >table[index].value); + bit_spin_lock(ZRAM_ACCESS, >table[index].value); } static void zram_slot_unlock(struct zram *zram, u32 index) { - struct zram_meta *meta = zram->meta; - - bit_spin_unlock(ZRAM_ACCESS, >table[index].value); + bit_spin_unlock(ZRAM_ACCESS, >table[index].value); } static bool zram_special_page_read(struct zram *zram, u32 index, struct page *page, unsigned int offset, unsigned int len) { - struct zram_meta *meta = zram->meta; - zram_slot_lock(zram, index); - if
[PATCH 4/5] zram: remove zram_meta structure
It's redundant now. Instead, remove it and use zram structure directly. Signed-off-by: Minchan Kim --- drivers/block/zram/zram_drv.c | 163 +- drivers/block/zram/zram_drv.h | 6 +- 2 files changed, 65 insertions(+), 104 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 71b0a584bc85..fdb73222841d 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -58,46 +58,46 @@ static inline struct zram *dev_to_zram(struct device *dev) } /* flag operations require table entry bit_spin_lock() being held */ -static int zram_test_flag(struct zram_meta *meta, u32 index, +static int zram_test_flag(struct zram *zram, u32 index, enum zram_pageflags flag) { - return meta->table[index].value & BIT(flag); + return zram->table[index].value & BIT(flag); } -static void zram_set_flag(struct zram_meta *meta, u32 index, +static void zram_set_flag(struct zram *zram, u32 index, enum zram_pageflags flag) { - meta->table[index].value |= BIT(flag); + zram->table[index].value |= BIT(flag); } -static void zram_clear_flag(struct zram_meta *meta, u32 index, +static void zram_clear_flag(struct zram *zram, u32 index, enum zram_pageflags flag) { - meta->table[index].value &= ~BIT(flag); + zram->table[index].value &= ~BIT(flag); } -static inline void zram_set_element(struct zram_meta *meta, u32 index, +static inline void zram_set_element(struct zram *zram, u32 index, unsigned long element) { - meta->table[index].element = element; + zram->table[index].element = element; } -static inline void zram_clear_element(struct zram_meta *meta, u32 index) +static inline void zram_clear_element(struct zram *zram, u32 index) { - meta->table[index].element = 0; + zram->table[index].element = 0; } -static size_t zram_get_obj_size(struct zram_meta *meta, u32 index) +static size_t zram_get_obj_size(struct zram *zram, u32 index) { - return meta->table[index].value & (BIT(ZRAM_FLAG_SHIFT) - 1); + return zram->table[index].value & (BIT(ZRAM_FLAG_SHIFT) - 1); } -static void zram_set_obj_size(struct zram_meta *meta, +static void zram_set_obj_size(struct zram *zram, u32 index, size_t size) { - unsigned long flags = meta->table[index].value >> ZRAM_FLAG_SHIFT; + unsigned long flags = zram->table[index].value >> ZRAM_FLAG_SHIFT; - meta->table[index].value = (flags << ZRAM_FLAG_SHIFT) | size; + zram->table[index].value = (flags << ZRAM_FLAG_SHIFT) | size; } #if PAGE_SIZE != 4096 @@ -252,9 +252,8 @@ static ssize_t mem_used_max_store(struct device *dev, down_read(>init_lock); if (init_done(zram)) { - struct zram_meta *meta = zram->meta; atomic_long_set(>stats.max_used_pages, - zs_get_total_pages(meta->mem_pool)); + zs_get_total_pages(zram->mem_pool)); } up_read(>init_lock); @@ -327,7 +326,6 @@ static ssize_t compact_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct zram *zram = dev_to_zram(dev); - struct zram_meta *meta; down_read(>init_lock); if (!init_done(zram)) { @@ -335,8 +333,7 @@ static ssize_t compact_store(struct device *dev, return -EINVAL; } - meta = zram->meta; - zs_compact(meta->mem_pool); + zs_compact(zram->mem_pool); up_read(>init_lock); return len; @@ -373,8 +370,8 @@ static ssize_t mm_stat_show(struct device *dev, down_read(>init_lock); if (init_done(zram)) { - mem_used = zs_get_total_pages(zram->meta->mem_pool); - zs_pool_stats(zram->meta->mem_pool, _stats); + mem_used = zs_get_total_pages(zram->mem_pool); + zs_pool_stats(zram->mem_pool, _stats); } orig_size = atomic64_read(>stats.pages_stored); @@ -418,32 +415,26 @@ static DEVICE_ATTR_RO(debug_stat); static void zram_slot_lock(struct zram *zram, u32 index) { - struct zram_meta *meta = zram->meta; - - bit_spin_lock(ZRAM_ACCESS, >table[index].value); + bit_spin_lock(ZRAM_ACCESS, >table[index].value); } static void zram_slot_unlock(struct zram *zram, u32 index) { - struct zram_meta *meta = zram->meta; - - bit_spin_unlock(ZRAM_ACCESS, >table[index].value); + bit_spin_unlock(ZRAM_ACCESS, >table[index].value); } static bool zram_special_page_read(struct zram *zram, u32 index, struct page *page, unsigned int offset, unsigned int len) { - struct zram_meta *meta = zram->meta; - zram_slot_lock(zram, index); - if