From d9cb2ead36e1338079da624e1b95e9621bfda1ef Mon Sep 17 00:00:00 2001 From: Laurent Barbe Date: Tue, 13 Aug 2013 17:16:35 +0200 Subject: [PATCH 1/2] init-rbdmap: fix for recursive umount Umount is not always done in the correct order. For exemple in that case : /dev/rbd1 on /myrbd /dev/rbd2 on /myrbd/.snapshots/@GMT-2013.08.09-10.14.44 rbd2 should be umounted before rbd1 Signed-off-by: Laurent Barbe --- src/init-rbdmap | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/init-rbdmap b/src/init-rbdmap index 6ea4af7624b..16d618a6c0d 100755 --- a/src/init-rbdmap +++ b/src/init-rbdmap @@ -62,14 +62,14 @@ do_map() { do_unmap() { log_daemon_msg "Stopping $DESC" RET=0 + # Recursive umount that depends /dev/rbd* + MNTDEP=$(findmnt --mtab | awk '$2 ~ /^\/dev\/rbd[0-9]*$/ {print $1}' | sort -r) + for MNT in $MNTDEP; do + umount $MNT + done # Unmap all rbd device for DEV in /dev/rbd[0-9]*; do log_progress_msg $DEV - # Umount before unmap - MNTDEP=$(findmnt --mtab --source $DEV --output TARGET | sed 1,1d | sort -r) - for MNT in $MNTDEP; do - umount $MNT || sleep 1 && umount -l $DEV - done rbd unmap $DEV [ $? -ne "0" ] && RET=1 done From 6df75da3d1bf8b11c5760a2d5a0b11b429e25b3f Mon Sep 17 00:00:00 2001 From: Laurent Barbe Date: Tue, 13 Aug 2013 17:45:03 +0200 Subject: [PATCH 2/2] init-rbdmap: minor fix no rbd exist Avoid error if stop when no rbd device exist Signed-off-by: Laurent Barbe --- src/init-rbdmap | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/init-rbdmap b/src/init-rbdmap index 16d618a6c0d..54554ae40d7 100755 --- a/src/init-rbdmap +++ b/src/init-rbdmap @@ -68,11 +68,13 @@ do_unmap() { umount $MNT done # Unmap all rbd device - for DEV in /dev/rbd[0-9]*; do - log_progress_msg $DEV - rbd unmap $DEV - [ $? -ne "0" ] && RET=1 - done + if [ -b /dev/rbd[0-9]* ]; then + for DEV in /dev/rbd[0-9]*; do + log_progress_msg $DEV + rbd unmap $DEV + [ $? -ne "0" ] && RET=1 + done + fi log_end_msg $RET }