devmapper: Use transactions during device deletion
Use transaction logic during device deletion and do rollback if transaction is not complete. Following is the sequence of events. - Open transaction and save to metafile - Delete device from pool - Delete device metadata file from disk - Close Transaction If docker crashes without closing transaction then rollback will take place upon next docker start. Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
parent
c115c4aa45
commit
17b75a21a6
1 changed files with 9 additions and 0 deletions
|
@ -1128,6 +1128,11 @@ func (devices *DeviceSet) deleteDevice(info *DevInfo) error {
|
|||
}
|
||||
}
|
||||
|
||||
if err := devices.openTransaction(info.Hash, info.DeviceId); err != nil {
|
||||
log.Debugf("Error opening transaction hash = %s deviceId = %d", "", info.DeviceId)
|
||||
return err
|
||||
}
|
||||
|
||||
if err := devicemapper.DeleteDevice(devices.getPoolDevName(), info.DeviceId); err != nil {
|
||||
log.Debugf("Error deleting device: %s", err)
|
||||
return err
|
||||
|
@ -1137,6 +1142,10 @@ func (devices *DeviceSet) deleteDevice(info *DevInfo) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := devices.closeTransaction(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
devices.markDeviceIdFree(info.DeviceId)
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue