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

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