From: Oleg Drokin Date: Thu, 18 May 2017 05:59:12 +0000 (+0000) Subject: Revert "LU-9439 scripts: Change behavior of lustre_rmmod" X-Git-Tag: 2.9.58~14 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=0bc19643b94f0adf28db365a07bcefeff4ebc51d;p=fs%2Flustre-release.git Revert "LU-9439 scripts: Change behavior of lustre_rmmod" This is causing widespread testing problems partially documented in LU-9524 and also in LU-9439 This reverts commit 645153be3eb1fd8c634717507f73d85625d1b84a. Change-Id: Ie20b9c7a52aec5153566ad0712689852545a0948 Reviewed-on: https://review.whamcloud.com/27181 Reviewed-by: Oleg Drokin Tested-by: Oleg Drokin --- diff --git a/lustre/scripts/lnet b/lustre/scripts/lnet index 43ad5bf..01f7e4f 100644 --- a/lustre/scripts/lnet +++ b/lustre/scripts/lnet @@ -131,9 +131,8 @@ case "$1" in ;; stop) run_preexec_check "stop" - lustre_rmmod ptlrpc || exit 1 lctl network down || 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 792f193..76a9d11 100755 --- a/lustre/scripts/lustre_rmmod +++ b/lustre/scripts/lustre_rmmod @@ -1,44 +1,38 @@ -#!/bin/bash +#!/bin/sh # -# Takes a list of modules and unloads them and all dependent modules. -# If a module cannot be unloaded (e.g. it's in use), an error is -# returned. +# remove all lustre modules. Won't succeed if they're in use, or if you +# manually did a 'lctl network up'. ############################################################################### -# Unload all modules dependent on $1 (exclude removal of $1) -unload_dep_modules_exclusive() { - local MODULE=$1 - local DEPS="$(lsmod | awk '($1 == "'$MODULE'") { print $4 }')" - for SUBMOD in $(echo $DEPS | tr ',' ' '); do - unload_dep_modules_inclusive $SUBMOD || return 1 - done - return 0 -} +FSTYPE=${1:-ldiskfs} -# Unload all modules dependent on $1 (include removal of $1) -unload_dep_modules_inclusive() { - local MODULE=$1 +TMP=${TMP:-/tmp} +LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)} +LCTL=${LCTL:-"$LUSTRE/utils/lctl"} +[ ! -f "$LCTL" ] && export LCTL=$(which lctl 2> /dev/null) - # if $MODULE not loaded, return 0 - lsmod | egrep -q "^\<$MODULE\>" || return 0 - unload_dep_modules_exclusive $MODULE || return 1 - rmmod $MODULE || return 1 - return 0 +unload_dep_module() { + # libcfs 107852 17 lustre,obdfilter,ost,... + local MODULE=$1 + local DEPS="$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')" + for SUBMOD in $DEPS; do + unload_dep_module $SUBMOD + done + [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug >/dev/null || true + rmmod $MODULE 2>/dev/null || true + return 0 } -modules="$@" +lsmod | grep obdclass > /dev/null && $LCTL dl +lsmod | grep $FSTYPE > /dev/null && unload_dep_module $FSTYPE +lsmod | grep ptlrpc > /dev/null && unload_dep_module ptlrpc +lsmod | grep libcfs > /dev/null && unload_dep_module libcfs -# To maintain backwards compatibility, ldiskfs and libcfs must be -# 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 [ -z "$modules" ]; then - modules="ldiskfs libcfs" -elif [ "$modules" = "ldiskfs" ]; then - modules="ldiskfs libcfs" +MODULES=$($LCTL modules | awk '{ print $2 }') +if [ -n "$MODULES" ]; then + echo "Modules still loaded: " + echo $MODULES + exit 1 fi - -for mod in $modules; do - unload_dep_modules_inclusive $mod || exit 1 -done - exit 0 +