From 5632538a8731c95c152a45fd0dc7f067acecc65f Mon Sep 17 00:00:00 2001 From: Doug Ledford Date: Aug 03 2010 04:58:14 +0000 Subject: Add NFSoRDMA configuration support to our init scripts Signed-off-by: Doug Ledford --- diff --git a/rdma.conf b/rdma.conf index f3921e7..272e3a4 100644 --- a/rdma.conf +++ b/rdma.conf @@ -13,3 +13,7 @@ LOAD_RDS=yes # Note: recent kernels should do this for us, but in case they don't, we'll # leave this option FIXUP_MTRR_REGS=no +# Should we enable the NFSoRDMA service? +NFSoRDMA_LOAD=yes +NFSoRDMA_PORT=2050 + diff --git a/rdma.init b/rdma.init index 82831a8..6b11199 100644 --- a/rdma.init +++ b/rdma.init @@ -9,7 +9,7 @@ ### BEGIN INIT INFO # Provides: rdma # Default-Stop: 0 1 2 3 4 5 6 -# Required-Stop: $network $srpd $opensm +# Required-Stop: $network $srpd $opensm $nfs-rdma # Short-Description: Loads and unloads the InfiniBand and iWARP kernel modules # Description: Loads and unloads the InfiniBand and iWARP kernel modules ### END INIT INFO @@ -284,6 +284,14 @@ stop() fi done + if is_module svcrdma; then + echo "NFSoRDMA support is still enabled." + echo "Please stop the nfs-rdma service before stopping the rdma service." + echo_failure + echo + return 1 + fi + if ! is_module ib_core; then # Nothing to do, make sure lock file is gone and return rm -f /var/lock/subsys/rdma diff --git a/rdma.nfs-rdma.init b/rdma.nfs-rdma.init new file mode 100644 index 0000000..19977fc --- /dev/null +++ b/rdma.nfs-rdma.init @@ -0,0 +1,199 @@ +#!/bin/bash +# +# Bring up/down NFSoRDMA support +# +# chkconfig: - 31 59 +# 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 +# Short-Description: Enables/Disables NFS over RDMA interfaces +# Description: Enables/Disables NFS over RDMA interfaces +### END INIT INFO + +CONFIG=/etc/rdma/rdma.conf + +. /etc/rc.d/init.d/functions + +LOAD_ULP_MODULES="" +if [ -f $CONFIG ]; then + . $CONFIG + + if [ "${NFSoRDMA_LOAD}" == "yes" ]; then + LOAD_ULP_MODULES="svcrdma xprtrdma" + fi + if [ -n "${NFSoRDMA_PORT}" ]; then + PORT=${NFSoRDMA_PORT} + else + PORT=2050 + fi +fi + +UNLOAD_ULP_MODULES="xprtrdma svcrdma" + + +# If module $1 is loaded return - 0 else - 1 +is_module() +{ + /sbin/lsmod | grep -w "$1" > /dev/null 2>&1 + return $? +} + +load_modules() +{ + local RC=0 + + for module in $*; do + if ! is_module $module; then + /sbin/modprobe $module + res=$? + RC=$[ $RC + $res ] + if [ $res -ne 0 ]; then + echo + echo -n "Failed to load module $mod" + fi + fi + done + return $RC +} + +unload_module() +{ + local mod=$1 + # Unload module $1 + if is_module $mod; then + /sbin/rmmod $mod > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo + echo "Failed to unload $mod" + return 1 + fi + fi + return 0 +} + +start() +{ + local RC=0 + local loaded=0 + + echo -n "Enabling NFSoRDMA support:" + + load_modules $LOAD_ULP_MODULES + RC=$[ $RC + $? ] + + if [ $RC -gt 0 ]; then + for mod in $UNLOAD_ULP_MODULES; do + unload_module $mod + done + echo_failure + echo + return $RC + fi + + echo "rdma $PORT" > /proc/fs/nfsd/portlist + sleep 1 + entry=$(grep rdma /proc/fs/nfsd/portlist) + if [ -z "$entry" ]; then + for mod in $UNLOAD_ULP_MODULES; do + unload_module $mod + done + echo_failure + echo + return 1 + fi + + touch /var/lock/subsys/nfs-rdma + echo_success + echo + return $RC +} + +stop() +{ + echo -n "Disabling NFSoRDMA support:" + + if ! is_module svcrdma; then + # Nothing to do, make sure lock file is gone and return + rm -f /var/lock/subsys/nfs-rdma + echo_success + echo + return 0 + fi + + # Tell the nfs server to quit listening on the rdma port + port=$(grep rdma /proc/fs/nfsd/portlist) + if [ -n "$port" ]; then + echo "-$port" > /proc/fs/nfsd/portlist + # Small sleep to let nfsd process our request + sleep 1 + fi + + # Unload NFSoRDMA modules + for mod in $UNLOAD_ULP_MODULES + do + unload_module $mod + RC=$[ $RC + $? ] + done + + [ $RC -eq 0 ] && rm -f /var/lock/subsys/nfs-rdma + [ $RC -eq 0 ] && echo_success || echo_failure + echo + return $RC +} + +status() +{ + entry=$(grep rdma /proc/fs/nfsd/portlist) + + if [ -z "$entry" ]; then + if [ -f /var/lock/subsys/nfs-rdma ]; then + return 2 + else + return 3 + fi + else + return 0 + fi +} + +restart () +{ + stop + start +} + +condrestart () +{ + [ -e /var/lock/subsys/nfs-rdma ] && restart || return 0 +} + +usage () +{ + echo + echo "Usage: `basename $0` {start|stop|restart|condrestart|try-restart|force-reload|status}" + echo + return 2 +} + +case $1 in + start|stop|restart|condrestart|try-restart|force-reload) + [ `id -u` != "0" ] && exit 4 ;; +esac + +case $1 in + start) 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=$? ;; +esac + +exit $RC diff --git a/rdma.spec b/rdma.spec index cc33bb5..8d66a80 100644 --- a/rdma.spec +++ b/rdma.spec @@ -14,6 +14,7 @@ Source1: rdma.init Source2: rdma.fixup-mtrr.awk Source3: rdma.90-rdma.rules Source4: rdma.ifup-ib +Source5: rdma.nfs-rdma.init BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch Requires(post): chkconfig @@ -38,6 +39,7 @@ install -m 0755 %{SOURCE1} ${RPM_BUILD_ROOT}%{_initrddir}/%{name} install -m 0644 %{SOURCE2} ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/fixup-mtrr.awk install -m 0644 %{SOURCE3} ${RPM_BUILD_ROOT}%{_sysconfdir}/udev/rules.d/90-%{name}.rules install -m 0755 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/network-scripts/ifup-ib +install -m 0755 %{SOURCE5} %{buildroot}%{_initrddir}/nfs-rdma %clean rm -rf ${RPM_BUILD_ROOT} @@ -58,12 +60,16 @@ fi %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf %{_sysconfdir}/%{name}/fixup-mtrr.awk %{_initrddir}/%{name} +%{_initrddir}/nfs-rdma %{_sysconfdir}/udev/rules.d/90-%{name}.rules %{_sysconfdir}/sysconfig/network-scripts/ifup-ib %changelog * Mon Aug 02 2010 Doug Ledford - 1.0-8 - Update udev rules syntax to eliminate warnings emitted via syslog (bz603264) +- Add new init script for starting/stopping nfs over rdma support +- Require that the nfs-rdma service be down before stopping the rdma + service (bz613437) * Thu Feb 25 2010 Doug Ledford - 1.0-7 - Minor tweak to rdma.init to silence udev warnings (bz567981)