Whamcloud - gitweb
LU-8384 scripts: Add scripts to systemd for EL7 03/34503/2
authorDmitry Eremin <dmitry.eremin@intel.com>
Fri, 8 Jul 2016 21:15:37 +0000 (00:15 +0300)
committerOleg Drokin <green@whamcloud.com>
Mon, 1 Apr 2019 06:20:32 +0000 (06:20 +0000)
When rebooting a lustre client where Lustre filesystem is still
mounted, the shutdown hangs. This patch create a systemd service
that unmount the Lustre filesystems and unload the Lustre modules
when system is shutdown.

Test-Parameters: trivial

Lustre-change: https://review.whamcloud.com/21457
Lustre-commit: 495deddfbb43f247b2fa9dd2da5743abc89cd862

Change-Id: I1cfe84684e23b8861743241dfbc4d6e320ace4a6
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Signed-off-by: Gregoire Pichon <gregoire.pichon@atos.net>
Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/34503
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre.spec.in
lustre/scripts/Makefile.am
lustre/scripts/lustre
lustre/scripts/systemd/Makefile.am
lustre/scripts/systemd/lustre.service.in [new file with mode: 0644]

index 7fe7e9f..ca6e9d5 100644 (file)
@@ -374,12 +374,12 @@ echo '%{_sysconfdir}/ha.d/resource.d/Lustre' >>lustre.files
 # systemd is on redhat, fedora, and suse
 %if %{with systemd}
 echo '%{_unitdir}/lnet.service' >>lustre.files
+echo '%{_unitdir}/lustre.service' >>lustre.files
 %endif
 
 %if %{_vendor}=="redhat"
 # The following scripts are Red Hat specific
 %if %{with servers}
-echo '%{_sysconfdir}/init.d/lustre' >>lustre.files
 echo '%{_sysconfdir}/sysconfig/lustre' >>lustre.files
 %if %{with gss_keyring}
 echo '%{_sysconfdir}/init.d/lsvcgss' >>lustre.files
@@ -389,6 +389,7 @@ echo '%{_sysconfdir}/sysconfig/lsvcgss' >>lustre.files
 
 %if %{without systemd}
 echo '%{_sysconfdir}/init.d/lnet' >>lustre.files
+echo '%{_sysconfdir}/init.d/lustre' >>lustre.files
 %endif
 %endif
 %if %{with gss_keyring}
@@ -552,15 +553,18 @@ echo '%{_sbindir}/wiretest' >>lustre-tests.files
 %post
 %if %{with systemd}
 %systemd_post lnet.service
+%systemd_post lustre.service
 %endif
 
 %preun
 %if %{with systemd}
+%systemd_preun lustre.service
 %systemd_preun lnet.service
 %endif
 
 %postun
 %if %{with systemd}
+%systemd_postun_with_restart lustre.service
 %systemd_postun_with_restart lnet.service
 %endif
 
index f834235..3757519 100644 (file)
@@ -48,7 +48,9 @@ init_SCRIPTS += lnet
 endif
 
 if SERVER
+if !HAVE_SYSTEMD
 init_SCRIPTS += lustre
+endif
 if GSS_KEYRING
 init_SCRIPTS += lsvcgss
 endif
@@ -85,7 +87,7 @@ endif # UTILS
 EXTRA_DIST = license-status lustre_rmmod ldev lc_mon lhbadm \
             lc_servip lustre_routes_config lustre_routes_conversion \
             $(addsuffix .in,$(genscripts)) lfs_migrate lustre_req_history \
-            lustre lsvcgss lc_common haconfig Lustre.ha_v2 dkms.mkconf \
+            lsvcgss lc_common haconfig Lustre.ha_v2 dkms.mkconf \
             zfsobj2fid ko2iblnd-probe statechange-lustre.sh
 
 CLEANFILES = $(genscripts)
index 919efb0..f258cb4 100644 (file)
@@ -1,12 +1,19 @@
 #!/bin/bash
 #
 # lustre       This shell script takes care of starting and stopping
-#             the lustre services.
+#              the lustre services.
 #
 # chkconfig: - 60 20
 # description:  Part of the lustre file system.
 # probe: true
 # config: /etc/sysconfig/lustre
+### BEGIN INIT INFO
+# Provides: lustre
+# Required-Start: openibd
+# Defalt-Start: -
+# Default-Stop: 0 1 6
+# Description: Lustre init script
+### END INIT INFO
 
 PATH=/sbin:/usr/sbin:/bin:/usr/bin
 
index 340f6f1..47f7fe7 100644 (file)
@@ -1,8 +1,9 @@
 # These are scripts that are generated from .in files
-genunitfiles = lnet.service
+genunitfiles = lnet.service lustre.service
 
 if HAVE_SYSTEMD
 systemdsystemunit_DATA = lnet.service
+systemdsystemunit_DATA += lustre.service
 endif
 
 EXTRA_DIST = $(addsuffix .in,$(genunitfiles))
@@ -11,4 +12,5 @@ CLEANFILES = $(genunitfiles)
 
 $(genunitfiles): %: %.in
        sed -e 's,@sbindir\@,$(sbindir),g' \
+           -e 's,@bindir\@,$(bindir),g' \
            -e 's,@sysconfdir\@,$(sysconfdir),g' $< > $@
diff --git a/lustre/scripts/systemd/lustre.service.in b/lustre/scripts/systemd/lustre.service.in
new file mode 100644 (file)
index 0000000..26d907d
--- /dev/null
@@ -0,0 +1,16 @@
+[Unit]
+Description=Lustre shutdown
+After=network.target network-online.target lnet.service
+DefaultDependencies=false
+Conflicts=umount.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=true
+ExecStart=/bin/true
+ExecStop=@bindir@/umount -a -t lustre
+ExecStop=@sbindir@/lustre_rmmod
+
+[Install]
+WantedBy=sysinit.target
+WantedBy=final.target