From 94e148ff47e85c6c69badcd51ce868f849efb95d Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 15 Feb 2018 10:31:59 +0100 Subject: [PATCH 1/4] Import lazy-umount-nfs.service Import existing systemd service file into repository. We had the problem, that systemd tries to unmount all mounted file systems after the network already shut down and in the case of nfs mounts, this made it wait a long time for timeouts. This service is supposed to remove the unmountable nfs mounts from the mount tree (by layz umount) so that systemd doesn't not attempt to dismount them again. A clean unmount of the nfs mounts has already been attempted (by shutdown of automount), so we only have those nfs mounts left over, which are locked and can't be dismounted anyway. --- install.sh | 1 + misc_systemd_units/lazy-umount-nfs.service | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 misc_systemd_units/lazy-umount-nfs.service diff --git a/install.sh b/install.sh index dead3e32..7432e51e 100755 --- a/install.sh +++ b/install.sh @@ -76,6 +76,7 @@ mkdir -p "$DESTDIR$usrlocal_bindir" install_exec make-automaps/make-automaps "$DESTDIR$usr_sbindir/make-automaps" install_data misc_systemd_units/automount.service "$DESTDIR$systemdunitdir/automount.service" install_data misc_systemd_units/gdm.service "$DESTDIR$systemdunitdir/gdm.service" +install_data misc_systemd_units/lazy-umount-nfs.service "$DESTDIR$systemdunitdir/lazy-umount-nfs.service" install_exec mxgrub/mxgrub "$DESTDIR$usr_sbindir/mxgrub" install_exec mxnetctl/mxnetctl "$DESTDIR$usr_sbindir/mxnetctl" install_exec mxrouter/mxrouterctl "$DESTDIR$usr_sbindir/mxrouterctl" diff --git a/misc_systemd_units/lazy-umount-nfs.service b/misc_systemd_units/lazy-umount-nfs.service new file mode 100644 index 00000000..c5a77e9d --- /dev/null +++ b/misc_systemd_units/lazy-umount-nfs.service @@ -0,0 +1,12 @@ +[Unit] +Description=Lazy Umount NFS +Before=halt.service reboot.service poweroff.service +DefaultDependencies=false + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/umount -a -t nfs4 -l + +[Install] +WantedBy=halt.service reboot.service poweroff.service From c91c4e41b0899ad98097c7b82b0326092ef70bf3 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 15 Feb 2018 10:44:39 +0100 Subject: [PATCH 2/4] lazy-umount-nfs.service: Bind to shutdown.target Use shutdown.target as a synchronization point instead of individual shutdown/reboot services. shutdown.target has RequiredBy=halt.service reboot.service poweroff.service Before=halt.service final.target reboot.service poweroff.service so this change shouldn't affect if and when lazy-umount-nfs.service is started. --- misc_systemd_units/lazy-umount-nfs.service | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc_systemd_units/lazy-umount-nfs.service b/misc_systemd_units/lazy-umount-nfs.service index c5a77e9d..1d04e421 100644 --- a/misc_systemd_units/lazy-umount-nfs.service +++ b/misc_systemd_units/lazy-umount-nfs.service @@ -1,6 +1,6 @@ [Unit] Description=Lazy Umount NFS -Before=halt.service reboot.service poweroff.service +Before=shutdown.target DefaultDependencies=false [Service] @@ -9,4 +9,4 @@ RemainAfterExit=yes ExecStart=/bin/umount -a -t nfs4 -l [Install] -WantedBy=halt.service reboot.service poweroff.service +WantedBy=shutdown.target From 1d5150e4e9e5b5947a559b3ace536c653c4a0116 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 15 Feb 2018 10:49:18 +0100 Subject: [PATCH 3/4] lazy-umount-nfs.service: Run after automount shutdown lazy-umount-nfs.service sometimes stalled for several seconds during shutdown. The assumed reason is, that is was started while automount was still shuting down - possibly triggering new automounts. Add a order dependency for automount.service. During shutdown, automount.service is stopped (by its default dependency on shutdown.target) and this service is started by its explicit dependency on shutdown.target. We could use "After=" or "Before=" [1], but "After=" seems a bit more intuitive to me ("start lazy-umount-nfs.service AFTER automount.service was stopped"). [1] `man systemd.unit` : If one unit with an ordering dependency on another unit is shut down while the latter is started up, the shut down is ordered before the start-up regardless whether the ordering dependency is actually of type After= or Before=. --- misc_systemd_units/lazy-umount-nfs.service | 1 + 1 file changed, 1 insertion(+) diff --git a/misc_systemd_units/lazy-umount-nfs.service b/misc_systemd_units/lazy-umount-nfs.service index 1d04e421..ffd5aff8 100644 --- a/misc_systemd_units/lazy-umount-nfs.service +++ b/misc_systemd_units/lazy-umount-nfs.service @@ -1,6 +1,7 @@ [Unit] Description=Lazy Umount NFS Before=shutdown.target +After=automount.service DefaultDependencies=false [Service] From 0329adca74682b26f592483deff3dbdff86d1b32 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 15 Feb 2018 11:08:26 +0100 Subject: [PATCH 4/4] lazy-umount-nfs.service: Try normal umount first When this service is started, automount already attempted to unmount the nfs mounts it is responsible for. However, we may have other nfs mounts (e.g. those done manually by a system administrator). If we just disconnect those, we would shutdown before attempting to write dirty data back and release delegations and locks on the server. Try a normal umount before we give up and just disconnect the mounts. --- misc_systemd_units/lazy-umount-nfs.service | 1 + 1 file changed, 1 insertion(+) diff --git a/misc_systemd_units/lazy-umount-nfs.service b/misc_systemd_units/lazy-umount-nfs.service index ffd5aff8..6a386d1b 100644 --- a/misc_systemd_units/lazy-umount-nfs.service +++ b/misc_systemd_units/lazy-umount-nfs.service @@ -7,6 +7,7 @@ DefaultDependencies=false [Service] Type=oneshot RemainAfterExit=yes +ExecStart=/bin/umount -a -t nfs4 ExecStart=/bin/umount -a -t nfs4 -l [Install]