Fix panic on devicemapper initialization

The ability to save and verify base device UUID (#13896) introduced a
situation where the initialization would panic when removing the device
returns EBUSY.

Functions `verifyBaseDeviceUUID` and `saveBaseDeviceUUID` now take the
lock on the `DeviceSet`, which solves the problem as `removeDevice`
assumes it owns the lock.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
This commit is contained in:
Arnaud Porterie 2015-07-08 09:05:37 -07:00
parent 2fe51ecee7
commit f089899023
1 changed files with 6 additions and 0 deletions

View File

@ -691,6 +691,9 @@ func getDeviceUUID(device string) (string, error) {
}
func (devices *DeviceSet) verifyBaseDeviceUUID(baseInfo *DevInfo) error {
devices.Lock()
defer devices.Unlock()
if err := devices.activateDeviceIfNeeded(baseInfo); err != nil {
return err
}
@ -710,6 +713,9 @@ func (devices *DeviceSet) verifyBaseDeviceUUID(baseInfo *DevInfo) error {
}
func (devices *DeviceSet) saveBaseDeviceUUID(baseInfo *DevInfo) error {
devices.Lock()
defer devices.Unlock()
if err := devices.activateDeviceIfNeeded(baseInfo); err != nil {
return err
}