forked from Freescale/linux-fslc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zram: add dynamic device add/remove functionality
We currently don't support on-demand device creation. The one and only way to have N zram devices is to specify num_devices module parameter (default value: 1). IOW 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. This patch introduces zram control sysfs class, which has two sysfs attrs: - hot_add -- add a new zram device - hot_remove -- remove a specific (device_id) zram device hot_add sysfs attr is read-only and has only automatic device id assignment mode (as requested by Minchan Kim). read operation performed on this attr creates a new zram device and returns back its device_id or error status. Usage example: # add a new specific zram device cat /sys/class/zram-control/hot_add 2 # remove a specific zram device echo 4 > /sys/class/zram-control/hot_remove Returning zram_add() error code back to user (-ENOMEM in this case) cat /sys/class/zram-control/hot_add cat: /sys/class/zram-control/hot_add: Cannot allocate memory NOTE, there might be users who already depend on the fact that at least zram0 device gets always created by zram_init(). Preserve this behavior. [minchan@kernel.org: use zram->claim to avoid lockdep splat] Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Cc: Minchan Kim <minchan@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
- Loading branch information
1 parent
f405c44
commit 6566d1a
Showing
3 changed files
with
141 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
What: /sys/class/zram-control/ | ||
Date: August 2015 | ||
KernelVersion: 4.2 | ||
Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | ||
Description: | ||
The zram-control/ class sub-directory belongs to zram | ||
device class | ||
|
||
What: /sys/class/zram-control/hot_add | ||
Date: August 2015 | ||
KernelVersion: 4.2 | ||
Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | ||
Description: | ||
RO attribute. Read operation will cause zram to add a new | ||
device and return its device id back to user (so one can | ||
use /dev/zram<id>), or error code. | ||
|
||
What: /sys/class/zram-control/hot_remove | ||
Date: August 2015 | ||
KernelVersion: 4.2 | ||
Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | ||
Description: | ||
WO attribute. Remove a specific /dev/zramX device, where X | ||
is a device_id provided by user. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters