Browse code

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>

Vivek Goyal authored on 2014/12/04 03:06:43
Showing 1 changed files
... ...
@@ -35,6 +35,10 @@ var (
35 35
 
36 36
 const deviceSetMetaFile string = "deviceset-metadata"
37 37
 
38
+type Transaction struct {
39
+	OpenTransactionId uint64 `json:"-"`
40
+}
41
+
38 42
 type DevInfo struct {
39 43
 	Hash          string     `json:"-"`
40 44
 	DeviceId      int        `json:"device_id"`
... ...
@@ -65,13 +69,12 @@ type MetaData struct {
65 65
 }
66 66
 
67 67
 type DeviceSet struct {
68
-	MetaData         `json:"-"`
69
-	sync.Mutex       `json:"-"` // Protects Devices map and serializes calls into libdevmapper
70
-	root             string
71
-	devicePrefix     string
72
-	TransactionId    uint64 `json:"-"`
73
-	NewTransactionId uint64 `json:"-"`
74
-	NextDeviceId     int    `json:"next_device_id"`
68
+	MetaData      `json:"-"`
69
+	sync.Mutex    `json:"-"` // Protects Devices map and serializes calls into libdevmapper
70
+	root          string
71
+	devicePrefix  string
72
+	TransactionId uint64 `json:"-"`
73
+	NextDeviceId  int    `json:"next_device_id"`
75 74
 
76 75
 	// Options
77 76
 	dataLoopbackSize     int64
... ...
@@ -85,6 +88,7 @@ type DeviceSet struct {
85 85
 	doBlkDiscard         bool
86 86
 	thinpBlockSize       uint32
87 87
 	thinPoolDevice       string
88
+	Transaction          `json:"-"`
88 89
 }
89 90
 
90 91
 type DiskUsage struct {
... ...
@@ -200,15 +204,15 @@ func (devices *DeviceSet) ensureImage(name string, size int64) (string, error) {
200 200
 }
201 201
 
202 202
 func (devices *DeviceSet) allocateTransactionId() uint64 {
203
-	devices.NewTransactionId = devices.TransactionId + 1
204
-	return devices.NewTransactionId
203
+	devices.OpenTransactionId = devices.TransactionId + 1
204
+	return devices.OpenTransactionId
205 205
 }
206 206
 
207 207
 func (devices *DeviceSet) updatePoolTransactionId() error {
208
-	if err := devicemapper.SetTransactionId(devices.getPoolDevName(), devices.TransactionId, devices.NewTransactionId); err != nil {
208
+	if err := devicemapper.SetTransactionId(devices.getPoolDevName(), devices.TransactionId, devices.OpenTransactionId); err != nil {
209 209
 		return fmt.Errorf("Error setting devmapper transaction ID: %s", err)
210 210
 	}
211
-	devices.TransactionId = devices.NewTransactionId
211
+	devices.TransactionId = devices.OpenTransactionId
212 212
 	return nil
213 213
 }
214 214