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

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