Dave, this definitely sounds like a bug. Pavel (cc'd) has done some work
in this area that we unfortunately haven't upstreamed yet, but it would fix
your issue. In the new method, we always trust the MOS config as the
source of truth w.r.t. the vdev tree layout. So (I think) with the new
code
I have a contrived scenario which generated the follow vdev tree:
rvd->vdev_children = 1
rvd->vdev_child[0]->vdev_children = 5
rvd->vdev_child[0]->vdev_child[0]->vdev_children = 2
rvd->vdev_child[0]->vdev_child[0]->vdev_child[0]->vdev_children = 0