Add -p switch to "zpool get"
[zfs.git] / module / zfs / ddt.c
index 6221157..286f3bb 100644 (file)
@@ -21,6 +21,7 @@
 
 /*
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
  */
 
 #include <sys/zfs_context.h>
@@ -322,8 +323,10 @@ ddt_phys_addref(ddt_phys_t *ddp)
 void
 ddt_phys_decref(ddt_phys_t *ddp)
 {
-       ASSERT((int64_t)ddp->ddp_refcnt > 0);
-       ddp->ddp_refcnt--;
+       if (ddp) {
+               ASSERT(ddp->ddp_refcnt > 0);
+               ddp->ddp_refcnt--;
+       }
 }
 
 void
@@ -1055,7 +1058,6 @@ ddt_sync_entry(ddt_t *ddt, ddt_entry_t *dde, dmu_tx_t *tx, uint64_t txg)
 
        for (p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
                ASSERT(dde->dde_lead_zio[p] == NULL);
-               ASSERT((int64_t)ddp->ddp_refcnt >= 0);
                if (ddp->ddp_phys_birth == 0) {
                        ASSERT(ddp->ddp_refcnt == 0);
                        continue;
@@ -1120,11 +1122,9 @@ ddt_sync_table(ddt_t *ddt, dmu_tx_t *tx, uint64_t txg)
        ASSERT(spa->spa_uberblock.ub_version >= SPA_VERSION_DEDUP);
 
        if (spa->spa_ddt_stat_object == 0) {
-               spa->spa_ddt_stat_object = zap_create(ddt->ddt_os,
-                   DMU_OT_DDT_STATS, DMU_OT_NONE, 0, tx);
-               VERIFY(zap_add(ddt->ddt_os, DMU_POOL_DIRECTORY_OBJECT,
-                   DMU_POOL_DDT_STATS, sizeof (uint64_t), 1,
-                   &spa->spa_ddt_stat_object, tx) == 0);
+               spa->spa_ddt_stat_object = zap_create_link(ddt->ddt_os,
+                   DMU_OT_DDT_STATS, DMU_POOL_DIRECTORY_OBJECT,
+                   DMU_POOL_DDT_STATS, tx);
        }
 
        while ((dde = avl_destroy_nodes(&ddt->ddt_tree, &cookie)) != NULL) {