| 1071 | } |
| 1072 | |
| 1073 | static void |
| 1074 | ddt_sync_table(ddt_t *ddt, dmu_tx_t *tx, uint64_t txg) |
| 1075 | { |
| 1076 | spa_t *spa = ddt->ddt_spa; |
| 1077 | ddt_entry_t *dde; |
| 1078 | void *cookie = NULL; |
| 1079 | |
| 1080 | if (avl_numnodes(&ddt->ddt_tree) == 0) |
| 1081 | return; |
| 1082 | |
| 1083 | ASSERT(spa->spa_uberblock.ub_version >= SPA_VERSION_DEDUP); |
| 1084 | |
| 1085 | if (spa->spa_ddt_stat_object == 0) { |
| 1086 | spa->spa_ddt_stat_object = zap_create_link(ddt->ddt_os, |
| 1087 | DMU_OT_DDT_STATS, DMU_POOL_DIRECTORY_OBJECT, |
| 1088 | DMU_POOL_DDT_STATS, tx); |
| 1089 | } |
| 1090 | |
| 1091 | while ((dde = avl_destroy_nodes(&ddt->ddt_tree, &cookie)) != NULL) { |
| 1092 | ddt_sync_entry(ddt, dde, tx, txg); |
| 1093 | ddt_free(dde); |
| 1094 | } |
| 1095 | |
| 1096 | for (enum ddt_type type = 0; type < DDT_TYPES; type++) { |
| 1097 | uint64_t add, count = 0; |
| 1098 | for (enum ddt_class class = 0; class < DDT_CLASSES; class++) { |
| 1099 | if (ddt_object_exists(ddt, type, class)) { |
| 1100 | ddt_object_sync(ddt, type, class, tx); |
| 1101 | VERIFY(ddt_object_count(ddt, type, class, |
| 1102 | &add) == 0); |
| 1103 | count += add; |
| 1104 | } |
| 1105 | } |
| 1106 | for (enum ddt_class class = 0; class < DDT_CLASSES; class++) { |
| 1107 | if (count == 0 && ddt_object_exists(ddt, type, class)) |
| 1108 | ddt_object_destroy(ddt, type, class, tx); |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | bcopy(ddt->ddt_histogram, &ddt->ddt_histogram_cache, |
| 1113 | sizeof (ddt->ddt_histogram)); |
| 1114 | spa->spa_dedup_dspace = ~0ULL; |
| 1115 | } |
| 1116 | |
| 1117 | void |
| 1118 | ddt_sync(spa_t *spa, uint64_t txg) |
no test coverage detected