+ zram-delete-zram_init_device.patch added to -mm tree
Subsystems (2)
Subject: + zram-delete-zram_init_device.patch added to -mm tree
To: [email protected],[email protected]
From: [email protected]
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 <[email protected]>
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.
[[email protected]]: handled zram->meta alloc fail case.
---
drivers/block/zram/zram_drv.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/block/zram/zram_drv.c renamed from drivers/block/zram/zram_drv.c~zram-delete-zram_init_device +7 -15
@@ -533,40 +533,32 @@ static void zram_reset_device(struct zraup_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 );