Print this page
5269 zfs: zpool import slow
PORTING: this code relies on the property of taskq_wait to wait
until no more tasks are queued and no more tasks are active. As
we always queue new tasks from within other tasks, task_wait
reliably waits for the full recursion to finish, even though we
enqueue new tasks after taskq_wait has been called.
On platforms other than illumos, taskq_wait may not have this
property.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: George Wilson <george.wilson@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/vdev.c
          +++ new/usr/src/uts/common/fs/zfs/vdev.c
↓ open down ↓ 170 lines elided ↑ open up ↑
 171  171                  return (vd);
 172  172  
 173  173          for (int c = 0; c < vd->vdev_children; c++)
 174  174                  if ((mvd = vdev_lookup_by_guid(vd->vdev_child[c], guid)) !=
 175  175                      NULL)
 176  176                          return (mvd);
 177  177  
 178  178          return (NULL);
 179  179  }
 180  180  
      181 +static int
      182 +vdev_count_leaves_impl(vdev_t *vd)
      183 +{
      184 +        int n = 0;
      185 +
      186 +        if (vd->vdev_ops->vdev_op_leaf)
      187 +                return (1);
      188 +
      189 +        for (int c = 0; c < vd->vdev_children; c++)
      190 +                n += vdev_count_leaves_impl(vd->vdev_child[c]);
      191 +
      192 +        return (n);
      193 +}
      194 +
      195 +int
      196 +vdev_count_leaves(spa_t *spa)
      197 +{
      198 +        return (vdev_count_leaves_impl(spa->spa_root_vdev));
      199 +}
      200 +
 181  201  void
 182  202  vdev_add_child(vdev_t *pvd, vdev_t *cvd)
 183  203  {
 184  204          size_t oldsize, newsize;
 185  205          uint64_t id = cvd->vdev_id;
 186  206          vdev_t **newchild;
 187  207  
 188  208          ASSERT(spa_config_held(cvd->vdev_spa, SCL_ALL, RW_WRITER) == SCL_ALL);
 189  209          ASSERT(cvd->vdev_parent == NULL);
 190  210  
↓ open down ↓ 3144 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX