File 0001-LVM-activate-verify-vg-or-lv-validity.patch of Package resource-agents.19144

From a299281a8ce34a226d380208c6fbc5f845778ad4 Mon Sep 17 00:00:00 2001
From: Zhao Heming <heming.zhao@suse.com>
Date: Thu, 9 Jan 2020 16:30:51 +0800
Subject: [PATCH 1/1] LVM-activate: verify vg or lv validity

When LVM underlying devs disappear, eg iSCSI SAN disks suffer network
disconnect, the pvs/vgs/lvs won't show related PVs/VGs/LVs, but dm
devs won't disappear. This makes the lvm_status() doesn't work as
expect.

This patch uses simple & stupid method "read 1 byte from underlaying
dev" to detect abnormal underlying devices.

Signed-off-by: Zhao Heming <heming.zhao@suse.com>
---
 heartbeat/LVM-activate | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/heartbeat/LVM-activate b/heartbeat/LVM-activate
index 3d6cf364..3ea1d31f 100755
--- a/heartbeat/LVM-activate
+++ b/heartbeat/LVM-activate
@@ -779,6 +779,7 @@ tagging_deactivate() {
 # This is AllBad but there isn't a better way that I'm aware of yet.
 lvm_status() {
 	local dm_count
+	local dm_name
 
 	if [ -n "${LV}" ]; then
 		# dmsetup ls? It cannot accept device name. It's
@@ -792,6 +793,15 @@ lvm_status() {
 		return $OCF_NOT_RUNNING
 	fi
 
+	# if there are many lv in vg dir, pick the first name
+	dm_name="/dev/${VG}/$(ls -1 /dev/${VG} | head -n 1)"
+
+	# read 1 byte to check the dev is alive
+	dd if=${dm_name} of=/dev/null bs=1 count=1 >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+		return $OCF_NOT_RUNNING
+	fi
+
 	return $OCF_SUCCESS
 }
 
-- 
2.26.1

openSUSE Build Service is sponsored by