Blame | Last modification | View Log | RSS feed
#!/bin/bash## Bring up/down NFSoRDMA support## chkconfig: - 31 61# description: Enables/Disables NFS over RDMA interfaces# config: /etc/rdma/rdma.conf#### BEGIN INIT INFO# Provides: nfs-rdma# Default-Stop: 0 1 2 3 4 5 6# Required-Start: $network $rdma $nfs# Required-Stop: $nfs# Short-Description: Enables/Disables NFS over RDMA interfaces# Description: Enables/Disables NFS over RDMA interfaces### END INIT INFOCONFIG=/etc/rdma/rdma.conf. /etc/rc.d/init.d/functionsLOAD_ULP_MODULES=""if [ -f $CONFIG ]; then. $CONFIGif [ "${NFSoRDMA_LOAD}" == "yes" ]; thenLOAD_ULP_MODULES="svcrdma xprtrdma"fiif [ -n "${NFSoRDMA_PORT}" ]; thenPORT=${NFSoRDMA_PORT}elsePORT=2050fifiUNLOAD_ULP_MODULES="xprtrdma svcrdma"# If module $1 is loaded return - 0 else - 1is_module(){/sbin/lsmod | grep -w "$1" > /dev/null 2>&1return $?}load_modules(){local RC=0for module in $*; doif ! is_module $module; then/sbin/modprobe $moduleres=$?RC=$[ $RC + $res ]if [ $res -ne 0 ]; thenechoecho -n "Failed to load module $mod"fifidonereturn $RC}unload_module(){local mod=$1# Unload module $1if is_module $mod; then/sbin/rmmod $mod > /dev/null 2>&1if [ $? -ne 0 ]; thenechoecho "Failed to unload $mod"return 1fifireturn 0}start(){local RC=0local loaded=0echo -n "Enabling NFSoRDMA support:"load_modules $LOAD_ULP_MODULESRC=$[ $RC + $? ]if [ $RC -gt 0 ]; thenfor mod in $UNLOAD_ULP_MODULES; dounload_module $moddoneecho_failureechoreturn $RCfiecho "rdma $PORT" > /proc/fs/nfsd/portlistsleep 1entry=$(grep rdma /proc/fs/nfsd/portlist)if [ -z "$entry" ]; thenfor mod in $UNLOAD_ULP_MODULES; dounload_module $moddoneecho_failureechoreturn 1fitouch /var/lock/subsys/nfs-rdmaecho_successechoreturn $RC}stop(){echo -n "Disabling NFSoRDMA support:"if ! is_module svcrdma; then# Nothing to do, make sure lock file is gone and returnrm -f /var/lock/subsys/nfs-rdmaecho_successechoreturn 0fi# Tell the nfs server to quit listening on the rdma portport=$(grep rdma /proc/fs/nfsd/portlist)if [ -n "$port" ]; thenecho "-$port" > /proc/fs/nfsd/portlist# Small sleep to let nfsd process our requestsleep 1fi# Unload NFSoRDMA modulesfor mod in $UNLOAD_ULP_MODULESdounload_module $modRC=$[ $RC + $? ]done[ $RC -eq 0 ] && rm -f /var/lock/subsys/nfs-rdma[ $RC -eq 0 ] && echo_success || echo_failureechoreturn $RC}status(){entry=$(grep rdma /proc/fs/nfsd/portlist)if [ -z "$entry" ]; thenif [ -f /var/lock/subsys/nfs-rdma ]; thenreturn 2elsereturn 3fielsereturn 0fi}restart (){stopstart}condrestart (){[ -e /var/lock/subsys/nfs-rdma ] && restart || return 0}usage (){echoecho "Usage: `basename $0` {start|stop|restart|condrestart|try-restart|force-reload|status}"echoreturn 2}case $1 instart|stop|restart|condrestart|try-restart|force-reload)[ `id -u` != "0" ] && exit 4 ;;esaccase $1 instart) start; RC=$? ;;stop) stop; RC=$? ;;restart) restart; RC=$? ;;reload) RC=3 ;;condrestart) condrestart; RC=$? ;;try-restart) condrestart; RC=$? ;;force-reload) condrestart; RC=$? ;;status) status; RC=$? ;;*) usage; RC=$? ;;esacexit $RC