]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbdmap: fix umount when multiple mounts use the same RBD 17978/head
authorAlexandre Marangone <a.marangone@gmail.com>
Tue, 26 Sep 2017 18:35:04 +0000 (11:35 -0700)
committerAlexandre Marangone <amarango@redhat.com>
Tue, 26 Sep 2017 23:19:25 +0000 (16:19 -0700)
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>
src/rbdmap

index ea7d8653ae0d1196e6c75d41ccc8bb0085c73c5d..f4503ab9d60247bf75bd3616e98dccce5c7690a6 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