aboutsummaryrefslogtreecommitdiffstats
path: root/package/system/zram-swap/files
diff options
context:
space:
mode:
authorEmil Muratov <gpm@hotplug.ru>2018-08-02 00:18:45 +0300
committerHauke Mehrtens <hauke@hauke-m.de>2018-09-29 17:23:11 +0200
commit9edc1fe8abac6638cd05640279bc741a23b8d260 (patch)
tree11f01f2944eb473a3e57f1ccd73f3fe4028c4b24 /package/system/zram-swap/files
parentb9e89adfb7881806d01e3bd259852e352f3b3ce8 (diff)
downloadupstream-9edc1fe8abac6638cd05640279bc741a23b8d260.tar.gz
upstream-9edc1fe8abac6638cd05640279bc741a23b8d260.tar.bz2
upstream-9edc1fe8abac6638cd05640279bc741a23b8d260.zip
zram-swap: fix zram dev reset for multicore cpu devices
* "zram stop" could reset up to $(num_of_cores) zram devices even if some of those were not mounted as swap dev's. This fix tries to enumerate mounted swap zram dev's before making a reset * remove hot-added zram devs on stop (except zram0) Signed-off-by: Emil Muratov <gpm@hotplug.ru>
Diffstat (limited to 'package/system/zram-swap/files')
-rw-r--r--package/system/zram-swap/files/zram.init22
1 files changed, 10 insertions, 12 deletions
diff --git a/package/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init
index 419221b1a3..1eba3f4d98 100644
--- a/package/system/zram-swap/files/zram.init
+++ b/package/system/zram-swap/files/zram.init
@@ -133,18 +133,16 @@ start()
stop()
{
- local zram_dev proc_entry
-
- for core in $( list_cpu_idx ); do {
- zram_dev="$( zram_dev "$core" )"
- proc_entry="/sys/block/$( basename "$zram_dev" )/reset"
-
- grep -sq ^"$zram_dev " /proc/swaps && {
- logger -s -t zram_stop -p daemon.debug "deactivate swap $zram_dev"
- swapoff "$zram_dev"
- }
-
- zram_reset "$zram_dev" "claiming memory back"
+ local zram_dev
+
+ for zram_dev in $( grep zram /proc/swaps |awk '{print $1}' ); do {
+ logger -s -t zram_stop -p daemon.debug "deactivate swap $zram_dev"
+ swapoff "$zram_dev" && zram_reset "$zram_dev" "claiming memory back"
+ local dev_index="$( echo $zram_dev | grep -o "[0-9]*$" )"
+ if [ $dev_index -ne 0 ]; then
+ logger -s -t zram_stop -p daemon.debug "removing zram $zram_dev"
+ echo $dev_index > /sys/class/zram-control/hot_remove
+ fi
} done
}