From: Ilya Dryomov Date: Tue, 1 Apr 2014 06:18:23 +0000 (+0400) Subject: stop.sh: unmap rbd images when stopping the whole cluster X-Git-Tag: v0.79~18^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8e46fe00faaa3309d9be663f0cd23a1a3ccea3d5;p=ceph.git stop.sh: unmap rbd images when stopping the whole cluster Unmap rbd images when stopping the whole cluster. Not doing so results in images that cannot be unmapped until the same cluster is brought back up. Issue a warning if we failed to unmap all images. Signed-off-by: Ilya Dryomov --- diff --git a/src/stop.sh b/src/stop.sh index 9a5b8d2cc8d5a..d7ce234c1fc57 100755 --- a/src/stop.sh +++ b/src/stop.sh @@ -18,6 +18,8 @@ test -d dev/osd0/. && test -e dev/sudo && SUDO="sudo" +[ -z "$CEPH_BIN" ] && CEPH_BIN=. + do_killall() { pg=`pgrep -f ceph-run.*$1` [ -n "$pg" ] && kill $pg @@ -57,6 +59,20 @@ while [ $# -ge 1 ]; do done if [ $stop_all -eq 1 ]; then + while read DEV; do + # While it is currently possible to create an rbd image with + # whitespace chars in its name, krbd will refuse mapping such + # an image, so we can safely split on whitespace here. (The + # same goes for whitespace chars in names of the pools that + # contain rbd images). + DEV="$(echo "${DEV}" | tr -s '[:space:]' | awk '{ print $5 }')" + sudo "${CEPH_BIN}"/rbd unmap "${DEV}" + done < <("${CEPH_BIN}"/rbd showmapped | tail -n +2) + + if [ -n "$("${CEPH_BIN}"/rbd showmapped)" ]; then + echo "WARNING: Some rbd images are still mapped!" >&2 + fi + for p in ceph-mon ceph-mds ceph-osd radosgw lt-radosgw apache2 ; do for try in 0 1 1 1 1 ; do if ! pkill $p ; then @@ -65,6 +81,7 @@ if [ $stop_all -eq 1 ]; then sleep $try done done + pkill -f valgrind.bin.\*ceph-mon $SUDO pkill -f valgrind.bin.\*ceph-osd pkill -f valgrind.bin.\*ceph-mds