Blame SOURCES/bz1777381-Filesystem-2-udev-settle.patch

b4b3ce
From af39017b9333dcbadee2a15f3829667f2b18fb45 Mon Sep 17 00:00:00 2001
b4b3ce
From: Roger Zhou <zzhou@suse.com>
b4b3ce
Date: Fri, 20 Dec 2019 23:28:45 +0800
b4b3ce
Subject: [PATCH 1/2] Filesystem: respect udevd need time to create UUID
b4b3ce
 symlinks
b4b3ce
b4b3ce
To refresh the filesystem UUID, there is a race condition. partprobe
b4b3ce
might return before the UUID symlink get created. Particularly, when the
b4b3ce
system has many devices, the udev daemon could need visible time to
b4b3ce
process the udev event queue. Hence, wait udev for a moment.
b4b3ce
b4b3ce
Signed-off-by: Roger Zhou <zzhou@suse.com>
b4b3ce
---
b4b3ce
 heartbeat/Filesystem | 4 ++++
b4b3ce
 1 file changed, 4 insertions(+)
b4b3ce
b4b3ce
diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
b4b3ce
index 543986441..c21ad5761 100755
b4b3ce
--- a/heartbeat/Filesystem
b4b3ce
+++ b/heartbeat/Filesystem
b4b3ce
@@ -460,6 +460,10 @@ Filesystem_start()
b4b3ce
 			# is not visible yet. Then try partprobe to
b4b3ce
 			# refresh /dev/disk/by-uuid/* up to date.
b4b3ce
 			have_binary partprobe && partprobe >/dev/null 2>&1
b4b3ce
+			local timeout
b4b3ce
+			timeout=${OCF_RESKEY_CRM_meta_timeout:="60000"}
b4b3ce
+			timeout=$((timeout/1000))
b4b3ce
+			have_binary udevadm && udevadm settle -t $timeout --exit-if-exists=$DEVICE
b4b3ce
 		fi
b4b3ce
 
b4b3ce
 		if [ "$DEVICE" != "/dev/null" -a ! -b "$DEVICE" ] ; then
b4b3ce
b4b3ce
From a9fb8077c8201b287ee0486b2a34db4b7d4d8f5d Mon Sep 17 00:00:00 2001
b4b3ce
From: Roger Zhou <zzhou@suse.com>
b4b3ce
Date: Wed, 25 Dec 2019 15:45:03 +0800
b4b3ce
Subject: [PATCH 2/2] Filesystem: add trigger_udev_rules_if_need() for -U, -L,
b4b3ce
 or /dev/xxx device
b4b3ce
b4b3ce
DEVICE parameter of this RA accepts "-U <uuid>" and "-L <label>" in
b4b3ce
addition to "/dev/xxx". Let's add a new function
b4b3ce
trigger_udev_rules_if_needed() to accommodate them all.
b4b3ce
b4b3ce
It is useful in the case a fresh filesystem is just created from another
b4b3ce
node on the shared storage, and is not visible yet.
b4b3ce
b4b3ce
Signed-off-by: Roger Zhou <zzhou@suse.com>
b4b3ce
---
b4b3ce
 heartbeat/Filesystem | 55 ++++++++++++++++++++++++++++++++++----------
b4b3ce
 1 file changed, 43 insertions(+), 12 deletions(-)
b4b3ce
b4b3ce
diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
b4b3ce
index c21ad5761..c716bd0a6 100755
b4b3ce
--- a/heartbeat/Filesystem
b4b3ce
+++ b/heartbeat/Filesystem
b4b3ce
@@ -430,6 +430,47 @@ fstype_supported()
b4b3ce
 }
b4b3ce
 
b4b3ce
 
b4b3ce
+#
b4b3ce
+# In the case a fresh filesystem is just created from another
b4b3ce
+# node on the shared storage, and is not visible yet. Then try
b4b3ce
+# partprobe to refresh /dev/disk/by-{label,uuid}/* up to date.
b4b3ce
+#
b4b3ce
+# DEVICE can be /dev/xxx, -U, -L 
b4b3ce
+#
b4b3ce
+trigger_udev_rules_if_needed()
b4b3ce
+{
b4b3ce
+	local refresh_flag="no"
b4b3ce
+	local tmp
b4b3ce
+	local timeout
b4b3ce
+
b4b3ce
+	if [ $blockdevice = "yes" ]; then
b4b3ce
+		tmp="$DEVICE"
b4b3ce
+		if [ "$DEVICE" != "/dev/null" -a ! -b "$DEVICE" ] ; then
b4b3ce
+			refresh_flag="yes"
b4b3ce
+		fi
b4b3ce
+	else
b4b3ce
+		tmp="`echo $DEVICE|awk '{$1=""; print substr($0,2)}'`"
b4b3ce
+		case "$DEVICE" in 
b4b3ce
+		-U*|--uuid*) 
b4b3ce
+			tmp="/dev/disk/by-uuid/$tmp" 
b4b3ce
+			;;
b4b3ce
+		-L*|--label*)
b4b3ce
+			tmp="/dev/disk/by-label/$tmp" 
b4b3ce
+			;;
b4b3ce
+		esac
b4b3ce
+		[ ! -b "$tmp" ] && refresh_flag="yes"
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	[ "$refresh_flag" = "no" ] && return
b4b3ce
+
b4b3ce
+	have_binary partprobe && partprobe >/dev/null 2>&1
b4b3ce
+	timeout=${OCF_RESKEY_CRM_meta_timeout:="60000"}
b4b3ce
+	timeout=$((timeout/1000))
b4b3ce
+	have_binary udevadm && udevadm settle -t $timeout --exit-if-exists=$tmp
b4b3ce
+
b4b3ce
+	return $?
b4b3ce
+}
b4b3ce
+
b4b3ce
 #
b4b3ce
 # START: Start up the filesystem
b4b3ce
 #
b4b3ce
@@ -453,19 +494,9 @@ Filesystem_start()
b4b3ce
 	# NOTE: Some filesystem types don't need this step...  Please modify
b4b3ce
 	#       accordingly
b4b3ce
 
b4b3ce
-	if [ $blockdevice = "yes" ]; then
b4b3ce
-		if [ "$DEVICE" != "/dev/null" -a ! -b "$DEVICE" ] ; then
b4b3ce
-			# In the case a fresh filesystem is just created
b4b3ce
-			# from another node on the shared storage, and
b4b3ce
-			# is not visible yet. Then try partprobe to
b4b3ce
-			# refresh /dev/disk/by-uuid/* up to date.
b4b3ce
-			have_binary partprobe && partprobe >/dev/null 2>&1
b4b3ce
-			local timeout
b4b3ce
-			timeout=${OCF_RESKEY_CRM_meta_timeout:="60000"}
b4b3ce
-			timeout=$((timeout/1000))
b4b3ce
-			have_binary udevadm && udevadm settle -t $timeout --exit-if-exists=$DEVICE
b4b3ce
-		fi
b4b3ce
+	trigger_udev_rules_if_needed
b4b3ce
 
b4b3ce
+	if [ $blockdevice = "yes" ]; then
b4b3ce
 		if [ "$DEVICE" != "/dev/null" -a ! -b "$DEVICE" ] ; then
b4b3ce
 			ocf_exit_reason "Couldn't find device [$DEVICE]. Expected /dev/??? to exist"
b4b3ce
 			exit $OCF_ERR_INSTALLED