]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-nbd: script that can be hooked to quiesce/unquiesce events
authorMykola Golub <mgolub@suse.com>
Mon, 27 Apr 2020 08:04:33 +0000 (09:04 +0100)
committerMykola Golub <mgolub@suse.com>
Sat, 9 May 2020 11:37:36 +0000 (12:37 +0100)
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/tools/rbd_nbd/rbd-nbd_quiesce [new file with mode: 0755]

diff --git a/src/tools/rbd_nbd/rbd-nbd_quiesce b/src/tools/rbd_nbd/rbd-nbd_quiesce
new file mode 100755 (executable)
index 0000000..a62a12b
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+echo "$0 $@" >&2
+
+if [ $# -lt 2 ]; then
+    echo "usage: $0 <dev> <cmd>" >&2
+    exit 1
+fi
+
+dev=$1
+cmd=$2
+
+export PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
+findmnt -S "${dev}" -fno TARGET |
+while read mnt; do
+    case "${cmd}" in
+        quiesce)
+            echo "freezing ${mnt}" >&2
+            fsfreeze -f "${mnt}"
+            ;;
+        unquiesce)
+            echo "unfreezing ${mnt}" >&2
+            fsfreeze -u "${mnt}"
+            ;;
+        *)
+            echo "unknown command ${cmd}" >&2
+            exit 1
+            ;;
+    esac
+done