Browse code

Mark device ID free only if device actually got deleted

Right now if somebody has enabled deferred device deletion, then
deleteTransaction() returns success even if device could not be deleted. It
has been marked for deferred deletion. Right now we will mark device ID free
and potentially use it again when somebody tries to create new container. And
that's wrong. Device ID is not free yet. It will become free once devices
has actually been deleted by the goroutine later.

So move the location of call to markDeviceIDFree() to a place where we know
device actually got deleted and was not marked for deferred deletion.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>

Vivek Goyal authored on 2016/01/12 03:57:37
Showing 1 changed files
... ...
@@ -1801,6 +1801,7 @@ func (devices *DeviceSet) deleteTransaction(info *devInfo, syncDelete bool) erro
1801 1801
 		if info.Deleted {
1802 1802
 			devices.nrDeletedDevices--
1803 1803
 		}
1804
+		devices.markDeviceIDFree(info.DeviceID)
1804 1805
 	} else {
1805 1806
 		if err := devices.markForDeferredDeletion(info); err != nil {
1806 1807
 			return err
... ...
@@ -1855,8 +1856,6 @@ func (devices *DeviceSet) deleteDevice(info *devInfo, syncDelete bool) error {
1855 1855
 		return err
1856 1856
 	}
1857 1857
 
1858
-	devices.markDeviceIDFree(info.DeviceID)
1859
-
1860 1858
 	return nil
1861 1859
 }
1862 1860