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

devmapper: Move maxDeviceID check in loadMetadata

maxDeviceID is upper limit on device Id thin pool can support. Right now
we have this check only during startup. It is a good idea to move this
check in loadMetadata so that any time a device file is loaded and if it
is corrupted and device Id is more than maxDevieceID, it will be detected
right then and there.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
Vivek Goyal 2015-09-30 18:54:06 -04:00
parent 39081eb3aa
commit 94caae2477

View file

@ -405,11 +405,6 @@ func (devices *DeviceSet) deviceFileWalkFunction(path string, finfo os.FileInfo)
return fmt.Errorf("Error loading device metadata file %s", hash)
}
if dinfo.DeviceID > maxDeviceID {
logrus.Errorf("Ignoring Invalid DeviceID=%d", dinfo.DeviceID)
return nil
}
devices.Lock()
devices.markDeviceIDUsed(dinfo.DeviceID)
devices.Unlock()
@ -715,6 +710,11 @@ func (devices *DeviceSet) loadMetadata(hash string) *devInfo {
return nil
}
if info.DeviceID > maxDeviceID {
logrus.Errorf("Ignoring Invalid DeviceId=%d", info.DeviceID)
return nil
}
return info
}