3 # lnet This shell script takes care of starting and stopping
4 # the lnet (Lustre networking) services.
7 # description: Part of the lustre file system.
9 # config: /etc/sysconfig/lnet
11 # Source function library.
12 [ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions
14 # Source networking configuration and check that networking is up.
15 [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network && \
16 [ "${NETWORKING}" = "no" ] && exit 0
18 # Check for and source configuration file otherwise set defaults
19 [ -f /etc/sysconfig/lnet ] && . /etc/sysconfig/lnet
21 declare -r TOP_MODULES=( \
36 declare -r BOTTOM_MODULES=( \
47 declare -r awkprog='BEGIN { rc = -1 }
48 { if ( $1 == module_name ) { rc = $3; exit; } }
51 # Usage: run_preexec_check [ start | restart | condrestart ]
52 # The single parameter will be passed to the PREEXEC_SCRIPT
55 if [ -n "$PREEXEC_CHECK" ] && ! $PREEXEC_CHECK ; then
56 echo "Pre-exec check \"$PREEXEC_CHECK\" failed. Aborting."
60 if [ -n "$PREEXEC_SCRIPT" ] && ! "$PREEXEC_SCRIPT" "$1" ; then
61 echo "Pre-exec script \"$PREEXEC_SCRIPT\" failed. Aborting."
66 # Usage: run_postexec_check [ start | restart | condrestart ]
67 # The single parameter will be passed to the POSTEXEC_SCRIPT
70 if [ -n "$POSTEXEC_CHECK" ] && ! $POSTEXEC_CHECK ; then
71 echo "Post-exec check \"$POSTEXEC_CHECK\" failed. Aborting."
75 if [ -n "$POSTEXEC_SCRIPT" ] && ! "$POSTEXEC_SCRIPT" "$1" ; then
76 echo "Post-exec script \"$POSTEXEC_SCRIPT\" failed. Aborting."
86 for mod in $modules; do
87 ref_cnt=`/sbin/lsmod | awk "$awkprog" "module_name=$mod"`
88 if [ $ref_cnt -lt 0 ]; then
89 # module not loaded, skip it
92 if [ $ref_cnt -gt 0 ]; then
93 # module in use. maybe it just needs a few seconds
94 # after removal of previous modules.
96 ref_cnt=`/sbin/lsmod | awk "$awkprog" module_name=$mod`
98 if [ $ref_cnt -eq 0 ]; then
100 echo "Removing module $mod"
102 if [ $? -ne 0 ]; then
103 echo "ERROR: Failed to remove module $mod."
107 # boo! module still in use.
108 echo "ERROR: Module $mod has non-zero reference count."
118 local errmsg=`/usr/sbin/lctl network unconfigure 2>&1`
119 if [ $? -gt 0 ]; then
120 # The following error message means that lnet is already
121 # unconfigured, and the modules are not loaded.
122 echo $errmsg | grep "LNET unconfigure error 19" > /dev/null
123 if [ $? -gt 0 ]; then
135 old_nullglob="`shopt -p nullglob`"
139 # LSB compliance - return 3 if service is not running
140 # Lustre-specific returns
141 # 150 - partial startup
142 # 151 - health_check unhealthy
145 egrep -q "lnet" /proc/modules && STATE="loaded"
147 # check for any routes - on a portals router this is the only thing
148 VAR=$(lctl get_param -n routes 2>&1)
154 # check if this is a router
155 if [[ "$(lctl get_param -n routes)" =~ "Routing enabled" ]]; then
160 # check for error in health_check
161 local health_check=$(lctl get_param -n health_check)
162 if [[ "$health_check" =~ "NOT HEALTHY" ]]; then
167 if [[ "$health_check" =~ "LBUG" ]]; then
176 LUSTRE_ROUTES_CONFIG_FILE="/etc/sysconfig/lnet_routes.conf"
178 # See how we were called.
181 run_preexec_check "start"
182 touch /var/lock/subsys/lnet
183 modprobe lnet || exit 1
184 lctl network up || exit 1
185 # if a routes config file is given then use it to configure the
186 # routes if not then default to LUSTRE_ROUTES_CONFIG_FILE
188 lustre_routes_config $2
189 elif [ -f "$LUSTRE_ROUTES_CONFIG_FILE" ]; then
190 lustre_routes_config $LUSTRE_ROUTES_CONFIG_FILE
192 run_postexec_check "start"
195 run_preexec_check "stop"
196 remove_modules ${TOP_MODULES[*]} || exit 1
198 remove_modules ${BOTTOM_MODULES[*]} || exit 1
199 rm -f /var/lock/subsys/lnet
200 run_postexec_check "stop"
210 touch /var/lock/subsys/lnet
213 if [ ! -f /var/lock/subsys/lnet ] ; then
214 echo $"start"; exit 0
218 [ -f /var/lock/subsys/lnet ] && {
224 echo $"Usage: lustre {start|stop|status|restart|reload|condrestart}"