--- /dev/null
+From 017157d21a56410811384a43d0b0cbba6444baeb Mon Sep 17 00:00:00 2001
+From: Don Penney <don.penney@windriver.com>
+Date: Wed, 6 Feb 2019 01:19:59 -0500
+Subject: [PATCH] Check for mounted device before demoting Primary DRBD
+ resource
+
+Update the OCF script to check for a mounted device when demoting
+a resource that's in the Primary state. The state change will fail
+if it is still in use, otherwise.
+
+Signed-off-by: Don Penney <don.penney@windriver.com>
+---
+ scripts/drbd.ocf | 16 +++++++++++++++-
+ 1 file changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/scripts/drbd.ocf b/scripts/drbd.ocf
+index e03bf6d..95da11a 100644
+--- a/scripts/drbd.ocf
++++ b/scripts/drbd.ocf
+@@ -720,7 +720,21 @@ drbd_stop() {
+ ;;
+ $OCF_RUNNING_MASTER)
+ ocf_log warn "$DRBD_RESOURCE still Primary, demoting."
+- do_drbdadm secondary $DRBD_RESOURCE
++ found=no
++ for dev in ${DRBD_DEVICES[@]} ""; do
++ cat /proc/mounts | grep -q "^${dev} "
++ if [ $? -eq 0 ]; then
++ ocf_log warn "${DRBD_RESOURCE} is still mounted via $dev"
++ found=yes
++ break
++ fi
++ done
++ if [ "${found}" = "yes" ]; then
++ ocf_log warn "Waiting to drop $DRBD_RESOURCE"
++ else
++ ocf_log warn "Dropping $DRBD_RESOURCE to Secondary"
++ do_drbdadm secondary $DRBD_RESOURCE
++ fi
+ esac
+ $first_try || sleep 1
+ first_try=false
+--
+1.8.3.1
+