Subject: + zram-delete-zram_init_device.patch added to -mm tree To: sergey.senozhatsky@xxxxxxxxx,minchan@xxxxxxxxxx From: akpm@xxxxxxxxxxxxxxxxxxxx Date: Tue, 25 Feb 2014 12:28:25 -0800 The patch titled Subject: zram: delete zram_init_device() has been added to the -mm tree. Its filename is zram-delete-zram_init_device.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/zram-delete-zram_init_device.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/zram-delete-zram_init_device.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: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx> Subject: zram: delete zram_init_device() allocate new `zram_meta' in disksize_store() only for uninitialised zram device, saving a number of allocations and deallocations in case if disksize_store() was called on currently used device. at the same time zram_meta stack variable is not necessary, because we can set ->meta directly. there is also no need in setting QUEUE_FLAG_NONROT queue on every disksize_store(), set it once during device creation. [minchan@xxxxxxxxxx]: handled zram->meta alloc fail case. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx> Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/block/zram/zram_drv.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff -puN drivers/block/zram/zram_drv.c~zram-delete-zram_init_device drivers/block/zram/zram_drv.c --- a/drivers/block/zram/zram_drv.c~zram-delete-zram_init_device +++ a/drivers/block/zram/zram_drv.c @@ -533,40 +533,32 @@ static void zram_reset_device(struct zra up_write(&zram->init_lock); } -static void zram_init_device(struct zram *zram, struct zram_meta *meta) -{ - /* zram devices sort of resembles non-rotational disks */ - queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue); - zram->meta = meta; - pr_debug("Initialization done!\n"); -} - static ssize_t disksize_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { u64 disksize; - struct zram_meta *meta; struct zram *zram = dev_to_zram(dev); disksize = memparse(buf, NULL); if (!disksize) return -EINVAL; - disksize = PAGE_ALIGN(disksize); - meta = zram_meta_alloc(disksize); - if (!meta) - return -ENOMEM; down_write(&zram->init_lock); if (init_done(zram)) { up_write(&zram->init_lock); - zram_meta_free(meta); pr_info("Cannot change disksize for initialized device\n"); return -EBUSY; } + disksize = PAGE_ALIGN(disksize); + zram->meta = zram_meta_alloc(disksize); + if (!zram->meta) { + up_write(&zram->init_lock); + return -ENOMEM; + } + zram->disksize = disksize; set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); - zram_init_device(zram, meta); up_write(&zram->init_lock); return len; @@ -776,7 +768,8 @@ static int create_device(struct zram *zr /* Actual capacity set using syfs (/sys/block/zram<id>/disksize */ set_capacity(zram->disk, 0); - + /* zram devices sort of resembles non-rotational disks */ + queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue); /* * To ensure that we always get PAGE_SIZE aligned * and n*PAGE_SIZED sized I/O requests. _ Patches currently in -mm which might be from sergey.senozhatsky@xxxxxxxxx are zram-drop-init_done-struct-zram-member.patch zram-do-not-pass-rw-argument-to-__zram_make_request.patch zram-remove-good-and-bad-compress-stats.patch zram-use-atomic64_t-for-all-zram-stats.patch zram-remove-zram-stats-code-duplication.patch zram-report-failed-read-and-write-stats.patch zram-drop-not-used-table-count-member.patch zram-move-zram-size-warning-to-documentation.patch zram-document-failed_reads-failed_writes-stats.patch zram-delete-zram_init_device.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