[arch-projects] [PATCH 1/2] rc.shutdown: reorder a bit

Tom Gundersen teg at jklm.no
Sat Oct 29 18:00:08 EDT 2011


The new ordering is now:

1) book-keeping
2) shutting down and killing processes
3) swapoff
4) unmounting and tearing down of block devices

The reason to move 1) to the top is so it will not interfere with
the killing of processes. The reason for not moving 3) to the top
as well is that we want to minimize the amount of stuff that has to
be moved from swap to ram.

However, swapoff must happen before 4) as we don't know what is under
the swap device/file.

Added a TODO: unmount any devices backed by swap (tmpfs/ramfs) to make
sure that their contents is thrown away rather than moved to ram. In
principle we might get OOM on shutdown due to the current situation,
but in most cases the only problem should be that shutdown is unecessarily
slow.

Thanks to Dan and Dave for prompting me to look into this.

Cc: Dan McGee <dpmcgee at gmail.com>
Cc: Dave Reisner <d at falconindy.com>
Signed-off-by: Tom Gundersen <teg at jklm.no>
---
 rc.shutdown |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/rc.shutdown b/rc.shutdown
index 5928b2d..1946068 100755
--- a/rc.shutdown
+++ b/rc.shutdown
@@ -19,20 +19,6 @@ run_hook shutdown_start
 
 stop_all_daemons
 
-status "Shutting down UDev" udevadm control --exit
-
-status "Deactivating Swap" swapoff -a
-
-# stop monitoring of lvm2 groups before unmounting filesystems
-[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) ]] &&
-	status "Deactivating monitoring of LVM2 groups" vgchange --monitor n
-
-run_hook shutdown_prekillall
-
-kill_all
-
-run_hook shutdown_postkillall
-
 stat_busy "Saving Random Seed"
 	RANDOM_SEED=/var/lib/misc/random-seed
 	install -TDm 0600 /dev/null $RANDOM_SEED
@@ -51,6 +37,26 @@ stat_done
 # Write to wtmp file before unmounting
 halt -w
 
+# stop monitoring of lvm2 groups before unmounting filesystems
+[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) ]] &&
+	status "Deactivating monitoring of LVM2 groups" vgchange --monitor n
+
+# any future uevents can and should be ignored
+status "Shutting down UDev" udevadm control --exit
+
+run_hook shutdown_prekillall
+
+kill_all
+
+run_hook shutdown_postkillall
+
+# TODO: unmount any non-api partitions that are backed by swap, we don't want to
+#       move their contents into memory (waste of time and might caues OOM).
+
+# almost everything is dead now, so the swap should hopefully be relatively
+# empty, and quick to switch off
+status "Deactivating Swap" swapoff -a
+
 # if we don't have devtmpfs support, /dev is mounted as tmpfs, so don't unmount it
 status "Unmounting Filesystems" \
 	umount -a -r -t nodevtmpfs,notmpfs,nosysfs,noproc,nodevpts -O no_netdev
-- 
1.7.7.1



More information about the arch-projects mailing list