diff --git a/components/engine/daemon/graphdriver/devmapper/deviceset.go b/components/engine/daemon/graphdriver/devmapper/deviceset.go index b079064029..e96127a000 100644 --- a/components/engine/daemon/graphdriver/devmapper/deviceset.go +++ b/components/engine/daemon/graphdriver/devmapper/deviceset.go @@ -388,6 +388,11 @@ func (devices *DeviceSet) deviceFileWalkFunction(path string, finfo os.FileInfo) return nil } + if finfo.Name() == transactionMetaFile { + logrus.Debugf("Skipping file %s", path) + return nil + } + logrus.Debugf("Loading data for file %s", path) hash := finfo.Name() @@ -1516,6 +1521,13 @@ func (devices *DeviceSet) DeleteDevice(hash string) error { devices.Lock() defer devices.Unlock() + // If mountcount is not zero, that means devices is still in use + // or has not been Put() properly. Fail device deletion. + + if info.mountCount != 0 { + return fmt.Errorf("devmapper: Can't delete device %v as it is still mounted. mntCount=%v", info.Hash, info.mountCount) + } + return devices.deleteDevice(info) } @@ -1781,7 +1793,7 @@ func (devices *DeviceSet) UnmountDevice(hash string) error { return nil } -// HasDevice returns true if the device is in the hash and mounted. +// HasDevice returns true if the device metadata exists. func (devices *DeviceSet) HasDevice(hash string) bool { devices.Lock() defer devices.Unlock() diff --git a/components/engine/daemon/graphdriver/devmapper/driver.go b/components/engine/daemon/graphdriver/devmapper/driver.go index 67657f65e7..dc2647d11d 100644 --- a/components/engine/daemon/graphdriver/devmapper/driver.go +++ b/components/engine/daemon/graphdriver/devmapper/driver.go @@ -196,7 +196,7 @@ func (d *Driver) Put(id string) error { return err } -// Exists checks to see if the device is mounted. +// Exists checks to see if the device exists. func (d *Driver) Exists(id string) bool { return d.DeviceSet.HasDevice(id) }