+ td = kmem_alloc(sizeof(traverse_data_t), KM_SLEEP);
+ pd = kmem_zalloc(sizeof(prefetch_data_t), KM_SLEEP);
+ czb = kmem_alloc(sizeof(zbookmark_t), KM_SLEEP);
+
+ td->td_spa = spa;
+ td->td_objset = ds ? ds->ds_object : 0;
+ td->td_rootbp = rootbp;
+ td->td_min_txg = txg_start;
+ td->td_func = func;
+ td->td_arg = arg;
+ td->td_pfd = pd;
+ td->td_flags = flags;
+
+ pd->pd_blks_max = zfs_pd_blks_max;
+ pd->pd_flags = flags;
+ mutex_init(&pd->pd_mtx, NULL, MUTEX_DEFAULT, NULL);
+ cv_init(&pd->pd_cv, NULL, CV_DEFAULT, NULL);
+
+ /* See comment on ZIL traversal in dsl_scan_visitds. */
+ if (ds != NULL && !dsl_dataset_is_snapshot(ds)) {
+ objset_t *os;
+
+ err = dmu_objset_from_ds(ds, &os);
+ if (err)
+ return (err);