resource-agents/SOURCES/bz1777381-Filesystem-2-udev-settle.patch

125 lines
3.9 KiB
Diff
Raw Normal View History

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