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>
This commit is contained in:
parent
b9e89adfb7
commit
9edc1fe8ab
1 changed files with 9 additions and 11 deletions
|
@ -133,18 +133,16 @@ start()
|
||||||
|
|
||||||
stop()
|
stop()
|
||||||
{
|
{
|
||||||
local zram_dev proc_entry
|
local zram_dev
|
||||||
|
|
||||||
for core in $( list_cpu_idx ); do {
|
for zram_dev in $( grep zram /proc/swaps |awk '{print $1}' ); do {
|
||||||
zram_dev="$( zram_dev "$core" )"
|
logger -s -t zram_stop -p daemon.debug "deactivate swap $zram_dev"
|
||||||
proc_entry="/sys/block/$( basename "$zram_dev" )/reset"
|
swapoff "$zram_dev" && zram_reset "$zram_dev" "claiming memory back"
|
||||||
|
local dev_index="$( echo $zram_dev | grep -o "[0-9]*$" )"
|
||||||
grep -sq ^"$zram_dev " /proc/swaps && {
|
if [ $dev_index -ne 0 ]; then
|
||||||
logger -s -t zram_stop -p daemon.debug "deactivate swap $zram_dev"
|
logger -s -t zram_stop -p daemon.debug "removing zram $zram_dev"
|
||||||
swapoff "$zram_dev"
|
echo $dev_index > /sys/class/zram-control/hot_remove
|
||||||
}
|
fi
|
||||||
|
|
||||||
zram_reset "$zram_dev" "claiming memory back"
|
|
||||||
} done
|
} done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue