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

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