aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/ddt.c
diff options
context:
space:
mode:
Diffstat (limited to 'module/zfs/ddt.c')
-rw-r--r--module/zfs/ddt.c72
1 files changed, 8 insertions, 64 deletions
diff --git a/module/zfs/ddt.c b/module/zfs/ddt.c
index a38c2b24e..05424d875 100644
--- a/module/zfs/ddt.c
+++ b/module/zfs/ddt.c
@@ -552,65 +552,6 @@ ddt_get_pool_dedup_ratio(spa_t *spa)
return (dds_total.dds_ref_dsize * 100 / dds_total.dds_dsize);
}
-int
-ddt_ditto_copies_needed(ddt_t *ddt, ddt_entry_t *dde, ddt_phys_t *ddp_willref)
-{
- spa_t *spa = ddt->ddt_spa;
- uint64_t total_refcnt = 0;
- uint64_t ditto = spa->spa_dedup_ditto;
- int total_copies = 0;
- int desired_copies = 0;
- int copies_needed = 0;
-
- for (int p = DDT_PHYS_SINGLE; p <= DDT_PHYS_TRIPLE; p++) {
- ddt_phys_t *ddp = &dde->dde_phys[p];
- zio_t *zio = dde->dde_lead_zio[p];
- uint64_t refcnt = ddp->ddp_refcnt; /* committed refs */
- if (zio != NULL)
- refcnt += zio->io_parent_count; /* pending refs */
- if (ddp == ddp_willref)
- refcnt++; /* caller's ref */
- if (refcnt != 0) {
- total_refcnt += refcnt;
- total_copies += p;
- }
- }
-
- if (ditto == 0 || ditto > UINT32_MAX)
- ditto = UINT32_MAX;
-
- if (total_refcnt >= 1)
- desired_copies++;
- if (total_refcnt >= ditto)
- desired_copies++;
- if (total_refcnt >= ditto * ditto)
- desired_copies++;
-
- copies_needed = MAX(desired_copies, total_copies) - total_copies;
-
- /* encrypted blocks store their IV in DVA[2] */
- if (DDK_GET_CRYPT(&dde->dde_key))
- copies_needed = MIN(copies_needed, SPA_DVAS_PER_BP - 1);
-
- return (copies_needed);
-}
-
-int
-ddt_ditto_copies_present(ddt_entry_t *dde)
-{
- ddt_phys_t *ddp = &dde->dde_phys[DDT_PHYS_DITTO];
- dva_t *dva = ddp->ddp_dva;
- int copies = 0 - DVA_GET_GANG(dva);
-
- for (int d = 0; d < DDE_GET_NDVAS(dde); d++, dva++)
- if (DVA_IS_VALID(dva))
- copies++;
-
- ASSERT(copies >= 0 && copies < SPA_DVAS_PER_BP);
-
- return (copies);
-}
-
size_t
ddt_compress(void *src, uchar_t *dst, size_t s_len, size_t d_len)
{
@@ -1088,8 +1029,11 @@ ddt_sync_entry(ddt_t *ddt, ddt_entry_t *dde, dmu_tx_t *tx, uint64_t txg)
continue;
}
if (p == DDT_PHYS_DITTO) {
- if (ddt_ditto_copies_needed(ddt, dde, NULL) == 0)
- ddt_phys_free(ddt, ddk, ddp, txg);
+ /*
+ * Note, we no longer create DDT-DITTO blocks, but we
+ * don't want to leak any written by older software.
+ */
+ ddt_phys_free(ddt, ddk, ddp, txg);
continue;
}
if (ddp->ddp_refcnt == 0)
@@ -1097,9 +1041,9 @@ ddt_sync_entry(ddt_t *ddt, ddt_entry_t *dde, dmu_tx_t *tx, uint64_t txg)
total_refcnt += ddp->ddp_refcnt;
}
- if (dde->dde_phys[DDT_PHYS_DITTO].ddp_phys_birth != 0)
- nclass = DDT_CLASS_DITTO;
- else if (total_refcnt > 1)
+ /* We do not create new DDT-DITTO blocks. */
+ ASSERT0(dde->dde_phys[DDT_PHYS_DITTO].ddp_phys_birth);
+ if (total_refcnt > 1)
nclass = DDT_CLASS_DUPLICATE;
else
nclass = DDT_CLASS_UNIQUE;