From: Alexandre Marangone Date: Tue, 26 Sep 2017 18:35:04 +0000 (-0700) Subject: rbdmap: fix umount when multiple mounts use the same RBD X-Git-Tag: ses5-gm~5^2~4^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F17998%2Fhead;p=ceph.git rbdmap: fix umount when multiple mounts use the same RBD When a Kubernetes Pod consumes a RBD it is mounted two times on the same host. When the host shutdown umount will fail leading to a hung system Signed-off-by: Alexandre Marangone (cherry picked from commit 40825daecedb2a3481021e4d36a367c339eb9b62) --- diff --git a/src/rbdmap b/src/rbdmap index 25de4648398d..3b840aef94c7 100755 --- a/src/rbdmap +++ b/src/rbdmap @@ -58,19 +58,19 @@ do_map() { unmount_unmap() { local rbd_dev=$1 - local mnt=$(findmnt --mtab --source ${rbd_dev} --noheadings \ + local mnts=$(findmnt --mtab --source ${rbd_dev} --noheadings \ | awk '{print $1'}) logger -p "daemon.debug" -t rbdmap "Unmapping '${rbd_dev}'" - if [ -n "${mnt}" ]; then + for mnt in ${mnts}; do logger -p "daemon.debug" -t rbdmap "Unmounting '${mnt}'" umount "${mnt}" >>/dev/null 2>&1 - fi - if mountpoint -q "${mnt}"; then - ## Un-mounting failed. - logger -p "daemon.warning" -t rbdmap "Failed to unmount '${mnt}'" - return 1 - fi + if mountpoint -q "${mnt}"; then + ## Un-mounting failed. + logger -p "daemon.warning" -t rbdmap "Failed to unmount '${mnt}'" + return 1 + fi + done ## Un-mapping. rbd unmap $rbd_dev >>/dev/null 2>&1 if [ $? -ne 0 ]; then