From 6b7e0db4e7c7d2c8363464b1786ab26a4c0e68ba Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Fri, 15 Jul 2016 19:49:43 -0400 Subject: [PATCH] Fix bug where VDevTree.Stat wasn't being populated because the wrong struct was being written to. --- zpool.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zpool.go b/zpool.go index dca41da..75f810e 100644 --- a/zpool.go +++ b/zpool.go @@ -145,7 +145,6 @@ func poolGetConfig(name string, nv *C.nvlist_t) (vdevs VDevTree, err error) { var vs *C.vdev_stat_t var ps *C.pool_scan_stat_t var child **C.nvlist_t - var vdev VDevTree if 0 != C.nvlist_lookup_string(nv, C.CString(C.ZPOOL_CONFIG_TYPE), &dtype) { err = fmt.Errorf("Failed to fetch %s", C.ZPOOL_CONFIG_TYPE) return @@ -171,8 +170,8 @@ func poolGetConfig(name string, nv *C.nvlist_t) (vdevs VDevTree, err error) { vdevs.Stat.RSize = uint64(vs.vs_rsize) vdevs.Stat.ESize = uint64(vs.vs_esize) for z := 0; z < ZIOTypes; z++ { - vdev.Stat.Ops[z] = uint64(vs.vs_ops[z]) - vdev.Stat.Bytes[z] = uint64(vs.vs_bytes[z]) + vdevs.Stat.Ops[z] = uint64(vs.vs_ops[z]) + vdevs.Stat.Bytes[z] = uint64(vs.vs_bytes[z]) } vdevs.Stat.ReadErrors = uint64(vs.vs_read_errors) vdevs.Stat.WriteErrors = uint64(vs.vs_write_errors) @@ -225,6 +224,8 @@ func poolGetConfig(name string, nv *C.nvlist_t) (vdevs VDevTree, err error) { } vname := C.zpool_vdev_name(libzfsHandle, nil, C.nvlist_array_at(child, c), C.B_TRUE) + + var vdev VDevTree vdev, err = poolGetConfig(C.GoString(vname), C.nvlist_array_at(child, c)) C.free_cstring(vname)