Whamcloud - gitweb
LU-14074 scripts: automatic LNet unconfigure 98/41698/3
authorCyril Bordage <cbordage@whamcloud.com>
Fri, 19 Feb 2021 17:12:45 +0000 (18:12 +0100)
committerOleg Drokin <green@whamcloud.com>
Wed, 30 Jun 2021 15:26:20 +0000 (15:26 +0000)
After using the lnetctl utility a reference count is taken on the LNet
modules. lnetctl lnet unconfigure is called in order for
lustre_rmmod to remove the LNet module.

Signed-off-by: Cyril Bordage <cbordage@whamcloud.com>
Change-Id: I7251a0c62c45da7b3cb0fddea97394b32cb6902a
Reviewed-on: https://review.whamcloud.com/41698
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/scripts/lnet.in
lustre/scripts/lustre_rmmod
lustre/scripts/systemd/lnet.service.in

index 84540bc..84409eb 100644 (file)
@@ -118,9 +118,7 @@ case "$1" in
        ;;
   stop)
        run_preexec_check "stop"
        ;;
   stop)
        run_preexec_check "stop"
-       lustre_rmmod ptlrpc || exit 1
-       lnetctl lnet unconfigure || exit 1
-       lustre_rmmod libcfs ldiskfs || exit 1
+       lustre_rmmod || exit 1
        rm -f /var/lock/subsys/lnet
        run_postexec_check "stop"
        ;;
        rm -f /var/lock/subsys/lnet
        run_postexec_check "stop"
        ;;
index 637c6a0..b31c34e 100755 (executable)
@@ -88,7 +88,10 @@ done
 # unloaded if no parameters are given, or if only the ldiskfs parameter
 # is given. It's ugly, but is needed to emulate the prior functionality
 if [ "${#modules[@]}" -eq 0 ] || [ "${modules[*]}" = "ldiskfs" ]; then
 # unloaded if no parameters are given, or if only the ldiskfs parameter
 # is given. It's ugly, but is needed to emulate the prior functionality
 if [ "${#modules[@]}" -eq 0 ] || [ "${modules[*]}" = "ldiskfs" ]; then
-       modules=('ptlrpc' 'lnet_selftest' 'ldiskfs' 'libcfs')
+       unload_all=true
+       modules=('lnet_selftest' 'ldiskfs' 'libcfs')
+else
+       unload_all=false
 fi
 
 if [ -f /sys/kernel/debug/kmemleak ] ; then
 fi
 
 if [ -f /sys/kernel/debug/kmemleak ] ; then
@@ -111,12 +114,13 @@ if $DEBUG; then
        $LCTL mark "$SCRIPT_NAME : Start debug"
 fi
 
        $LCTL mark "$SCRIPT_NAME : Start debug"
 fi
 
-# LNet may have an internal ref which can prevent LND modules from
-# unloading. Try to drop it before unloading modules.
-# NB: we squelch stderr because lnetctl/lctl may complain about
-# LNet being "busy", but this is normal. We're making a best effort
-# here.
-if lsmod | grep -q lnet; then
+if $unload_all; then
+       unload_dep_modules_inclusive 'ptlrpc' || exit 1
+       # LNet may have an internal ref which can prevent LND modules from
+       # unloading. Try to drop it before unloading modules.
+       # NB: we squelch stderr because lnetctl/lctl may complain about
+       # LNet being "busy", but this is normal. We're making a best effort
+       # here.
        # Prefer lnetctl if it is present
        if [ -n "$(which lnetctl 2>/dev/null)" ]; then
                lnetctl lnet unconfigure 2>/dev/null
        # Prefer lnetctl if it is present
        if [ -n "$(which lnetctl 2>/dev/null)" ]; then
                lnetctl lnet unconfigure 2>/dev/null
index 8b0102e..2efe7b0 100644 (file)
@@ -12,9 +12,7 @@ RemainAfterExit=true
 ExecStart=/sbin/modprobe lnet
 ExecStart=@sbindir@/lnetctl lnet configure
 ExecStart=@sbindir@/lnetctl import @sysconfdir@/lnet.conf
 ExecStart=/sbin/modprobe lnet
 ExecStart=@sbindir@/lnetctl lnet configure
 ExecStart=@sbindir@/lnetctl import @sysconfdir@/lnet.conf
-ExecStop=@sbindir@/lustre_rmmod ptlrpc
-ExecStop=@sbindir@/lnetctl lnet unconfigure
-ExecStop=@sbindir@/lustre_rmmod libcfs ldiskfs
+ExecStop=@sbindir@/lustre_rmmod
 
 [Install]
 WantedBy=multi-user.target
 
 [Install]
 WantedBy=multi-user.target