1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

devmapper: Pass info rather than hash to deleteDevice

All the callers already have the info, no need for an extra lookup.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
This commit is contained in:
Alexander Larsson 2014-04-01 10:24:26 +02:00
parent e5394e35c7
commit 8e39b35c7c

View file

@ -313,7 +313,7 @@ func (devices *DeviceSet) setupBaseImage() error {
if oldInfo != nil && !oldInfo.Initialized {
utils.Debugf("Removing uninitialized base image")
if err := devices.deleteDevice(""); err != nil {
if err := devices.deleteDevice(oldInfo); err != nil {
utils.Debugf("\n--->Err: %s\n", err)
return err
}
@ -592,12 +592,7 @@ func (devices *DeviceSet) AddDevice(hash, baseHash string) error {
return nil
}
func (devices *DeviceSet) deleteDevice(hash string) error {
info := devices.Devices[hash]
if info == nil {
return fmt.Errorf("hash %s doesn't exists", hash)
}
func (devices *DeviceSet) deleteDevice(info *DevInfo) error {
// This is a workaround for the kernel not discarding block so
// on the thin pool when we remove a thinp device, so we do it
// manually
@ -652,7 +647,7 @@ func (devices *DeviceSet) DeleteDevice(hash string) error {
info.lock.Lock()
defer info.lock.Unlock()
return devices.deleteDevice(hash)
return devices.deleteDevice(info)
}
func (devices *DeviceSet) deactivatePool() error {