1 From 017157d21a56410811384a43d0b0cbba6444baeb Mon Sep 17 00:00:00 2001
2 From: Don Penney <don.penney@windriver.com>
3 Date: Wed, 6 Feb 2019 01:19:59 -0500
4 Subject: [PATCH] Check for mounted device before demoting Primary DRBD
7 Update the OCF script to check for a mounted device when demoting
8 a resource that's in the Primary state. The state change will fail
9 if it is still in use, otherwise.
11 Signed-off-by: Don Penney <don.penney@windriver.com>
13 scripts/drbd.ocf | 16 +++++++++++++++-
14 1 file changed, 15 insertions(+), 1 deletion(-)
16 diff --git a/scripts/drbd.ocf b/scripts/drbd.ocf
17 index e03bf6d..95da11a 100644
18 --- a/scripts/drbd.ocf
19 +++ b/scripts/drbd.ocf
20 @@ -720,7 +720,21 @@ drbd_stop() {
23 ocf_log warn "$DRBD_RESOURCE still Primary, demoting."
24 - do_drbdadm secondary $DRBD_RESOURCE
26 + for dev in ${DRBD_DEVICES[@]} ""; do
27 + cat /proc/mounts | grep -q "^${dev} "
28 + if [ $? -eq 0 ]; then
29 + ocf_log warn "${DRBD_RESOURCE} is still mounted via $dev"
34 + if [ "${found}" = "yes" ]; then
35 + ocf_log warn "Waiting to drop $DRBD_RESOURCE"
37 + ocf_log warn "Dropping $DRBD_RESOURCE to Secondary"
38 + do_drbdadm secondary $DRBD_RESOURCE