X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fscripts%2Flustre_rmmod;h=637c6a0ba20ab370175b43369b8fc33c34c05000;hp=9da25ff40d5eaa86d1eaadd728d1f79da080dfc8;hb=HEAD;hpb=65e391e95b6d53b36840c95c2499f17fd84a1d36 diff --git a/lustre/scripts/lustre_rmmod b/lustre/scripts/lustre_rmmod index 9da25ff..9dca753 100755 --- a/lustre/scripts/lustre_rmmod +++ b/lustre/scripts/lustre_rmmod @@ -8,6 +8,7 @@ SCRIPT_NAME="$(basename "$0")" LCTL=${LCTL:-lctl} DEBUG='false' +[[ -n $DEBUG_RMMOD ]] && DEBUG='true' # Print help message print_usage() { @@ -23,8 +24,14 @@ print_usage() { # Print kernel debug message for lustre modules print_debug() { + local debug_file $LCTL mark "$SCRIPT_NAME : Stop debug" - $LCTL debug_kernel + if [[ $DEBUG_RMMOD == "-" ]]; then + debug_file="" # dump to stdout + else + debug_file=$DEBUG_RMMOD + fi + $LCTL debug_kernel $debug_file DEBUG='false' } @@ -88,7 +95,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,6 +121,21 @@ if $DEBUG; then $LCTL mark "$SCRIPT_NAME : Start debug" fi +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 + elif [ -n "$(which lctl 2>/dev/null)" ]; then + lctl net down 2>/dev/null | grep -v "LNET ready to unload" + fi +fi + for mod in ${modules[*]}; do unload_dep_modules_inclusive $mod || exit 1 done