SCRIPT_NAME="$(basename "$0")"
LCTL=${LCTL:-lctl}
DEBUG='false'
+[[ -n $DEBUG_RMMOD ]] && DEBUG='true'
# Print help message
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'
}
# 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
$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