浏览代码

devmapper: Remove call to waitClose()

During device removal, we are first waiting for device to close() in a tight
loop for 10 seconds. I am not sure why do we need it. First of all we come
here once the umount() is successful so device should be free. For some reason
of device is temporarily busy, then removeDevice() logic retries device removal
logic in a loop for 10 seconds and that should cover it. Can't see why one
more 10 seoncds loop is required before attempting device removal.

One loop should be able to cover all the temporary device busy conditions and
if condition is not temporary then 10 seconds loop is not going to help anyway.

So instead of two loops of 10 seconds each, I am converting it to a single
loop of 20 seconds. May be 10 second loop is good enough but for now I am
keeping it 20 seconds to avoid any regressions.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Vivek Goyal 10 年之前
父节点
当前提交
f74d12012c
共有 1 个文件被更改,包括 1 次插入33 次删除
  1. 1 33
      daemon/graphdriver/devmapper/deviceset.go

+ 1 - 33
daemon/graphdriver/devmapper/deviceset.go

@@ -1225,12 +1225,6 @@ func (devices *DeviceSet) deactivateDevice(info *DevInfo) error {
 	logrus.Debugf("[devmapper] deactivateDevice(%s)", info.Hash)
 	defer logrus.Debugf("[devmapper] deactivateDevice END(%s)", info.Hash)
 
-	// Wait for the unmount to be effective,
-	// by watching the value of Info.OpenCount for the device
-	if err := devices.waitClose(info); err != nil {
-		logrus.Errorf("Error waiting for device %s to close: %s", info.Hash, err)
-	}
-
 	devinfo, err := devicemapper.GetInfo(info.Name())
 	if err != nil {
 		return err
@@ -1251,7 +1245,7 @@ func (devices *DeviceSet) removeDevice(devname string) error {
 	logrus.Debugf("[devmapper] removeDevice START(%s)", devname)
 	defer logrus.Debugf("[devmapper] removeDevice END(%s)", devname)
 
-	for i := 0; i < 1000; i++ {
+	for i := 0; i < 2000; i++ {
 		err = devicemapper.RemoveDevice(devname)
 		if err == nil {
 			break
@@ -1270,32 +1264,6 @@ func (devices *DeviceSet) removeDevice(devname string) error {
 	return err
 }
 
-// waitClose blocks until either:
-// a) the device registered at <device_set_prefix>-<hash> is closed,
-// or b) the 10 second timeout expires.
-func (devices *DeviceSet) waitClose(info *DevInfo) error {
-	i := 0
-	for ; i < 1000; i++ {
-		devinfo, err := devicemapper.GetInfo(info.Name())
-		if err != nil {
-			return err
-		}
-		if i%100 == 0 {
-			logrus.Debugf("Waiting for unmount of %s: opencount=%d", info.Hash, devinfo.OpenCount)
-		}
-		if devinfo.OpenCount == 0 {
-			break
-		}
-		devices.Unlock()
-		time.Sleep(10 * time.Millisecond)
-		devices.Lock()
-	}
-	if i == 1000 {
-		return fmt.Errorf("Timeout while waiting for device %s to close", info.Hash)
-	}
-	return nil
-}
-
 func (devices *DeviceSet) Shutdown() error {
 	logrus.Debugf("[deviceset %s] Shutdown()", devices.devicePrefix)
 	logrus.Debugf("[devmapper] Shutting down DeviceSet: %s", devices.root)