MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ddt_sync_entry

Function ddt_sync_entry

freebsd/contrib/openzfs/module/zfs/ddt.c:1004–1071  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1002}
1003
1004static void
1005ddt_sync_entry(ddt_t *ddt, ddt_entry_t *dde, dmu_tx_t *tx, uint64_t txg)
1006{
1007 dsl_pool_t *dp = ddt->ddt_spa->spa_dsl_pool;
1008 ddt_phys_t *ddp = dde->dde_phys;
1009 ddt_key_t *ddk = &dde->dde_key;
1010 enum ddt_type otype = dde->dde_type;
1011 enum ddt_type ntype = DDT_TYPE_CURRENT;
1012 enum ddt_class oclass = dde->dde_class;
1013 enum ddt_class nclass;
1014 uint64_t total_refcnt = 0;
1015
1016 ASSERT(dde->dde_loaded);
1017 ASSERT(!dde->dde_loading);
1018
1019 for (int p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
1020 ASSERT(dde->dde_lead_zio[p] == NULL);
1021 if (ddp->ddp_phys_birth == 0) {
1022 ASSERT(ddp->ddp_refcnt == 0);
1023 continue;
1024 }
1025 if (p == DDT_PHYS_DITTO) {
1026 /*
1027 * Note, we no longer create DDT-DITTO blocks, but we
1028 * don't want to leak any written by older software.
1029 */
1030 ddt_phys_free(ddt, ddk, ddp, txg);
1031 continue;
1032 }
1033 if (ddp->ddp_refcnt == 0)
1034 ddt_phys_free(ddt, ddk, ddp, txg);
1035 total_refcnt += ddp->ddp_refcnt;
1036 }
1037
1038 /* We do not create new DDT-DITTO blocks. */
1039 ASSERT0(dde->dde_phys[DDT_PHYS_DITTO].ddp_phys_birth);
1040 if (total_refcnt > 1)
1041 nclass = DDT_CLASS_DUPLICATE;
1042 else
1043 nclass = DDT_CLASS_UNIQUE;
1044
1045 if (otype != DDT_TYPES &&
1046 (otype != ntype || oclass != nclass || total_refcnt == 0)) {
1047 VERIFY(ddt_object_remove(ddt, otype, oclass, dde, tx) == 0);
1048 ASSERT(ddt_object_lookup(ddt, otype, oclass, dde) == ENOENT);
1049 }
1050
1051 if (total_refcnt != 0) {
1052 dde->dde_type = ntype;
1053 dde->dde_class = nclass;
1054 ddt_stat_update(ddt, dde, 0);
1055 if (!ddt_object_exists(ddt, ntype, nclass))
1056 ddt_object_create(ddt, ntype, nclass, tx);
1057 VERIFY(ddt_object_update(ddt, ntype, nclass, dde, tx) == 0);
1058
1059 /*
1060 * If the class changes, the order that we scan this bp
1061 * changes. If it decreases, we could miss it, so

Callers 1

ddt_sync_tableFunction · 0.85

Calls 8

ddt_phys_freeFunction · 0.85
ddt_object_removeFunction · 0.85
ddt_object_lookupFunction · 0.85
ddt_stat_updateFunction · 0.85
ddt_object_existsFunction · 0.85
ddt_object_createFunction · 0.85
ddt_object_updateFunction · 0.85
dsl_scan_ddt_entryFunction · 0.85

Tested by

no test coverage detected