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 <vgoyal@redhat.com>
This commit is contained in:
Vivek Goyal 2014-12-03 13:06:43 -05:00 committed by root
parent 7b0a1b814b
commit f078bcd8e5

View file

@ -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"`
@ -70,7 +74,6 @@ type DeviceSet struct {
root string
devicePrefix string
TransactionId uint64 `json:"-"`
NewTransactionId uint64 `json:"-"`
NextDeviceId int `json:"next_device_id"`
// Options
@ -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
}