Merge pull request #16683 from rhvgoyal/fix-couple-of-bugs

devmapper: Fix a bug and fix a comment and add one reliability check
This commit is contained in:
David Calavera 2015-09-30 15:17:29 -07:00
commit 8ebd0c972a
2 changed files with 14 additions and 2 deletions

View file

@ -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()

View file

@ -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)
}