From 347bbb765f4dfc509c395da4b2b699586dba7366 Mon Sep 17 00:00:00 2001 From: Chris Horn Date: Fri, 23 Apr 2021 14:05:02 -0500 Subject: [PATCH] LU-14627 tests: Create unload_modules_local t-f allows for loading modules on single node via load_modules_local. However, there is no corresponding unload_modules_local that can be called to cleanup after call to load_modules_local, so we create it. unload_modules() refactored to use unload_modules_local. Also address a potential issue that can prevent LND modules from unloading. Some LNet setup (particularly those in sanity-lnet) may require that we call lnetctl lnet unconfigure (or lctl net down) to drop a ref on the module before it can be unloaded. Lustre-change: https://review.whamcloud.com/43425 Lustre-commit: 32304d863ae98c641f541362f54e7b1f24b350a6 HPE-bug-id: LUS-9031 Signed-off-by: Chris Horn Change-Id: I6458a7728f5f559f8641c5a9e29dd775c8445c38 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/43960 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/scripts/lustre_rmmod | 16 +++++++++++++++- lustre/tests/sanity-lnet.sh | 3 --- lustre/tests/test-framework.sh | 29 ++++++++++++++++++----------- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/lustre/scripts/lustre_rmmod b/lustre/scripts/lustre_rmmod index a2dfd0a..7d4cc50 100755 --- a/lustre/scripts/lustre_rmmod +++ b/lustre/scripts/lustre_rmmod @@ -35,7 +35,21 @@ if [ -z "$modules" ] || [ "$modules" = "ldiskfs" ]; then modules="ptlrpc lnet_selftest ldiskfs libcfs" fi -for mod in $modules; do +# 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 + # Prefer lnetctl if it is present + if [ -n "$(which lnetctl 2>/dev/null)" ]; then + lnetctl lnet unconfigure 2>/dev/null + elif [ -n "$(which lctl 2>/dev/null)" ]; then + lctl net down 2>/dev/null + fi +fi + +for mod in ${modules[*]}; do unload_dep_modules_inclusive $mod || exit 1 done diff --git a/lustre/tests/sanity-lnet.sh b/lustre/tests/sanity-lnet.sh index 3ed3c07..4e3d24f 100755 --- a/lustre/tests/sanity-lnet.sh +++ b/lustre/tests/sanity-lnet.sh @@ -23,9 +23,6 @@ init_logging build_test_filter -export LNETCTL=${LNETCTL:-"$LUSTRE/../lnet/utils/lnetctl"} -[ ! -f "$LNETCTL" ] && - export LNETCTL=$(which lnetctl 2> /dev/null) [[ -z $LNETCTL ]] && skip "Need lnetctl" load_lnet() { diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index fce8d9d..66fce64 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -287,6 +287,8 @@ init_test_env() { fi export RSYNC_RSH=${RSYNC_RSH:-rsh} + export LNETCTL=${LNETCTL:-"$LUSTRE/../lnet/utils/lnetctl"} + [ ! -f "$LNETCTL" ] && export LNETCTL=$(which lnetctl 2> /dev/null) export LCTL=${LCTL:-"$LUSTRE/utils/lctl"} [ ! -f "$LCTL" ] && export LCTL=$(which lctl) export LFS=${LFS:-"$LUSTRE/utils/lfs"} @@ -782,9 +784,7 @@ check_mem_leak () { fi } -unload_modules() { - wait_exit_ST client # bug 12845 - +unload_modules_local() { $LUSTRE_RMMOD ldiskfs || return 2 [ -f /etc/udev/rules.d/99-lustre-test.rules ] && @@ -792,15 +792,23 @@ unload_modules() { udevadm control --reload-rules udevadm trigger + check_mem_leak || return 254 + + return 0 +} + +unload_modules() { + local rc=0 + + wait_exit_ST client # bug 12845 + + unload_modules_local || rc=$? + if $LOAD_MODULES_REMOTE; then local list=$(comma_list $(remote_nodes_list)) if [ -n "$list" ]; then echo "unloading modules on: '$list'" - do_rpc_nodes "$list" $LUSTRE_RMMOD ldiskfs - do_rpc_nodes "$list" check_mem_leak - do_rpc_nodes "$list" "rm /etc/udev/rules.d/99-lustre-test.rules" - do_rpc_nodes "$list" "udevadm control --reload-rules" - do_rpc_nodes "$list" "udevadm trigger" + do_rpc_nodes "$list" unload_modules_local fi fi @@ -811,10 +819,9 @@ unload_modules() { rm -f $sbin_mount fi - check_mem_leak || return 254 + [[ $rc -eq 0 ]] && echo "modules unloaded." - echo "modules unloaded." - return 0 + return $rc } fs_log_size() { -- 1.8.3.1