Blame SOURCES/LVM-activate-fix-issue-with-dashes.patch

05afe3
From 2c219dd000d7f5edd3765a1c6bc5f3e6efb7208b Mon Sep 17 00:00:00 2001
05afe3
From: Paul Mezzanini <pfmeec@rit.edu>
05afe3
Date: Fri, 1 Jun 2018 11:58:06 -0400
05afe3
Subject: [PATCH] Volume groups and logical volumes "-" in their name get
05afe3
 mangled with double dashes in dmsetup.  Switching to wc and just counting
05afe3
 lines while depending on the vgname + lvname filter in the dmsetup call gets
05afe3
 around the issue with dmsetup outputting correctly but grep failing due to
05afe3
 the name mangle.
05afe3
05afe3
Logic for both test cases and dmsetup calls changed so they match too.  No reason
05afe3
to not have matching tests.
05afe3
05afe3
This is AllBad but there isn't a better way that I'm aware of yet.
05afe3
---
05afe3
 heartbeat/LVM-activate | 17 ++++++++++++-----
05afe3
 1 file changed, 12 insertions(+), 5 deletions(-)
05afe3
05afe3
diff --git a/heartbeat/LVM-activate b/heartbeat/LVM-activate
05afe3
index 60e656178..fbd058288 100755
05afe3
--- a/heartbeat/LVM-activate
05afe3
+++ b/heartbeat/LVM-activate
05afe3
@@ -692,20 +692,27 @@ tagging_deactivate() {
05afe3
 # lvs/vgs when the metadata is somehow inconsistent.
05afe3
 #
05afe3
 # So, we have to make compromise that the VG is assumably active if any LV of the VG is active.
05afe3
+#
05afe3
+# Paul:
05afe3
+# VGS + LVS with "-" in their name get mangled with double dashes in dmsetup.
05afe3
+# Switching to wc and just counting lines while depending on the vgname + lvname filter
05afe3
+# in dmsetup gets around the issue with dmsetup reporting correctly but grep failing.
05afe3
+#
05afe3
+# Logic for both test cases and dmsetup calls changed so they match too.
05afe3
+#
05afe3
+# This is AllBad but there isn't a better way that I'm aware of yet.
05afe3
 lvm_status() {
05afe3
 	local dm_count
05afe3
 
05afe3
 	if [ -n "${LV}" ]; then
05afe3
 		# dmsetup ls? It cannot accept device name. It's
05afe3
 		# too heavy to list all DM devices.
05afe3
-		dmsetup info --noheadings --noflush -c -S "vgname=${VG} && lvname=${LV}" \
05afe3
-			| grep -Eq "${VG}-+${LV}"
05afe3
+		dm_count=$(dmsetup info --noheadings --noflush -c -S "vgname=${VG} && lvname=${LV}" |  wc -l )
05afe3
 	else
05afe3
-		dm_count=$(dmsetup --noheadings info -c -S "vgname=${VG}" 2>/dev/null | grep -c "${VG}-")
05afe3
-		test $dm_count -gt 0
05afe3
+		dm_count=$(dmsetup info --noheadings --noflush -c -S "vgname=${VG}" 2>/dev/null | wc -l )
05afe3
 	fi
05afe3
 
05afe3
-	if [ $? -ne 0 ]; then
05afe3
+	if [ $dm_count -eq 0 ]; then
05afe3
 		return $OCF_NOT_RUNNING
05afe3
 	fi
05afe3