1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

devmapper: Move pool id query and migration of old data in separate function

Right now initMetaData() first queries the pool for current transaciton Id
and then it migrates the old metafile.

Move pool transaction Id query and file migration in separate functions
for better code reuse and organization.

Given we have removed device transaction Id dependency from saveMetaData(),
we don't have to query pool transaction Id before migrating files.
 
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 0db6cc85ed
commit 824a87f7ef

View file

@ -352,19 +352,8 @@ func (devices *DeviceSet) createFilesystem(info *DevInfo) error {
return nil return nil
} }
func (devices *DeviceSet) initMetaData() error { func (devices *DeviceSet) migrateOldMetaData() error {
_, _, _, params, err := devicemapper.GetStatus(devices.getPoolName())
if err != nil {
return err
}
if _, err := fmt.Sscanf(params, "%d", &devices.TransactionId); err != nil {
return err
}
devices.NewTransactionId = devices.TransactionId
// Migrate old metadatafile // Migrate old metadatafile
jsonData, err := ioutil.ReadFile(devices.oldMetadataFile()) jsonData, err := ioutil.ReadFile(devices.oldMetadataFile())
if err != nil && !os.IsNotExist(err) { if err != nil && !os.IsNotExist(err) {
return err return err
@ -390,6 +379,21 @@ func (devices *DeviceSet) initMetaData() error {
return nil return nil
} }
func (devices *DeviceSet) initMetaData() error {
if err := devices.migrateOldMetaData(); err != nil {
return err
}
_, transactionId, _, _, _, _, err := devices.poolStatus()
if err != nil {
return err
}
devices.TransactionId = transactionId
devices.NewTransactionId = devices.TransactionId
return nil
}
func (devices *DeviceSet) loadMetadata(hash string) *DevInfo { func (devices *DeviceSet) loadMetadata(hash string) *DevInfo {
info := &DevInfo{Hash: hash, devices: devices} info := &DevInfo{Hash: hash, devices: devices}