diff --git a/module/zfs/dnode.c b/module/zfs/dnode.c index eaba9c0c0e7f..cafa650869a3 100644 --- a/module/zfs/dnode.c +++ b/module/zfs/dnode.c @@ -1610,7 +1610,11 @@ dnode_rele_and_unlock(dnode_t *dn, void *tag, boolean_t evicting) dmu_buf_impl_t *db = dn->dn_dbuf; dnode_handle_t *dnh = dn->dn_handle; - refs = zfs_refcount_remove(&dn->dn_holds, tag); + if (zfs_refcount_count(&dn->dn_holds) > 0) { + refs = zfs_refcount_remove(&dn->dn_holds, tag); + } else { + refs = 0; + } if (refs == 0) cv_broadcast(&dn->dn_nodnholds); mutex_exit(&dn->dn_mtx); diff --git a/module/zfs/dnode_sync.c b/module/zfs/dnode_sync.c index 66e48a1e17d4..e0da2e130b1b 100644 --- a/module/zfs/dnode_sync.c +++ b/module/zfs/dnode_sync.c @@ -594,10 +594,11 @@ dnode_sync_free(dnode_t *dn, dmu_tx_t *tx) ASSERT(dn->dn_type != DMU_OT_NONE); ASSERT(dn->dn_free_txg > 0); - if (dn->dn_allocated_txg != dn->dn_free_txg) + if (dn->dn_allocated_txg != dn->dn_free_txg && &dn->dn_dbuf->db != NULL) dmu_buf_will_dirty(&dn->dn_dbuf->db, tx); bzero(dn->dn_phys, sizeof (dnode_phys_t) * dn->dn_num_slots); - dnode_free_interior_slots(dn); + if (&dn->dn_dbuf->db != NULL) + dnode_free_interior_slots(dn); mutex_enter(&dn->dn_mtx); dn->dn_type = DMU_OT_NONE; diff --git a/module/zfs/dsl_crypt.c b/module/zfs/dsl_crypt.c index 1f24c750c8e4..8ac02fea8c0e 100644 --- a/module/zfs/dsl_crypt.c +++ b/module/zfs/dsl_crypt.c @@ -2136,6 +2136,8 @@ dsl_crypto_recv_raw_objset_sync(dsl_dataset_t *ds, dmu_objset_type_t ostype, /* dsl_dataset_sync_done will drop this reference. */ dmu_buf_add_ref(ds->ds_dbuf, ds); dsl_dataset_sync_done(ds, tx); + + dsl_dataset_create_key_mapping(ds); } }