Browse code

devmapper: Do not check for pool transaction id during old metadata migration

Current code is associating a transaction id with each device and if pool
transaction id is greater that value, then current code assumes that device
is there in pool.

Transaction id of pool is a mechanism so that during device creation and
removal one can define a transaction and during startup figure out if
transaction was complete or not. I think we are using transaction id
throughout the code little inappropriately.

For example, if a device is being deleted, it is possible that we deleted
the device from pool but before we could delete metafile docker crashed.
When docker comes back it will think that device is in the pool (due to
device transaction id being less than pool transaction id) but device
is not in the pool.

Similary, it could happen that some data in the pool is corrupted and
during pool repair some devices are lost (without docker knowing about
it). In that case tool pool transaction id will be higher than device
transaction id and there are no guaratees that device is actually in
the pool.

So move away from this model where we think that a device is in pool if pool
transaction id is greater than device transaction Id. Per device
transaction Id just says that after device creation this should be pool's
transaction Id and nothing more.

Transaction id is per pool property (as opposed to per device property) and
will be used internally to figure out if last transaction was complete or
not and recover from failure during docker startup.

If for some reason metafile is present but device is not in pool, then
device activation will fail later.

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

Vivek Goyal authored on 2014/12/04 03:06:43
Showing 1 changed files
... ...
@@ -367,11 +367,7 @@ func (devices *DeviceSet) initMetaData() error {
367 367
 
368 368
 		for hash, info := range m.Devices {
369 369
 			info.Hash = hash
370
-
371
-			// If the transaction id is larger than the actual one we lost the device due to some crash
372
-			if info.TransactionId <= devices.TransactionId {
373
-				devices.saveMetadata(info)
374
-			}
370
+			devices.saveMetadata(info)
375 371
 		}
376 372
 		if err := os.Rename(devices.oldMetadataFile(), devices.oldMetadataFile()+".migrated"); err != nil {
377 373
 			return err