mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
devmapper: Move thin pool related checks in a function
Move thin pool related checks in a separate function. Pure code reorganization. Makes reading code easier. Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
parent
efc1ddd7e3
commit
69051ec0a5
1 changed files with 17 additions and 10 deletions
|
@ -809,6 +809,22 @@ func (devices *DeviceSet) createBaseImage() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (devices *DeviceSet) checkThinPool() error {
|
||||||
|
_, transactionID, dataUsed, _, _, _, err := devices.poolStatus()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if dataUsed != 0 {
|
||||||
|
return fmt.Errorf("Unable to take ownership of thin-pool (%s) that already has used data blocks",
|
||||||
|
devices.thinPoolDevice)
|
||||||
|
}
|
||||||
|
if transactionID != 0 {
|
||||||
|
return fmt.Errorf("Unable to take ownership of thin-pool (%s) with non-zero transaction ID",
|
||||||
|
devices.thinPoolDevice)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (devices *DeviceSet) setupBaseImage() error {
|
func (devices *DeviceSet) setupBaseImage() error {
|
||||||
oldInfo, _ := devices.lookupDeviceWithLock("")
|
oldInfo, _ := devices.lookupDeviceWithLock("")
|
||||||
if oldInfo != nil && oldInfo.Initialized {
|
if oldInfo != nil && oldInfo.Initialized {
|
||||||
|
@ -835,18 +851,9 @@ func (devices *DeviceSet) setupBaseImage() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if devices.thinPoolDevice != "" && oldInfo == nil {
|
if devices.thinPoolDevice != "" && oldInfo == nil {
|
||||||
_, transactionID, dataUsed, _, _, _, err := devices.poolStatus()
|
if err := devices.checkThinPool(); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if dataUsed != 0 {
|
|
||||||
return fmt.Errorf("Unable to take ownership of thin-pool (%s) that already has used data blocks",
|
|
||||||
devices.thinPoolDevice)
|
|
||||||
}
|
|
||||||
if transactionID != 0 {
|
|
||||||
return fmt.Errorf("Unable to take ownership of thin-pool (%s) with non-zero transaction ID",
|
|
||||||
devices.thinPoolDevice)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new base image device
|
// Create new base image device
|
||||||
|
|
Loading…
Add table
Reference in a new issue