X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=meta-stx%2Frecipes-support%2Fdrbd%2Fdrbd-utils%2F0009-Check-for-mounted-device-before-demoting-Primary-DRB.patch;fp=meta-stx%2Frecipes-support%2Fdrbd%2Fdrbd-utils%2F0009-Check-for-mounted-device-before-demoting-Primary-DRB.patch;h=ac8f41417625aad6cbd921d82550de2134e19caa;hb=57fdea704bd62af847872c40508f00aa1d7cac60;hp=0000000000000000000000000000000000000000;hpb=f23f21bccfb750b9e30141fd9676515215ffbc4e;p=pti%2Frtp.git diff --git a/meta-stx/recipes-support/drbd/drbd-utils/0009-Check-for-mounted-device-before-demoting-Primary-DRB.patch b/meta-stx/recipes-support/drbd/drbd-utils/0009-Check-for-mounted-device-before-demoting-Primary-DRB.patch new file mode 100644 index 0000000..ac8f414 --- /dev/null +++ b/meta-stx/recipes-support/drbd/drbd-utils/0009-Check-for-mounted-device-before-demoting-Primary-DRB.patch @@ -0,0 +1,45 @@ +From 017157d21a56410811384a43d0b0cbba6444baeb Mon Sep 17 00:00:00 2001 +From: Don Penney +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 +--- + 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 +