swap: Do not setup swap after resourced restart 92/189992/1
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Tue, 25 Sep 2018 15:12:55 +0000 (17:12 +0200)
committerPaweł Szewczyk <p.szewczyk@samsung.com>
Tue, 25 Sep 2018 15:26:07 +0000 (17:26 +0200)
To avoid reconfiguration and possible loss of swapped data, or setting
up multiple swap devices, we assume that swap is configured after boot
and survive resourced restarts.
The side effect is that for change of swap configuration a reboot is
needed.

Change-Id: I874be98ed2a491ce932202987ae99113aa2519c0
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
src/swap/swap.c

index 9451882..ff89f7c 100644 (file)
@@ -53,6 +53,7 @@
 #include "proc-main.h"
 #include "util.h"
 #include "losetup.h"
+#include "init.h"
 
 #define MEMCG_PATH                     "/sys/fs/cgroup/memory/"
 #define MEMCG_SIZE_LIMIT               "memory.limit_in_bytes"
@@ -1008,6 +1009,11 @@ static int swap_init(void)
        if (!arg_swap_enable)
                return -ENODEV;
 
+       if (resourced_restarted()) {
+               _I("Assuming swap is already set up. To reconfigure, reboot the device.");
+               return 0;
+       }
+
        gslist_for_each_safe(swap_module, iter, next, swaps) {
                swaps = (struct swap_module_ops *)iter->data;
                if (!CHECK_BIT(arg_swap_type, swaps->type)) {