From 931a9b4dd1c52faeb085f3017b847a3aea8f6ffd Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Thu, 28 Apr 2016 20:52:48 -0500 Subject: [PATCH 01/10] ctdb-scripts: Unwrap one line in 60.nfs for readability Signed-off-by: Jose A. Rivera Reviewed-by: Martin Schwenke --- ctdb/config/events.d/60.nfs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ctdb/config/events.d/60.nfs b/ctdb/config/events.d/60.nfs index c25b73e..f227e5d 100755 --- a/ctdb/config/events.d/60.nfs +++ b/ctdb/config/events.d/60.nfs @@ -250,8 +250,7 @@ ctdb_check_rpc () if ! ctdb_check_rpc_out=$(rpcinfo -T $_family $_localhost \ $_progname $_version 2>&1) ; then - ctdb_check_rpc_out="$_progname failed RPC check: -$ctdb_check_rpc_out" + ctdb_check_rpc_out="$_progname failed RPC check: $ctdb_check_rpc_out" echo "$ctdb_check_rpc_out" return 1 fi -- 2.5.5 From d4c9c96bf7b58ba5a0e77e09f0dbf83e2a47d2a5 Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Thu, 28 Apr 2016 20:58:30 -0500 Subject: [PATCH 02/10] ctdb-scripts: Various small fixes to example nfs-ganesha-callout Comment typos and clarifications, erroneous variable names, corrected pathnames, reorganizing variables, and squashing a few non-fatal scripting errors. Signed-off-by: Jose A. Rivera Reviewed-by: Martin Schwenke --- ctdb/doc/examples/nfs-ganesha-callout | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ctdb/doc/examples/nfs-ganesha-callout b/ctdb/doc/examples/nfs-ganesha-callout index a3d0471..a564a67 100755 --- a/ctdb/doc/examples/nfs-ganesha-callout +++ b/ctdb/doc/examples/nfs-ganesha-callout @@ -14,8 +14,13 @@ # * Set CTDB_NFS_CALLOUT in your CTDB configuration to point to this # script # -# * Rename nfs-checks.d/{20.nfs.check,30.nlockmgr.check,50.mountd.check} -# so that they no longer have the ".check" suffix +# * Rename the following files in nfs-checks.d so that they no longer +# have the ".check" suffix: +# * 10.status.check +# * 20.nfs.check +# * 30.nlockmgr.check +# * 40.mountd.check +# * 50.rquotad.check # # * Install 20.nfs-ganesha.check to nfs-checks.d/20.nfs.check @@ -121,6 +126,7 @@ GANRECDIR="/var/lib/nfs/ganesha" GANRECDIR2="/var/lib/nfs/ganesha/recevents" GANRECDIR3="/var/lib/nfs/ganesha_local" +# Return 'active' if the shared filesystem is accessible. get_cluster_fs_state () { case $CTDB_CLUSTER_FILESYSTEM_TYPE in @@ -128,7 +134,8 @@ get_cluster_fs_state () /usr/lpp/mmfs/bin/mmgetstate | awk 'NR == 4 { print $3 }' ;; *) - die "File system $CTDB_CLUSTER_FILESYSTEM_TYPE not supported" + echo "File system $CTDB_CLUSTER_FILESYSTEM_TYPE not supported" + exit 1 ;; esac } @@ -170,12 +177,12 @@ service_check () # Always succeed if cluster filesystem is not active _cluster_fs_state=$(get_cluster_fs_state) if [ $_cluster_fs_state != "active" ] ; then - exit 0 + return 0 fi # Check that NFS Ganesha is running, according to PID file _pidfile="/var/run/ganesha.pid" - _ganesha="/usr/bin/$CTDB_CLUSTER_FILESYSTEM_TYPE.ganesha.nfsd" + _ganesha="/usr/bin/ganesha.nfsd" if ! { read _pid < "$_pidfile" && \ grep "$_ganesha" "${PROCFS_PATH}/${_pid}/cmdline" ; } >/dev/null 2>&1 ; then echo "ERROR: NFS Ganesha not running according to PID file" @@ -221,7 +228,7 @@ get_nodenum () nfs_releaseip () { - case $CLUSTER_FILESYSTEM_TYPE in + case $CTDB_CLUSTER_FILESYSTEM_TYPE in gpfs) _nnum=$(get_nodenum) _tdate=$(date +"%s") @@ -234,7 +241,7 @@ nfs_releaseip () nfs_takeip () { - case $CLUSTER_FILESYSTEM_TYPE in + case $CTDB_CLUSTER_FILESYSTEM_TYPE in gpfs) _nnum=$(get_nodenum) _tdate=$(date +"%s") @@ -254,9 +261,10 @@ nfs_shutdown () nfs_startup () { + basic_stop "nfs" || true + create_ganesha_recdirs - basic_stop "nfs" || true basic_start "nfs" _f="${PROCFS_PATH}/sys/net/ipv4/tcp_tw_recycle" if [ "$_f" ] ; then -- 2.5.5 From dead7919828ea310ccf6c322a5e75261acd93f56 Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Tue, 10 May 2016 16:50:10 +0200 Subject: [PATCH 03/10] ctdb-scripts: Organize global variables in nfs_ganesha_callout Signed-off-by: Jose A. Rivera Reviewed-by: Martin Schwenke --- ctdb/doc/examples/nfs-ganesha-callout | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ctdb/doc/examples/nfs-ganesha-callout b/ctdb/doc/examples/nfs-ganesha-callout index a564a67..144cd4d 100755 --- a/ctdb/doc/examples/nfs-ganesha-callout +++ b/ctdb/doc/examples/nfs-ganesha-callout @@ -35,14 +35,17 @@ # Exit on 1st error set -e +# To change the following, edit the default values below. Do not set +# these - they aren't configuration variables, just hooks for testing. +nfs_exports_file="${CTDB_NFS_EXPORTS_FILE:-/etc/ganesha/ganesha.conf}" +nfs_service="${CTDB_NFS_SERVICE:-nfs-ganesha}" +ganesha_rec_subdir=${CTDB_GANESHA_REC_SUBDIR:-.ganesha} +procfs=${PROCFS_PATH:-/proc} + if [ -z "$CTDB_CLUSTER_FILESYSTEM_TYPE" ] ; then CTDB_CLUSTER_FILESYSTEM_TYPE="gpfs" fi -# Override for unit testing -if [ -z "$PROCFS_PATH" ] ; then - PROCFS_PATH="/proc" -fi ################################################## @@ -62,8 +65,6 @@ EOF ################################################## # Basic service stop and start -nfs_service="nfs-ganesha-$CTDB_CLUSTER_FILESYSTEM_TYPE" - basic_stop () { case "$1" in @@ -142,15 +143,13 @@ get_cluster_fs_state () create_ganesha_recdirs () { - [ -n "$CTDB_GANESHA_REC_SUBDIR" ] || CTDB_GANESHA_REC_SUBDIR=".ganesha" - _mounts=$(mount -t $CTDB_CLUSTER_FILESYSTEM_TYPE) if [ -z "$_mounts" ]; then echo "startup $CTDB_CLUSTER_FILESYSTEM_TYPE not ready" exit 0 fi _mntpt=$(echo "$_mounts" | sort | awk 'NR == 1 {print $3}') - _link_dst="${_mntpt}/${CTDB_GANESHA_REC_SUBDIR}" + _link_dst="${_mntpt}/${ganesha_rec_subdir}" mkdir -vp "$_link_dst" if [ ! -L "$GANRECDIR" ] ; then rm -vrf "$GANRECDIR" @@ -184,7 +183,7 @@ service_check () _pidfile="/var/run/ganesha.pid" _ganesha="/usr/bin/ganesha.nfsd" if ! { read _pid < "$_pidfile" && \ - grep "$_ganesha" "${PROCFS_PATH}/${_pid}/cmdline" ; } >/dev/null 2>&1 ; then + grep "$_ganesha" "${procfs}/${_pid}/cmdline" ; } >/dev/null 2>&1 ; then echo "ERROR: NFS Ganesha not running according to PID file" return 1 fi @@ -266,7 +265,7 @@ nfs_startup () create_ganesha_recdirs basic_start "nfs" - _f="${PROCFS_PATH}/sys/net/ipv4/tcp_tw_recycle" + _f="${procfs}/sys/net/ipv4/tcp_tw_recycle" if [ "$_f" ] ; then echo 1 >"$_f" fi @@ -277,7 +276,7 @@ nfs_startup () nfs_monitor_list_shares () { - grep Path /etc/ganesha/$CTDB_CLUSTER_FILESYSTEM_TYPE.ganesha.exports.conf | + grep Path $nfs_exports_file | cut -f2 -d\" | sort -u } -- 2.5.5 From 858f75fe149da49e550788ad3be6aae3b842b33a Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Thu, 28 Apr 2016 21:12:33 -0500 Subject: [PATCH 04/10] ctdb-scripts: Add register action to nfs-ganesha-callout Signed-off-by: Jose A. Rivera Reviewed-by: Martin Schwenke --- ctdb/doc/examples/nfs-ganesha-callout | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ctdb/doc/examples/nfs-ganesha-callout b/ctdb/doc/examples/nfs-ganesha-callout index 144cd4d..602d13c 100755 --- a/ctdb/doc/examples/nfs-ganesha-callout +++ b/ctdb/doc/examples/nfs-ganesha-callout @@ -283,6 +283,22 @@ nfs_monitor_list_shares () ################################################## +nfs_register () +{ + cat < Date: Wed, 4 May 2016 13:03:29 -0500 Subject: [PATCH 05/10] ctdb-scripts: Use D-Bus messages to trigger grace in nfs-ganesha-callout Signed-off-by: Jose A. Rivera Reviewed-by: Martin Schwenke --- ctdb/doc/examples/nfs-ganesha-callout | 52 +++++++++++++++-------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/ctdb/doc/examples/nfs-ganesha-callout b/ctdb/doc/examples/nfs-ganesha-callout index 602d13c..634b673 100755 --- a/ctdb/doc/examples/nfs-ganesha-callout +++ b/ctdb/doc/examples/nfs-ganesha-callout @@ -23,6 +23,10 @@ # * 50.rquotad.check # # * Install 20.nfs-ganesha.check to nfs-checks.d/20.nfs.check +# +# * It is recommended, but not required, to install the grace_period +# script (usually shipped in a utils package for NFS-Ganesha) to +# /usr/bin/grace_period # I (Martin Schwenke) hereby relicense all of my contributions to this # callout (and, previously, to 60.ganesha) to a license compatible @@ -124,7 +128,6 @@ service_start () # Nitty gritty - monitoring and IP handling GANRECDIR="/var/lib/nfs/ganesha" -GANRECDIR2="/var/lib/nfs/ganesha/recevents" GANRECDIR3="/var/lib/nfs/ganesha_local" # Return 'active' if the shared filesystem is accessible. @@ -165,7 +168,6 @@ create_ganesha_recdirs () ln -sv "$_link_dst" "$GANRECDIR" fi - mkdir -p "$GANRECDIR2" mkdir -p "$GANRECDIR3" } @@ -213,41 +215,31 @@ service_check () #------------------------------------------------- -get_nodenum () -{ - _nodenum_file="${GANRECDIR}/gpfs_nodenum" - - if [ ! -f "$_nodenum_file" ]; then - /usr/lpp/mmfs/bin/mmlsconfig myNodeConfigNumber | - awk '{print $2}' >"$_nodenum_file" - fi - - cat "$_nodenum_file" -} - nfs_releaseip () { - case $CTDB_CLUSTER_FILESYSTEM_TYPE in - gpfs) - _nnum=$(get_nodenum) - _tdate=$(date +"%s") - _touchtgt="releaseip_${_tdate}_${_nnum}_${2}_${3}_${1}" - touch "${GANRECDIR2}/${_touchtgt}" - touch "$GANRECDIR2/my${_touchtgt}" - ;; - esac + if [ -x "/usr/bin/grace_period" ]; then + /usr/bin/grace_period "2:${2}" + else + dbus-send --print-reply --system --dest=org.ganesha.nfsd \ + /org/ganesha/nfsd/admin org.ganesha.nfsd.admin.grace \ + string:"2:${2}" + fi } nfs_takeip () { - case $CTDB_CLUSTER_FILESYSTEM_TYPE in - gpfs) - _nnum=$(get_nodenum) - _tdate=$(date +"%s") - _touchtgt="takeip_${_tdate}_${_nnum}_${2}_${3}_${1}" - touch "${GANRECDIR2}/${_touchtgt}" - ;; + case $state_fs in + glusterfs) + check_ln ${NODESTATEDIR} ${GANSTATEDIR}/${2} + ;; esac + if [ -x "/usr/bin/grace_period" ]; then + /usr/bin/grace_period "5:${2}" + else + dbus-send --print-reply --system --dest=org.ganesha.nfsd \ + /org/ganesha/nfsd/admin org.ganesha.nfsd.admin.grace \ + string:"5:${2}" + fi } ################################################## -- 2.5.5 From 5d631309b37f16596da1455dbeac74f005b8ddc8 Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Tue, 10 May 2016 16:27:43 +0200 Subject: [PATCH 06/10] ctdb-scripts: Cleanup service_check() in nfs-ganesha-callout Signed-off-by: Jose A. Rivera Reviewed-by: Martin Schwenke --- ctdb/doc/examples/nfs-ganesha-callout | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/ctdb/doc/examples/nfs-ganesha-callout b/ctdb/doc/examples/nfs-ganesha-callout index 634b673..633667a 100755 --- a/ctdb/doc/examples/nfs-ganesha-callout +++ b/ctdb/doc/examples/nfs-ganesha-callout @@ -128,7 +128,6 @@ service_start () # Nitty gritty - monitoring and IP handling GANRECDIR="/var/lib/nfs/ganesha" -GANRECDIR3="/var/lib/nfs/ganesha_local" # Return 'active' if the shared filesystem is accessible. get_cluster_fs_state () @@ -167,8 +166,6 @@ create_ganesha_recdirs () if [ ! -e "$GANRECDIR" ]; then ln -sv "$_link_dst" "$GANRECDIR" fi - - mkdir -p "$GANRECDIR3" } service_check () @@ -190,26 +187,6 @@ service_check () return 1 fi - # Check red conditions against limit - _reds_max=2 - _reds=$(ls $GANRECDIR3 | grep -c "red") - - if [ $_reds -ge $_reds_max ] ; then - echo "Too many red conditions (${_reds}/${_reds_max})" - return 1 - fi - - # Check for stall - _stall_max=120 - _now=$(date +"%s") - _last=$(ls -t $GANRECDIR3 | sed -n -e '1s@_.*@@p') - [ -n $_last ] || _last=$_now # Handle startup - _stall=$(($_now - $_last)) - if [ $_stall -ge $_stall_max ] ; then - echo "ERROR: Stalled for ${_stall} second(s)" - return 1 - fi - return 0 } -- 2.5.5 From f4cadf7ae783488f06f7bd7dd04cb9a97b4e938e Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Wed, 4 May 2016 14:16:27 -0500 Subject: [PATCH 07/10] ctdb-scripts: Parametize symlink checking in nfs-ganesha-callout Signed-off-by: Jose A. Rivera Reviewed-by: Martin Schwenke --- ctdb/doc/examples/nfs-ganesha-callout | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/ctdb/doc/examples/nfs-ganesha-callout b/ctdb/doc/examples/nfs-ganesha-callout index 633667a..80bba89 100755 --- a/ctdb/doc/examples/nfs-ganesha-callout +++ b/ctdb/doc/examples/nfs-ganesha-callout @@ -129,6 +129,25 @@ service_start () GANRECDIR="/var/lib/nfs/ganesha" +# Check that a symlink exists, create it otherwise. +# Usage: check_ln +check_ln () +{ + if [ ! -L "${2}" ] ; then + rm -vrf "${2}" + else + _t=$(readlink "${2}") + if [ "$_t" != "${1}" ] ; then + rm -v "${2}" + fi + fi + # This is not an "else". It also re-creates the link if it was + # removed above! + if [ ! -e "${2}" ]; then + ln -sfv "${1}" "${2}" + fi +} + # Return 'active' if the shared filesystem is accessible. get_cluster_fs_state () { @@ -153,19 +172,7 @@ create_ganesha_recdirs () _mntpt=$(echo "$_mounts" | sort | awk 'NR == 1 {print $3}') _link_dst="${_mntpt}/${ganesha_rec_subdir}" mkdir -vp "$_link_dst" - if [ ! -L "$GANRECDIR" ] ; then - rm -vrf "$GANRECDIR" - else - _t=$(readlink "$GANRECDIR") - if [ "$_t" != "$_link_dst" ] ; then - rm -v "$GANRECDIR" - fi - fi - # This is not an "else". It also re-creates the link if it was - # removed above! - if [ ! -e "$GANRECDIR" ]; then - ln -sv "$_link_dst" "$GANRECDIR" - fi + check_ln "$_link_dst" "$GANRECDIR" } service_check () -- 2.5.5 From e87d563241d839133a85a2724d143bbadae36c59 Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Thu, 28 Apr 2016 21:18:05 -0500 Subject: [PATCH 08/10] ctdb-scripts: Add config options for use by clustered NFS Add CTDB_NFS_STATE_FS_TYPE and CTDB_NFS_STATE_MNT config options, show use in nfs-ganesha-callout. Since the callout script is only an example, we officially don't have default values for these. Signed-off-by: Jose A. Rivera Reviewed-by: Martin Schwenke --- ctdb/config/events.d/60.nfs | 8 ++++++++ ctdb/doc/ctdbd.conf.5.xml | 33 ++++++++++++++++++++------------- ctdb/doc/examples/nfs-ganesha-callout | 17 +++++++++-------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/ctdb/config/events.d/60.nfs b/ctdb/config/events.d/60.nfs index f227e5d..894886a 100755 --- a/ctdb/config/events.d/60.nfs +++ b/ctdb/config/events.d/60.nfs @@ -21,6 +21,14 @@ export CTDB_NFS_CALLOUT # If the callout wants to use this then it must create it export CTDB_NFS_CALLOUT_STATE_DIR="${service_state_dir}/callout-state" +# Export, if set, for use by clustered NFS callouts +if [ -n "$CTDB_NFS_STATE_FS_TYPE" ] ; then + export CTDB_NFS_STATE_FS_TYPE +fi +if [ -n "$CTDB_NFS_STATE_MNT" ] ; then + export CTDB_NFS_STATE_MNT +fi + nfs_callout_cache="${service_state_dir}/nfs_callout_cache" nfs_callout_cache_callout="${nfs_callout_cache}/CTDB_NFS_CALLOUT" nfs_callout_cache_ops="${nfs_callout_cache}/ops" diff --git a/ctdb/doc/ctdbd.conf.5.xml b/ctdb/doc/ctdbd.conf.5.xml index a364c9f..f69f705 100644 --- a/ctdb/doc/ctdbd.conf.5.xml +++ b/ctdb/doc/ctdbd.conf.5.xml @@ -1062,19 +1062,6 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000 - CTDB_CLUSTER_FILESYSTEM_TYPE=gpfs - - - The type of cluster filesystem to use with NFS-ganesha. - Currently only "gpfs" is supported. - - - Default is "gpfs". - - - - - CTDB_MANAGES_NFS=yes|no @@ -1148,6 +1135,26 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000 + + CTDB_NFS_STATE_FS_TYPE=TYPE + + + The type of filesystem used for a clustered NFS' shared + state. No default. + + + + + + CTDB_NFS_STATE_MNT=DIR + + + The directory where a clustered NFS' shared state will be + located. No default. + + + + diff --git a/ctdb/doc/examples/nfs-ganesha-callout b/ctdb/doc/examples/nfs-ganesha-callout index 80bba89..06d08ad 100755 --- a/ctdb/doc/examples/nfs-ganesha-callout +++ b/ctdb/doc/examples/nfs-ganesha-callout @@ -39,6 +39,11 @@ # Exit on 1st error set -e +# Filesystem type and mount point for the (typically clustered) +# volume that will contain the NFS-Ganesha state. +state_fs="${CTDB_NFS_STATE_FS_TYPE:-gpfs}" +state_dir="${CTDB_NFS_STATE_MNT}" # No sane default. + # To change the following, edit the default values below. Do not set # these - they aren't configuration variables, just hooks for testing. nfs_exports_file="${CTDB_NFS_EXPORTS_FILE:-/etc/ganesha/ganesha.conf}" @@ -46,10 +51,6 @@ nfs_service="${CTDB_NFS_SERVICE:-nfs-ganesha}" ganesha_rec_subdir=${CTDB_GANESHA_REC_SUBDIR:-.ganesha} procfs=${PROCFS_PATH:-/proc} -if [ -z "$CTDB_CLUSTER_FILESYSTEM_TYPE" ] ; then - CTDB_CLUSTER_FILESYSTEM_TYPE="gpfs" -fi - ################################################## @@ -151,12 +152,12 @@ check_ln () # Return 'active' if the shared filesystem is accessible. get_cluster_fs_state () { - case $CTDB_CLUSTER_FILESYSTEM_TYPE in + case $state_fs in gpfs) /usr/lpp/mmfs/bin/mmgetstate | awk 'NR == 4 { print $3 }' ;; *) - echo "File system $CTDB_CLUSTER_FILESYSTEM_TYPE not supported" + echo "File system $state_fs not supported" exit 1 ;; esac @@ -164,9 +165,9 @@ get_cluster_fs_state () create_ganesha_recdirs () { - _mounts=$(mount -t $CTDB_CLUSTER_FILESYSTEM_TYPE) + _mounts=$(mount -t $state_fs) if [ -z "$_mounts" ]; then - echo "startup $CTDB_CLUSTER_FILESYSTEM_TYPE not ready" + echo "startup $state_fs not ready" exit 0 fi _mntpt=$(echo "$_mounts" | sort | awk 'NR == 1 {print $3}') -- 2.5.5 From 1e1c77804920f6d6e6a6fa06cb2132b4ef5e32ab Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Tue, 3 May 2016 01:53:07 -0500 Subject: [PATCH 09/10] ctdb-scripts: Section off GPFS-specific functionality in nfs-ganesha-callout Signed-off-by: Jose A. Rivera Reviewed-by: Martin Schwenke --- ctdb/doc/examples/nfs-ganesha-callout | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ctdb/doc/examples/nfs-ganesha-callout b/ctdb/doc/examples/nfs-ganesha-callout index 06d08ad..7351e34 100755 --- a/ctdb/doc/examples/nfs-ganesha-callout +++ b/ctdb/doc/examples/nfs-ganesha-callout @@ -51,6 +51,12 @@ nfs_service="${CTDB_NFS_SERVICE:-nfs-ganesha}" ganesha_rec_subdir=${CTDB_GANESHA_REC_SUBDIR:-.ganesha} procfs=${PROCFS_PATH:-/proc} +case $state_fs in + gpfs) + GANRECDIR="/var/lib/nfs/ganesha" + ;; +esac + ################################################## @@ -128,8 +134,6 @@ service_start () ################################################## # Nitty gritty - monitoring and IP handling -GANRECDIR="/var/lib/nfs/ganesha" - # Check that a symlink exists, create it otherwise. # Usage: check_ln check_ln () @@ -170,10 +174,15 @@ create_ganesha_recdirs () echo "startup $state_fs not ready" exit 0 fi - _mntpt=$(echo "$_mounts" | sort | awk 'NR == 1 {print $3}') - _link_dst="${_mntpt}/${ganesha_rec_subdir}" - mkdir -vp "$_link_dst" - check_ln "$_link_dst" "$GANRECDIR" + + case $state_fs in + gpfs) + _mntpt=$(echo "$_mounts" | sort | awk 'NR == 1 {print $3}') + _link_dst="${_mntpt}/${ganesha_rec_subdir}" + mkdir -vp "$_link_dst" + check_ln "$_link_dst" "$GANRECDIR" + ;; + esac } service_check () -- 2.5.5 From c2421d5a5bd9e827ac734f39d0a6a5b362f0620f Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Thu, 28 Apr 2016 21:24:16 -0500 Subject: [PATCH 10/10] ctdb-scripts: Add GlusterFS support to nfs-ganesha-callout Signed-off-by: Jose A. Rivera Reviewed-by: Martin Schwenke --- ctdb/doc/examples/nfs-ganesha-callout | 39 ++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/ctdb/doc/examples/nfs-ganesha-callout b/ctdb/doc/examples/nfs-ganesha-callout index 7351e34..34794c1 100755 --- a/ctdb/doc/examples/nfs-ganesha-callout +++ b/ctdb/doc/examples/nfs-ganesha-callout @@ -55,6 +55,16 @@ case $state_fs in gpfs) GANRECDIR="/var/lib/nfs/ganesha" ;; + glusterfs) + if [ -z "${state_dir}" ]; then + echo "CTDB_NFS_STATE_MNT not defined for GlusterFS" + exit 1 + fi + host=`hostname` + NODESTATEDIR="$state_dir/nfs-ganesha/$host" + GANSTATEDIR="$state_dir/nfs-ganesha/.noderefs" + NODESTATELN="$GANSTATEDIR/$host" + ;; esac @@ -160,6 +170,10 @@ get_cluster_fs_state () gpfs) /usr/lpp/mmfs/bin/mmgetstate | awk 'NR == 4 { print $3 }' ;; + glusterfs) + # Since we're past create_ganesha_recdirs(), we're active. + echo "active" + ;; *) echo "File system $state_fs not supported" exit 1 @@ -169,7 +183,10 @@ get_cluster_fs_state () create_ganesha_recdirs () { - _mounts=$(mount -t $state_fs) + if ! _mounts=$(mount | grep $state_fs); then + echo "Failed to find mounts of type $state_fs" + exit 1 + fi if [ -z "$_mounts" ]; then echo "startup $state_fs not ready" exit 0 @@ -182,6 +199,26 @@ create_ganesha_recdirs () mkdir -vp "$_link_dst" check_ln "$_link_dst" "$GANRECDIR" ;; + glusterfs) + [ -d /var/lib/nfs.backup ] || mv /var/lib/nfs /var/lib/nfs.backup + check_ln ${NODESTATEDIR} /var/lib/nfs + + mkdir -p ${NODESTATEDIR}/ganesha/v4recov + mkdir -p ${NODESTATEDIR}/ganesha/v4old + mkdir -p ${NODESTATEDIR}/statd/sm + mkdir -p ${NODESTATEDIR}/statd/sm.bak + touch ${NODESTATEDIR}/state + touch ${NODESTATEDIR}/statd/state + + mkdir -p ${GANSTATEDIR} + check_ln ${NODESTATEDIR} ${NODESTATELN} + for node in `ls ${GANSTATEDIR}`; do + if [ "${node}" != "${host}" ]; then + check_ln ${GANSTATEDIR}/${node}/ganesha ${NODESTATEDIR}/ganesha/${node} + check_ln ${GANSTATEDIR}/${node}/statd ${NODESTATEDIR}/statd/${node} + fi + done + ;; esac } -- 2.5.5