]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbdmap: fix umount when multiple mounts use the same RBD 17998/head
authorAlexandre Marangone <a.marangone@gmail.com>
Tue, 26 Sep 2017 18:35:04 +0000 (11:35 -0700)
committerSage Weil <sage@redhat.com>
Wed, 27 Sep 2017 17:58:59 +0000 (13:58 -0400)
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 <amarango@redhat.com>
(cherry picked from commit 40825daecedb2a3481021e4d36a367c339eb9b62)

src/rbdmap

index 25de4648398d62aef955c92c3d60a88b26aff6d3..3b840aef94c7b2962a204d13703637c677ac5b35 100755 (executable)
@@ -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