浏览代码

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 10 年之前
父节点
当前提交
7b0a1b814b
共有 1 个文件被更改,包括 1 次插入2 次删除
  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 {
 func (devices *DeviceSet) allocateTransactionId() uint64 {
-	devices.NewTransactionId = devices.NewTransactionId + 1
+	devices.NewTransactionId = devices.TransactionId + 1
 	return devices.NewTransactionId
 	return devices.NewTransactionId
 }
 }
 
 
@@ -398,7 +398,6 @@ func (devices *DeviceSet) initMetaData() error {
 	}
 	}
 
 
 	devices.TransactionId = transactionId
 	devices.TransactionId = transactionId
-	devices.NewTransactionId = devices.TransactionId
 	return nil
 	return nil
 }
 }