From 7b0a1b814b8f13e30df466dd66c3fdc2114eac28 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Wed, 3 Dec 2014 13:06:43 -0500 Subject: [PATCH] devmapper: Allocate new transaction Id using current transaction Id Currently new transaction Id is created using allocateTransactionId() function. This function takes NewTransactionId and bumps up by one to create NewTransactionId. I think ideally we should be bumping up devices.TransactionId by 1 to come up with NewTransactionId. Because idea is that devices.TransactionId contains the current pool transaction Id and to come up with a new transaction Id bump it up by one. Current code is not wrong as we are keeping NewTransactionId and TransactionId in sync. But it will be more direct if we look at devices.TransactionId to come up with NewTransactionId. That way we don't have to even initialize NewTransactionId during startup as first time somebody wants to do a transaction, it will be allocated fresh. So simplify the code a bit. No functionality change. Signed-off-by: Vivek Goyal --- daemon/graphdriver/devmapper/deviceset.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/daemon/graphdriver/devmapper/deviceset.go b/daemon/graphdriver/devmapper/deviceset.go index 40fb4e2d4..2660ade29 100644 --- a/daemon/graphdriver/devmapper/deviceset.go +++ b/daemon/graphdriver/devmapper/deviceset.go @@ -200,7 +200,7 @@ func (devices *DeviceSet) ensureImage(name string, size int64) (string, error) { } func (devices *DeviceSet) allocateTransactionId() uint64 { - devices.NewTransactionId = devices.NewTransactionId + 1 + devices.NewTransactionId = devices.TransactionId + 1 return devices.NewTransactionId } @@ -398,7 +398,6 @@ func (devices *DeviceSet) initMetaData() error { } devices.TransactionId = transactionId - devices.NewTransactionId = devices.TransactionId return nil }