]> git.karo-electronics.de Git - karo-tx-linux.git/commit
zram: add dynamic device add/remove functionality
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Tue, 7 Apr 2015 23:44:44 +0000 (09:44 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 7 Apr 2015 23:44:44 +0000 (09:44 +1000)
commit6da19459ff4b3b23e0b69a61d8a2b9e4b106990e
treeb15dd426a163ba13e1791fa112e4cb4778ce5aec
parentd7ee706b6a8d913c9ffd7fd74c7cd40e61019538
zram: add dynamic device add/remove functionality

We currently don't support on-demand device creation.  The only way to
have N zram devices is to specify num_devices module parameter (default
value 1).  That means that if, for some reason, at some point, user wants
to have N + 1 devies he/she must umount all the existing devices, unload
the module, load the module passing num_devices equals to N + 1.  And do
this again, if needed.

Introduce zram control sysfs class, which has two sysfs attrs:
- zram_add      -- add a new specific (device_id) zram device
- zram_remove   -- remove a specific (device_id) zram device

Usage example:
# add a new specific zram device
echo 4 > /sys/class/zram-control/zram_add

# remove a specific zram device
echo 4 > /sys/class/zram-control/zram_remove

There is no automatic device_id generation, so user is expected to
provide one.

NOTE, there might be users who already depend on the fact that at
least zram0 device gets always created by zram_init(). Thus, due to
compatibility reasons, along with requested device_id (f.e. 5) zram0
will also be created.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/ABI/testing/sysfs-class-zram [new file with mode: 0644]
Documentation/blockdev/zram.txt
drivers/block/zram/zram_drv.c