diff options
Diffstat (limited to 'module/zfs/vdev.c')
-rw-r--r-- | module/zfs/vdev.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index fe6631925..d53537103 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -179,6 +179,27 @@ vdev_lookup_by_guid(vdev_t *vd, uint64_t guid) return (NULL); } +static int +vdev_count_leaves_impl(vdev_t *vd) +{ + int n = 0; + int c; + + if (vd->vdev_ops->vdev_op_leaf) + return (1); + + for (c = 0; c < vd->vdev_children; c++) + n += vdev_count_leaves_impl(vd->vdev_child[c]); + + return (n); +} + +int +vdev_count_leaves(spa_t *spa) +{ + return (vdev_count_leaves_impl(spa->spa_root_vdev)); +} + void vdev_add_child(vdev_t *pvd, vdev_t *cvd) { |