Blame SOURCES/bz1744103-Filesystem-3-fix-umount-disk-failure.patch

9cf66a
From 69d607dc7568168e874f99d5a8b6bdb66b579d8b Mon Sep 17 00:00:00 2001
9cf66a
From: "yusk.iida" <yusk.iida@gmail.com>
9cf66a
Date: Tue, 7 May 2019 19:37:26 +0900
9cf66a
Subject: [PATCH] Low: Filesystem: Fix a problem umount is not executed in the
9cf66a
 event of a disk failure
9cf66a
9cf66a
---
9cf66a
 heartbeat/Filesystem | 11 ++++++++---
9cf66a
 1 file changed, 8 insertions(+), 3 deletions(-)
9cf66a
9cf66a
diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
9cf66a
index 2a43d1daa..bd974f8f3 100755
9cf66a
--- a/heartbeat/Filesystem
9cf66a
+++ b/heartbeat/Filesystem
9cf66a
@@ -278,7 +278,7 @@ determine_blockdevice() {
9cf66a
 	nfs4|nfs|smbfs|cifs|glusterfs|ceph|tmpfs|overlay|overlayfs|rozofs|zfs|cvfs|none)
9cf66a
 		: ;;
9cf66a
 	*)
9cf66a
-		DEVICE=`list_mounts | grep " $(readlink -f "$MOUNTPOINT" ) " | cut -d' ' -f1`
9cf66a
+		DEVICE=`list_mounts | grep " $CANONICALIZED_MOUNTPOINT " | cut -d' ' -f1`
9cf66a
 		if [ -b "$DEVICE" ]; then
9cf66a
 			blockdevice=yes
9cf66a
 		fi
9cf66a
@@ -396,7 +396,7 @@ fstype_supported()
9cf66a
 Filesystem_start()
9cf66a
 {
9cf66a
 	# Check if there are any mounts mounted under the mountpoint
9cf66a
-	if list_mounts | grep -q -E " $(readlink -f "$MOUNTPOINT" )/\w+" >/dev/null 2>&1; then
9cf66a
+	if list_mounts | grep -q -E " $CANONICALIZED_MOUNTPOINT/\w+" >/dev/null 2>&1; then
9cf66a
 		ocf_log err "There is one or more mounts mounted under $MOUNTPOINT."
9cf66a
 		return $OCF_ERR_CONFIGURED
9cf66a
 	fi
9cf66a
@@ -580,7 +580,7 @@ Filesystem_stop()
9cf66a
 #
9cf66a
 Filesystem_status()
9cf66a
 {
9cf66a
-	if list_mounts | grep -q " $(readlink -f "$MOUNTPOINT" ) " >/dev/null 2>&1; then
9cf66a
+	if list_mounts | grep -q " $CANONICALIZED_MOUNTPOINT " >/dev/null 2>&1; then
9cf66a
 		rc=$OCF_SUCCESS
9cf66a
 		msg="$MOUNTPOINT is mounted (running)"
9cf66a
 	else
9cf66a
@@ -804,6 +804,11 @@ if [ -z "$OCF_RESKEY_directory" ]; then
9cf66a
 else
9cf66a
 	MOUNTPOINT=$(echo $OCF_RESKEY_directory | sed 's/\/*$//')
9cf66a
 	: ${MOUNTPOINT:=/}
9cf66a
+	CANONICALIZED_MOUNTPOINT=$(readlink -f "$MOUNTPOINT")
9cf66a
+	if [ $? -ne 0 ]; then
9cf66a
+		ocf_exit_reason "Could not canonicalize $MOUNTPOINT because readlink failed"
9cf66a
+		exit $OCF_ERR_GENERIC
9cf66a
+	fi
9cf66a
 	# At this stage, $MOUNTPOINT does not contain trailing "/" unless it is "/"
9cf66a
 	# TODO: / mounted via Filesystem sounds dangerous. On stop, we'll
9cf66a
 	# kill the whole system. Is that a good idea?