Author: eelco Date: 2010-06-09 22:29:06 +0000 (Wed, 09 Jun 2010) New Revision: 22204
You can view the changes in this commit at: https://svn.nixos.org/viewvc/nix?rev=22204&view=rev Modified: nixos/branches/boot-order/modules/services/network-filesystems/nfs-kernel.nix nixos/branches/boot-order/modules/services/networking/portmap.nix nixos/branches/boot-order/modules/system/activation/activation-script.nix nixos/branches/boot-order/modules/system/boot/stage-2-init.sh nixos/branches/boot-order/modules/system/upstart-events/shutdown.nix nixos/branches/boot-order/tests/nfs.nix Log: * Put all of /var/run (not just /var/run/nscd) on a tmpfs to simplify shutdown. (Portmap and statd are needed during shutdown to unmount NFS volumes but have open files in /var/run.) * In the shutdown job, don't kill PIDs belonging to Upstart jobs that are still running. If they don't stop on the "starting shutdown" event, then they're needed during shutdown (such as portmap and statd). * NFS test: test whether the shutdown quickly unmounts NFS volumes (i.e. whether portmap and statd are still running). Changes: Modified: nixos/branches/boot-order/modules/services/network-filesystems/nfs-kernel.nix =================================================================== --- nixos/branches/boot-order/modules/services/network-filesystems/nfs-kernel.nix 2010-06-09 21:48:51 UTC (rev 22203) +++ nixos/branches/boot-order/modules/services/network-filesystems/nfs-kernel.nix 2010-06-09 22:29:06 UTC (rev 22204) @@ -162,7 +162,7 @@ description = "Kernel NFS server - Network Status Monitor"; startOn = "${if cfg.server.enable then "starting nfs-kernel-nfsd and " else ""} started portmap"; - stopOn = if cfg.server.enable then "stopped nfs-kernel-nfsd" else "starting shutdown"; + stopOn = "never"; preStart = '' Modified: nixos/branches/boot-order/modules/services/networking/portmap.nix =================================================================== --- nixos/branches/boot-order/modules/services/networking/portmap.nix 2010-06-09 21:48:51 UTC (rev 22203) +++ nixos/branches/boot-order/modules/services/networking/portmap.nix 2010-06-09 22:29:06 UTC (rev 22204) @@ -67,6 +67,7 @@ { description = "ONC RPC portmap"; startOn = "started network-interfaces"; + stopOn = "never"; daemonType = "fork"; Modified: nixos/branches/boot-order/modules/system/activation/activation-script.nix =================================================================== --- nixos/branches/boot-order/modules/system/activation/activation-script.nix 2010-06-09 21:48:51 UTC (rev 22203) +++ nixos/branches/boot-order/modules/system/activation/activation-script.nix 2010-06-09 22:29:06 UTC (rev 22204) @@ -75,7 +75,6 @@ var = fullDepEntry '' # Various log/runtime directories. - mkdir -m 0755 -p /var/run touch /var/run/utmp # must exist chgrp ${toString config.ids.gids.utmp} /var/run/utmp @@ -84,16 +83,6 @@ mkdir -m 0755 -p /var/run/nix/current-load # for distributed builds mkdir -m 0700 -p /var/run/nix/remote-stores - # Use a tmpfs for /var/run/nscd to ensure that / or /var can be - # unmounted or at least remounted read-only during shutdown. - # (Upstart 0.6 apparently uses nscd to do some name lookups, - # resulting in it holding some mmap mapping to deleted files in - # /var/run/nscd.) - if [ ! -e /var/run/nscd ]; then - mkdir -p /var/run/nscd - ${pkgs.utillinux}/bin/mount -t tmpfs -o "mode=755" none /var/run/nscd - fi - mkdir -m 0755 -p /var/log mkdir -m 0755 -p /var/log/upstart Modified: nixos/branches/boot-order/modules/system/boot/stage-2-init.sh =================================================================== --- nixos/branches/boot-order/modules/system/boot/stage-2-init.sh 2010-06-09 21:48:51 UTC (rev 22203) +++ nixos/branches/boot-order/modules/system/boot/stage-2-init.sh 2010-06-09 22:29:06 UTC (rev 22204) @@ -109,6 +109,16 @@ rm -rf /nix/var/nix/chroots # recreated in activate-configuration.sh +# Use a tmpfs for /var/run to ensure that / or /var can be unmounted +# or at least remounted read-only during shutdown. (Upstart 0.6 +# apparently uses nscd to do some name lookups, resulting in it +# holding some mmap mapping to deleted files in /var/run/nscd. +# Similarly, portmap and statd have open files in /var/run and are +# needed during shutdown to unmount NFS volumes.) +mkdir -m 0755 -p /var/run +mount -t tmpfs -o "mode=755" none /var/run + + # Clear the resume device. if test -n "$resumeDevice"; then mkswap "$resumeDevice" || echo 'Failed to clear saved image.' Modified: nixos/branches/boot-order/modules/system/upstart-events/shutdown.nix =================================================================== --- nixos/branches/boot-order/modules/system/upstart-events/shutdown.nix 2010-06-09 21:48:51 UTC (rev 22203) +++ nixos/branches/boot-order/modules/system/upstart-events/shutdown.nix 2010-06-09 22:29:06 UTC (rev 22204) @@ -37,14 +37,19 @@ sync - # Kill all remaining processes except init and this one. + # Kill all remaining processes except init, this one and any + # Upstart jobs that don't stop on the "starting shutdown" + # event, as these are necessary to complete the shutdown. + omittedPids=$(initctl list | sed -e 's/.*process \([0-9]\+\)/-o \1/;t;d') + #echo "saved PIDs: $omittedPids" + echo "sending the TERM signal to all processes..." - kill -TERM -1 + ${pkgs.sysvtools}/bin/killall5 -15 $job $omittedPids sleep 1 # wait briefly echo "sending the KILL signal to all processes..." - kill -KILL -1 + ${pkgs.sysvtools}/bin/killall5 -9 $job $omittedPids # If maintenance mode is requested, start a root shell, and @@ -71,8 +76,8 @@ # Stop all swap devices. swapoff -a - - + + # Unmount file systems. We repeat this until no more file systems # can be unmounted. This is to handle loopback devices, file # systems mounted on other file systems and so on. @@ -84,7 +89,7 @@ cp /proc/mounts /dev/.mounts # don't read /proc/mounts while it's changing exec 4< /dev/.mounts while read -u 4 device mp fstype options rest; do - if [ "$mp" = /proc -o "$mp" = /sys -o "$mp" = /dev -o "$device" = "rootfs" -o "$mp" = /var/run/nscd ]; then continue; fi + if [ "$mp" = /proc -o "$mp" = /sys -o "$mp" = /dev -o "$device" = "rootfs" -o "$mp" = /var/run ]; then continue; fi echo "unmounting $mp..." Modified: nixos/branches/boot-order/tests/nfs.nix =================================================================== --- nixos/branches/boot-order/tests/nfs.nix 2010-06-09 21:48:51 UTC (rev 22203) +++ nixos/branches/boot-order/tests/nfs.nix 2010-06-09 22:29:06 UTC (rev 22204) @@ -71,6 +71,14 @@ $server->start; $client1->succeed("touch /data/xyzzy"); $client1->fail("time flock -n -s /data/lock true"); + + # Test whether unmounting during shutdown happens quickly. This + # requires portmap and statd to keep running during the + # shutdown. + my $t1 = time; + $client1->shutdown; + my $duration = time - $t1; + die "shutdown took too long ($duration seconds)" if $duration > 30; ''; } _______________________________________________ nix-commits mailing list [email protected] http://mail.cs.uu.nl/mailman/listinfo/nix-commits
