mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #8232 from vbatts/vbatts-devmapper_getDeps
devmapper: include dm_deps information in debug
This commit is contained in:
commit
2f9ffe5b6a
4 changed files with 49 additions and 4 deletions
|
@ -771,10 +771,15 @@ func (devices *DeviceSet) deactivatePool() error {
|
||||||
log.Debugf("[devmapper] deactivatePool()")
|
log.Debugf("[devmapper] deactivatePool()")
|
||||||
defer log.Debugf("[devmapper] deactivatePool END")
|
defer log.Debugf("[devmapper] deactivatePool END")
|
||||||
devname := devices.getPoolDevName()
|
devname := devices.getPoolDevName()
|
||||||
|
|
||||||
devinfo, err := getInfo(devname)
|
devinfo, err := getInfo(devname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if d, err := getDeps(devname); err == nil {
|
||||||
|
// Access to more Debug output
|
||||||
|
log.Debugf("[devmapper] getDeps() %s: %#v", devname, d)
|
||||||
|
}
|
||||||
if devinfo.Exists != 0 {
|
if devinfo.Exists != 0 {
|
||||||
return removeDevice(devname)
|
return removeDevice(devname)
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ var (
|
||||||
ErrTaskSetRo = errors.New("dm_task_set_ro failed")
|
ErrTaskSetRo = errors.New("dm_task_set_ro failed")
|
||||||
ErrTaskAddTarget = errors.New("dm_task_add_target failed")
|
ErrTaskAddTarget = errors.New("dm_task_add_target failed")
|
||||||
ErrTaskSetSector = errors.New("dm_task_set_sector failed")
|
ErrTaskSetSector = errors.New("dm_task_set_sector failed")
|
||||||
|
ErrTaskGetDeps = errors.New("dm_task_get_deps failed")
|
||||||
ErrTaskGetInfo = errors.New("dm_task_get_info failed")
|
ErrTaskGetInfo = errors.New("dm_task_get_info failed")
|
||||||
ErrTaskGetDriverVersion = errors.New("dm_task_get_driver_version failed")
|
ErrTaskGetDriverVersion = errors.New("dm_task_get_driver_version failed")
|
||||||
ErrTaskSetCookie = errors.New("dm_task_set_cookie failed")
|
ErrTaskSetCookie = errors.New("dm_task_set_cookie failed")
|
||||||
|
@ -75,6 +76,11 @@ type (
|
||||||
Task struct {
|
Task struct {
|
||||||
unmanaged *CDmTask
|
unmanaged *CDmTask
|
||||||
}
|
}
|
||||||
|
Deps struct {
|
||||||
|
Count uint32
|
||||||
|
Filler uint32
|
||||||
|
Device []uint64
|
||||||
|
}
|
||||||
Info struct {
|
Info struct {
|
||||||
Exists int
|
Exists int
|
||||||
Suspended int
|
Suspended int
|
||||||
|
@ -171,6 +177,14 @@ func (t *Task) AddTarget(start, size uint64, ttype, params string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Task) GetDeps() (*Deps, error) {
|
||||||
|
var deps *Deps
|
||||||
|
if deps = DmTaskGetDeps(t.unmanaged); deps == nil {
|
||||||
|
return nil, ErrTaskGetDeps
|
||||||
|
}
|
||||||
|
return deps, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Task) GetInfo() (*Info, error) {
|
func (t *Task) GetInfo() (*Info, error) {
|
||||||
info := &Info{}
|
info := &Info{}
|
||||||
if res := DmTaskGetInfo(t.unmanaged, info); res != 1 {
|
if res := DmTaskGetInfo(t.unmanaged, info); res != 1 {
|
||||||
|
@ -392,6 +406,17 @@ func createTask(t TaskType, name string) (*Task, error) {
|
||||||
return task, nil
|
return task, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getDeps(name string) (*Deps, error) {
|
||||||
|
task, err := createTask(DeviceDeps, name)
|
||||||
|
if task == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := task.Run(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return task.GetDeps()
|
||||||
|
}
|
||||||
|
|
||||||
func getInfo(name string) (*Info, error) {
|
func getInfo(name string) (*Info, error) {
|
||||||
task, err := createTask(DeviceInfo, name)
|
task, err := createTask(DeviceInfo, name)
|
||||||
if task == nil {
|
if task == nil {
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
package devmapper
|
package devmapper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/docker/docker/daemon/graphdriver/graphtest"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/docker/docker/daemon/graphdriver/graphtest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -38,9 +38,7 @@ static void log_with_errno_init()
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import "unsafe"
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
type (
|
||||||
CDmTask C.struct_dm_task
|
CDmTask C.struct_dm_task
|
||||||
|
@ -92,6 +90,7 @@ var (
|
||||||
DmTaskAddTarget = dmTaskAddTargetFct
|
DmTaskAddTarget = dmTaskAddTargetFct
|
||||||
DmTaskCreate = dmTaskCreateFct
|
DmTaskCreate = dmTaskCreateFct
|
||||||
DmTaskDestroy = dmTaskDestroyFct
|
DmTaskDestroy = dmTaskDestroyFct
|
||||||
|
DmTaskGetDeps = dmTaskGetDepsFct
|
||||||
DmTaskGetInfo = dmTaskGetInfoFct
|
DmTaskGetInfo = dmTaskGetInfoFct
|
||||||
DmTaskGetDriverVersion = dmTaskGetDriverVersionFct
|
DmTaskGetDriverVersion = dmTaskGetDriverVersionFct
|
||||||
DmTaskRun = dmTaskRunFct
|
DmTaskRun = dmTaskRunFct
|
||||||
|
@ -168,6 +167,21 @@ func dmTaskAddTargetFct(task *CDmTask,
|
||||||
return int(C.dm_task_add_target((*C.struct_dm_task)(task), C.uint64_t(start), C.uint64_t(size), Cttype, Cparams))
|
return int(C.dm_task_add_target((*C.struct_dm_task)(task), C.uint64_t(start), C.uint64_t(size), Cttype, Cparams))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dmTaskGetDepsFct(task *CDmTask) *Deps {
|
||||||
|
Cdeps := C.dm_task_get_deps((*C.struct_dm_task)(task))
|
||||||
|
if Cdeps == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
deps := &Deps{
|
||||||
|
Count: uint32(Cdeps.count),
|
||||||
|
Filler: uint32(Cdeps.filler),
|
||||||
|
}
|
||||||
|
for _, device := range Cdeps.device {
|
||||||
|
deps.Device = append(deps.Device, (uint64)(device))
|
||||||
|
}
|
||||||
|
return deps
|
||||||
|
}
|
||||||
|
|
||||||
func dmTaskGetInfoFct(task *CDmTask, info *Info) int {
|
func dmTaskGetInfoFct(task *CDmTask, info *Info) int {
|
||||||
Cinfo := C.struct_dm_info{}
|
Cinfo := C.struct_dm_info{}
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
Loading…
Reference in a new issue