Blame SOURCES/lvmlockd-add-cmirrord-support.patch

b4b3ce
From d4c9de6264251e4dbc91b64aaf7f500919d08d60 Mon Sep 17 00:00:00 2001
b4b3ce
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
b4b3ce
Date: Fri, 17 Aug 2018 12:48:46 +0200
b4b3ce
Subject: [PATCH] lvmlockd: add cmirrord support
b4b3ce
b4b3ce
---
b4b3ce
 heartbeat/lvmlockd | 53 ++++++++++++++++++++++++++++++++++++++++++----
b4b3ce
 1 file changed, 49 insertions(+), 4 deletions(-)
b4b3ce
b4b3ce
diff --git a/heartbeat/lvmlockd b/heartbeat/lvmlockd
b4b3ce
index 7fe73e364..57f7fdc76 100755
b4b3ce
--- a/heartbeat/lvmlockd
b4b3ce
+++ b/heartbeat/lvmlockd
b4b3ce
@@ -59,6 +59,14 @@ For more information, refer to manpage lvmlockd.8.
b4b3ce
 <shortdesc lang="en">This agent manages the lvmlockd daemon</shortdesc>
b4b3ce
 
b4b3ce
 <parameters>
b4b3ce
+<parameter name="with_cmirrord" unique="0" required="0">
b4b3ce
+<longdesc lang="en">
b4b3ce
+Start with cmirrord (cluster mirror log daemon).
b4b3ce
+</longdesc>
b4b3ce
+<shortdesc lang="en">activate cmirrord</shortdesc>
b4b3ce
+<content type="boolean" default="false" />
b4b3ce
+</parameter>
b4b3ce
+
b4b3ce
 <parameter name="pidfile" unique="0">
b4b3ce
 <longdesc lang="en">pid file</longdesc>
b4b3ce
 <shortdesc lang="en">pid file</shortdesc>
b4b3ce
@@ -102,6 +110,7 @@ END
b4b3ce
 : ${OCF_RESKEY_pidfile:="/run/lvmlockd.pid"}
b4b3ce
 
b4b3ce
 LOCKD="lvmlockd"
b4b3ce
+CMIRRORD="cmirrord"
b4b3ce
 # 0.5s sleep each count
b4b3ce
 TIMEOUT_COUNT=20
b4b3ce
 
b4b3ce
@@ -138,6 +147,21 @@ silent_status()
b4b3ce
 
b4b3ce
 	if [ -n "$pid" ] ; then
b4b3ce
 		daemon_is_running "$pid"
b4b3ce
+		rc=$?
b4b3ce
+		mirror_rc=$rc
b4b3ce
+
b4b3ce
+		if ocf_is_true $OCF_RESKEY_with_cmirrord; then
b4b3ce
+			pid=$(pgrep $CMIRRORD | head -n1)
b4b3ce
+			daemon_is_running "$pid"
b4b3ce
+			mirror_rc=$?
b4b3ce
+		fi
b4b3ce
+
b4b3ce
+		# If these ever don't match, return error to force recovery
b4b3ce
+		if [ $mirror_rc -ne $rc ]; then
b4b3ce
+			return $OCF_ERR_GENERIC
b4b3ce
+		fi
b4b3ce
+
b4b3ce
+		return $rc
b4b3ce
 	else
b4b3ce
 		# No pid file
b4b3ce
 		false
b4b3ce
@@ -199,6 +223,16 @@ lvmlockd_start() {
b4b3ce
 		return $OCF_SUCCESS
b4b3ce
 	fi
b4b3ce
 
b4b3ce
+	if ocf_is_true $OCF_RESKEY_with_cmirrord; then
b4b3ce
+		ocf_log info "starting ${CMIRRORD}..."
b4b3ce
+		$CMIRRORD
b4b3ce
+		rc=$?
b4b3ce
+		if [ $rc -ne $OCF_SUCCESS ] ; then
b4b3ce
+			ocf_exit_reason "Failed to start ${CMIRRORD}, exit code: $rc"
b4b3ce
+			return $OCF_ERR_GENERIC
b4b3ce
+		fi
b4b3ce
+	fi
b4b3ce
+
b4b3ce
 	if [ ! -z "$OCF_RESKEY_socket_path" ] ; then
b4b3ce
 		extras="$extras -s ${OCF_RESKEY_socket_path}"
b4b3ce
 	fi
b4b3ce
@@ -252,10 +286,11 @@ wait_lockspaces_close()
b4b3ce
 
b4b3ce
 kill_stop()
b4b3ce
 {
b4b3ce
-	local pid=$1
b4b3ce
+	local proc=$1
b4b3ce
+	local pid=$2
b4b3ce
 	local retries=0
b4b3ce
 
b4b3ce
-	ocf_log info "Killing ${LOCKD} (pid=$pid)"
b4b3ce
+	ocf_log info "Killing $proc (pid=$pid)"
b4b3ce
 	while
b4b3ce
 		daemon_is_running $pid && [ $retries -lt "$TIMEOUT_COUNT" ]
b4b3ce
 	do
b4b3ce
@@ -292,9 +327,15 @@ lvmlockd_stop() {
b4b3ce
 	wait_lockspaces_close
b4b3ce
 
b4b3ce
 	pid=$(get_pid)
b4b3ce
-	kill_stop $pid
b4b3ce
+	kill_stop $LOCKD $pid
b4b3ce
+
b4b3ce
+	if ocf_is_true $OCF_RESKEY_with_cmirrord; then
b4b3ce
+		pid=$(pgrep $CMIRRORD)
b4b3ce
+		kill_stop $CMIRRORD $pid
b4b3ce
+	fi
b4b3ce
+
b4b3ce
 	if silent_status ; then
b4b3ce
-		ocf_exit_reason "Failed to stop, ${LOCKD}[$pid] still running."
b4b3ce
+		ocf_exit_reason "Failed to stop, ${LOCKD} or ${CMIRRORD} still running."
b4b3ce
 		return $OCF_ERR_GENERIC
b4b3ce
 	fi
b4b3ce
 
b4b3ce
@@ -317,6 +358,10 @@ lvmlockd_validate() {
b4b3ce
 	check_binary pgrep
b4b3ce
 	check_binary lvmlockctl
b4b3ce
 
b4b3ce
+	if ocf_is_true $OCF_RESKEY_with_cmirrord; then
b4b3ce
+		check_binary $CMIRRORD
b4b3ce
+	fi
b4b3ce
+
b4b3ce
 	return $OCF_SUCCESS
b4b3ce
 }
b4b3ce