diff --git a/pkg/volume/iscsi/iscsi_util.go b/pkg/volume/iscsi/iscsi_util.go index ad6382f308f..d649e351729 100644 --- a/pkg/volume/iscsi/iscsi_util.go +++ b/pkg/volume/iscsi/iscsi_util.go @@ -396,25 +396,16 @@ func globalPDPathOperation(b iscsiDiskMounter) func(iscsiDiskMounter, string, *I // DetachDisk unmounts and detaches a volume from node func (util *ISCSIUtil) DetachDisk(c iscsiDiskUnmounter, mntPath string) error { - _, cnt, err := mount.GetDeviceNameFromMount(c.mounter, mntPath) - if err != nil { - glog.Errorf("iscsi detach disk: failed to get device from mnt: %s\nError: %v", mntPath, err) - return err - } if pathExists, pathErr := volumeutil.PathExists(mntPath); pathErr != nil { return fmt.Errorf("Error checking if path exists: %v", pathErr) } else if !pathExists { glog.Warningf("Warning: Unmount skipped because path does not exist: %v", mntPath) return nil } - if err = c.mounter.Unmount(mntPath); err != nil { + if err := c.mounter.Unmount(mntPath); err != nil { glog.Errorf("iscsi detach disk: failed to unmount: %s\nError: %v", mntPath, err) return err } - cnt-- - if cnt != 0 { - return nil - } // if device is no longer used, see if need to logout the target device, prefix, err := extractDeviceAndPrefix(mntPath) if err != nil { diff --git a/pkg/volume/rbd/attacher.go b/pkg/volume/rbd/attacher.go index 2e5960092e1..9a74a608c33 100644 --- a/pkg/volume/rbd/attacher.go +++ b/pkg/volume/rbd/attacher.go @@ -189,21 +189,17 @@ func (detacher *rbdDetacher) UnmountDevice(deviceMountPath string) error { glog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath) return nil } - devicePath, cnt, err := mount.GetDeviceNameFromMount(detacher.mounter, deviceMountPath) + devicePath, _, err := mount.GetDeviceNameFromMount(detacher.mounter, deviceMountPath) if err != nil { return err } - if cnt > 1 { - return fmt.Errorf("rbd: more than 1 reference counts at %s", deviceMountPath) - } - if cnt == 1 { - // Unmount the device from the device mount point. - glog.V(4).Infof("rbd: unmouting device mountpoint %s", deviceMountPath) - if err = detacher.mounter.Unmount(deviceMountPath); err != nil { - return err - } - glog.V(3).Infof("rbd: successfully umount device mountpath %s", deviceMountPath) + // Unmount the device from the device mount point. + glog.V(4).Infof("rbd: unmouting device mountpoint %s", deviceMountPath) + if err = detacher.mounter.Unmount(deviceMountPath); err != nil { + return err } + glog.V(3).Infof("rbd: successfully umount device mountpath %s", deviceMountPath) + glog.V(4).Infof("rbd: detaching device %s", devicePath) err = detacher.manager.DetachDisk(detacher.plugin, deviceMountPath, devicePath) if err != nil {