Whamcloud - gitweb
LU-5443 lustre: replace direct HZ access with kernel APIs
[fs/lustre-release.git] / lustre / scripts / lnet
index f4aacf3..b02c74a 100644 (file)
@@ -6,7 +6,7 @@
 # chkconfig: - 59 76
 # description:  Part of the lustre file system.
 # probe: true
-# config: /etc/sysconfig/lustre
+# config: /etc/sysconfig/lnet
 
 # Source function library.
 [ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions
@@ -145,29 +145,37 @@ status ()
        egrep -q "lnet" /proc/modules && STATE="loaded"
 
        # check for any routes - on a portals router this is the only thing
-       [ "`cat /proc/sys/lnet/routes 2> /dev/null`" ] && STATE="running" && RETVAL=0
+       VAR=$(lctl get_param -n routes 2>&1)
+       if [ $? = 0 ] ; then
+               STATE="running"
+               RETVAL=0
+       fi
 
        # check if this is a router
-       if [ -d /proc/sys/lnet ]; then
-               ROUTER="`cat /proc/sys/lnet/routes | head -1 | grep -i -c \"Routing enabled\"`"
-               if [[ ! -z ${ROUTER} && ${ROUTER} -ge 1 ]]; then
-                       STATE="running"
-                       RETVAL=0
-               fi
+       if [[ "$(lctl get_param -n routes)" =~ "Routing enabled" ]]; then
+               STATE="running"
+               RETVAL=0
        fi
 
        # check for error in health_check
-       HEALTH="/proc/fs/lustre/health_check"
-       [ -f "$HEALTH" ] && grep -q "NOT HEALTHY" $HEALTH && STATE="unhealthy" && RETVAL=1
+       local health_check=$(lctl get_param -n health_check)
+       if [[ "$health_check" =~ "NOT HEALTHY" ]]; then
+               STATE="unhealthy"
+               RETVAL=1
+       fi
 
-       # check for LBUG
-       [ -f  "$HEALTH" ] && grep -q "LBUG" $HEALTH && STATE="LBUG" && RETVAL=152
+       if [[ "$health_check" =~ "LBUG" ]]; then
+               STATE="LBUG"
+               RETVAL=152
+       fi
 
        echo $STATE
        eval $old_nullglob
 }
 
 LUSTRE_ROUTES_CONFIG_FILE="/etc/sysconfig/lnet_routes.conf"
+LUSTRE_LNET_CONFIG_FILE="/etc/sysconfig/lnet.conf"
+LUSTRE_LNET_CONFIG_UTILITY="/usr/sbin/lnetctl"
 
 # See how we were called.
 case "$1" in
@@ -183,6 +191,12 @@ case "$1" in
        elif [ -f "$LUSTRE_ROUTES_CONFIG_FILE" ]; then
                lustre_routes_config $LUSTRE_ROUTES_CONFIG_FILE
        fi
+       # if an lnet.conf file exists then pass that to the lnetctl
+       # utility for parsing.  This will configure the items defined
+       # in YAML format in the config file.
+       if [ -f $LUSTRE_LNET_CONFIG_UTILITY ] && [ -f "$LUSTRE_LNET_CONFIG_FILE" ]; then
+               $LUSTRE_LNET_CONFIG_UTILITY $LUSTRE_LNET_CONFIG_FILE
+       fi
        run_postexec_check "start"
        ;;
   stop)