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>