Procházet zdrojové kódy

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 <vgoyal@redhat.com>
Vivek Goyal před 10 roky
rodič
revize
7b0a1b814b
1 změnil soubory, kde provedl 1 přidání a 2 odebrání
  1. 1 2
      daemon/graphdriver/devmapper/deviceset.go

+ 1 - 2
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
 }