From 63f43eb9749b9be9e07b7350e37993f47efb8e65 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Wed, 3 Dec 2014 13:06:43 -0500 Subject: [PATCH] devmapper: Rename NewTransactionId to OpenTransactionId Very soon we will have the notion of an open transaction and keep its details in a metafile. When a new transaction is opened, we allocate a new transaction Id, do the device creation/deletion and then we will close the transaction. I thought that OpenTransactionId better represents the semantics of transaction Id associated with an open transaction instead of NewtransactionId. This patch just does the renaming. No functionality change. I have also introduced a structure "Transaction" which will keep all the details associated with a transaction. Later patches will add more fields in this structure. Signed-off-by: Vivek Goyal Upstream-commit: f078bcd8e50913fd8b05022ebd047c5a1f2e3d52 Component: engine --- .../daemon/graphdriver/devmapper/deviceset.go | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/components/engine/daemon/graphdriver/devmapper/deviceset.go b/components/engine/daemon/graphdriver/devmapper/deviceset.go index 2660ade295..f132575355 100644 --- a/components/engine/daemon/graphdriver/devmapper/deviceset.go +++ b/components/engine/daemon/graphdriver/devmapper/deviceset.go @@ -35,6 +35,10 @@ var ( const deviceSetMetaFile string = "deviceset-metadata" +type Transaction struct { + OpenTransactionId uint64 `json:"-"` +} + type DevInfo struct { Hash string `json:"-"` DeviceId int `json:"device_id"` @@ -65,13 +69,12 @@ type MetaData struct { } type DeviceSet struct { - MetaData `json:"-"` - sync.Mutex `json:"-"` // Protects Devices map and serializes calls into libdevmapper - root string - devicePrefix string - TransactionId uint64 `json:"-"` - NewTransactionId uint64 `json:"-"` - NextDeviceId int `json:"next_device_id"` + MetaData `json:"-"` + sync.Mutex `json:"-"` // Protects Devices map and serializes calls into libdevmapper + root string + devicePrefix string + TransactionId uint64 `json:"-"` + NextDeviceId int `json:"next_device_id"` // Options dataLoopbackSize int64 @@ -85,6 +88,7 @@ type DeviceSet struct { doBlkDiscard bool thinpBlockSize uint32 thinPoolDevice string + Transaction `json:"-"` } type DiskUsage struct { @@ -200,15 +204,15 @@ func (devices *DeviceSet) ensureImage(name string, size int64) (string, error) { } func (devices *DeviceSet) allocateTransactionId() uint64 { - devices.NewTransactionId = devices.TransactionId + 1 - return devices.NewTransactionId + devices.OpenTransactionId = devices.TransactionId + 1 + return devices.OpenTransactionId } func (devices *DeviceSet) updatePoolTransactionId() error { - if err := devicemapper.SetTransactionId(devices.getPoolDevName(), devices.TransactionId, devices.NewTransactionId); err != nil { + if err := devicemapper.SetTransactionId(devices.getPoolDevName(), devices.TransactionId, devices.OpenTransactionId); err != nil { return fmt.Errorf("Error setting devmapper transaction ID: %s", err) } - devices.TransactionId = devices.NewTransactionId + devices.TransactionId = devices.OpenTransactionId return nil }