Whamcloud - gitweb
LU-8851 nodemap: add uid/gid only flags to control mapping
[fs/lustre-release.git] / lustre / scripts / lustre_rmmod
1 #!/bin/sh
2 #
3 # remove all lustre modules.  Won't succeed if they're in use, or if you
4 # manually did a 'lctl network up'.
5 ###############################################################################
6
7 FSTYPE=${1:-ldiskfs}
8
9 TMP=${TMP:-/tmp}
10 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
11 LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
12 [ ! -f "$LCTL" ] && export LCTL=$(which lctl 2> /dev/null)
13
14 unload_dep_module() {
15     # libcfs                107852  17 lustre,obdfilter,ost,...
16     local MODULE=$1
17     local DEPS="$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')"
18     for SUBMOD in $DEPS; do
19         unload_dep_module $SUBMOD
20     done
21     [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug >/dev/null || true
22     rmmod $MODULE 2>/dev/null || true
23     return 0
24 }
25
26 lsmod | grep obdclass > /dev/null && $LCTL dl
27 lsmod | grep $FSTYPE > /dev/null && unload_dep_module $FSTYPE
28 lsmod | grep ptlrpc > /dev/null && unload_dep_module ptlrpc
29 lsmod | grep libcfs > /dev/null && unload_dep_module libcfs
30
31 MODULES=$($LCTL modules | awk '{ print $2 }')
32 if [ -n "$MODULES" ]; then
33     echo "Modules still loaded: "
34     echo $MODULES
35     exit 1
36 fi
37 exit 0
38