From ebdf71a2df044c441ff633dbfc2f463520892bfb Mon Sep 17 00:00:00 2001 From: Cyril Bordage Date: Fri, 19 Feb 2021 18:12:45 +0100 Subject: [PATCH] LU-14074 scripts: automatic LNet unconfigure 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 Change-Id: I7251a0c62c45da7b3cb0fddea97394b32cb6902a Reviewed-on: https://review.whamcloud.com/41698 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Serguei Smirnov Reviewed-by: Oleg Drokin --- lustre/scripts/lnet.in | 4 +--- lustre/scripts/lustre_rmmod | 18 +++++++++++------- lustre/scripts/systemd/lnet.service.in | 4 +--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lustre/scripts/lnet.in b/lustre/scripts/lnet.in index 84540bc..84409eb 100644 --- a/lustre/scripts/lnet.in +++ b/lustre/scripts/lnet.in @@ -118,9 +118,7 @@ case "$1" in ;; 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" ;; diff --git a/lustre/scripts/lustre_rmmod b/lustre/scripts/lustre_rmmod index 637c6a0..b31c34e 100755 --- a/lustre/scripts/lustre_rmmod +++ b/lustre/scripts/lustre_rmmod @@ -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 - 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 @@ -111,12 +114,13 @@ if $DEBUG; then $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 diff --git a/lustre/scripts/systemd/lnet.service.in b/lustre/scripts/systemd/lnet.service.in index 8b0102e..2efe7b0 100644 --- a/lustre/scripts/systemd/lnet.service.in +++ b/lustre/scripts/systemd/lnet.service.in @@ -12,9 +12,7 @@ RemainAfterExit=true 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 -- 1.8.3.1