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=( \
48 declare -r awkprog='BEGIN { rc = -1 }
49 { if ( $1 == module_name ) { rc = $3; exit; } }
52 # Usage: run_preexec_check [ start | restart | condrestart ]
53 # The single parameter will be passed to the PREEXEC_SCRIPT
56 if [ -n "$PREEXEC_CHECK" ] && ! $PREEXEC_CHECK ; then
57 echo "Pre-exec check \"$PREEXEC_CHECK\" failed. Aborting."
61 if [ -n "$PREEXEC_SCRIPT" ] && ! "$PREEXEC_SCRIPT" "$1" ; then
62 echo "Pre-exec script \"$PREEXEC_SCRIPT\" failed. Aborting."
67 # Usage: run_postexec_check [ start | restart | condrestart ]
68 # The single parameter will be passed to the POSTEXEC_SCRIPT
71 if [ -n "$POSTEXEC_CHECK" ] && ! $POSTEXEC_CHECK ; then
72 echo "Post-exec check \"$POSTEXEC_CHECK\" failed. Aborting."
76 if [ -n "$POSTEXEC_SCRIPT" ] && ! "$POSTEXEC_SCRIPT" "$1" ; then
77 echo "Post-exec script \"$POSTEXEC_SCRIPT\" failed. Aborting."
87 for mod in $modules; do
88 ref_cnt=`/sbin/lsmod | awk "$awkprog" "module_name=$mod"`
89 if [ $ref_cnt -lt 0 ]; then
90 # module not loaded, skip it
93 if [ $ref_cnt -gt 0 ]; then
94 # module in use. maybe it just needs a few seconds
95 # after removal of previous modules.
97 ref_cnt=`/sbin/lsmod | awk "$awkprog" module_name=$mod`
99 if [ $ref_cnt -eq 0 ]; then
101 echo "Removing module $mod"
103 if [ $? -ne 0 ]; then
104 echo "ERROR: Failed to remove module $mod."
108 # boo! module still in use.
109 echo "ERROR: Module $mod has non-zero reference count."
119 local errmsg=`/usr/sbin/lctl network unconfigure 2>&1`
120 if [ $? -gt 0 ]; then
121 # The following error message means that lnet is already
122 # unconfigured, and the modules are not loaded.
123 echo $errmsg | grep "LNET unconfigure error 19" > /dev/null
124 if [ $? -gt 0 ]; then
136 old_nullglob="`shopt -p nullglob`"
140 # LSB compliance - return 3 if service is not running
141 # Lustre-specific returns
142 # 150 - partial startup
143 # 151 - health_check unhealthy
146 egrep -q "lnet" /proc/modules && STATE="loaded"
148 # check for any routes - on a portals router this is the only thing
149 [ "`cat /proc/sys/lnet/routes 2> /dev/null`" ] && STATE="running" && RETVAL=0
151 # check if this is a router
152 if [ -d /proc/sys/lnet ]; then
153 ROUTER="`cat /proc/sys/lnet/routes | head -1 | grep -i -c \"Routing enabled\"`"
154 if [[ ! -z ${ROUTER} && ${ROUTER} -ge 1 ]]; then
160 # check for error in health_check
161 HEALTH="/proc/fs/lustre/health_check"
162 [ -f "$HEALTH" ] && grep -q "NOT HEALTHY" $HEALTH && STATE="unhealthy" && RETVAL=1
165 [ -f "$HEALTH" ] && grep -q "LBUG" $HEALTH && STATE="LBUG" && RETVAL=152
171 # See how we were called.
174 run_preexec_check "start"
175 touch /var/lock/subsys/lnet
176 modprobe lnet || exit 1
177 lctl network up || exit 1
178 run_postexec_check "start"
181 run_preexec_check "stop"
182 remove_modules ${TOP_MODULES[*]} || exit 1
184 remove_modules ${BOTTOM_MODULES[*]} || exit 1
185 rm -f /var/lock/subsys/lnet
186 run_postexec_check "stop"
196 touch /var/lock/subsys/lnet
199 if [ ! -f /var/lock/subsys/lnet ] ; then
200 echo $"start"; exit 0
204 [ -f /var/lock/subsys/lnet ] && {
210 echo $"Usage: lustre {start|stop|status|restart|reload|condrestart}"