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/lustre
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 [ "`cat /proc/sys/lnet/routes 2> /dev/null`" ] && STATE="running" && RETVAL=0
150 # check if this is a router
151 if [ -d /proc/sys/lnet ]; then
152 ROUTER="`cat /proc/sys/lnet/routes | head -1 | grep -i -c \"Routing enabled\"`"
153 if [[ ! -z ${ROUTER} && ${ROUTER} -ge 1 ]]; then
159 # check for error in health_check
160 HEALTH="/proc/fs/lustre/health_check"
161 [ -f "$HEALTH" ] && grep -q "NOT HEALTHY" $HEALTH && STATE="unhealthy" && RETVAL=1
164 [ -f "$HEALTH" ] && grep -q "LBUG" $HEALTH && STATE="LBUG" && RETVAL=152
170 LUSTRE_ROUTES_CONFIG_FILE="/etc/sysconfig/lnet_routes.conf"
172 # See how we were called.
175 run_preexec_check "start"
176 touch /var/lock/subsys/lnet
177 modprobe lnet || exit 1
178 lctl network up || exit 1
179 # if a routes config file is given then use it to configure the
180 # routes if not then default to LUSTRE_ROUTES_CONFIG_FILE
182 lustre_routes_config $2
183 elif [ -f "$LUSTRE_ROUTES_CONFIG_FILE" ]; then
184 lustre_routes_config $LUSTRE_ROUTES_CONFIG_FILE
186 run_postexec_check "start"
189 run_preexec_check "stop"
190 remove_modules ${TOP_MODULES[*]} || exit 1
192 remove_modules ${BOTTOM_MODULES[*]} || exit 1
193 rm -f /var/lock/subsys/lnet
194 run_postexec_check "stop"
204 touch /var/lock/subsys/lnet
207 if [ ! -f /var/lock/subsys/lnet ] ; then
208 echo $"start"; exit 0
212 [ -f /var/lock/subsys/lnet ] && {
218 echo $"Usage: lustre {start|stop|status|restart|reload|condrestart}"