From 94caae2477f42b55adeab22f14bcef22b90373d6 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Wed, 30 Sep 2015 18:54:06 -0400 Subject: [PATCH] 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 --- daemon/graphdriver/devmapper/deviceset.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/daemon/graphdriver/devmapper/deviceset.go b/daemon/graphdriver/devmapper/deviceset.go index 407eef9f87..e7a330d6e9 100644 --- a/daemon/graphdriver/devmapper/deviceset.go +++ b/daemon/graphdriver/devmapper/deviceset.go @@ -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 }