aboutsummaryrefslogtreecommitdiffstats
path: root/include/sys
diff options
context:
space:
mode:
authorRob Norris <[email protected]>2023-07-03 22:16:04 +1000
committerBrian Behlendorf <[email protected]>2024-08-16 12:02:22 -0700
commit4d686c3da53db5e5f3f3cc52060d9fbca2baf092 (patch)
tree9747b7af3a59ace608ba064b4bac7b08894ac4da /include/sys
parentd17ab631a9142b81b100d87f0619f5e59bc211ac (diff)
ddt: introduce lightweight entry
The idea here is that sometimes you need the contents of an entry with no intent to modify it, and/or from a place where its difficult to get hold of its originating ddt_t to know how to interpret it. A lightweight entry contains everything you might need to "read" an entry - its key, type and phys contents - but none of the extras for modifying it or using it in a larger context. It also has the full complement of phys slots, so it can represent any kind of dedup entry without having to know the specific configuration of the table it came from. Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rob Norris <[email protected]> Sponsored-by: Klara, Inc. Sponsored-by: iXsystems, Inc. Closes #15893
Diffstat (limited to 'include/sys')
-rw-r--r--include/sys/ddt.h16
-rw-r--r--include/sys/ddt_impl.h13
-rw-r--r--include/sys/dsl_scan.h2
3 files changed, 27 insertions, 4 deletions
diff --git a/include/sys/ddt.h b/include/sys/ddt.h
index a2e069f13..7a0916690 100644
--- a/include/sys/ddt.h
+++ b/include/sys/ddt.h
@@ -174,6 +174,18 @@ typedef struct {
} ddt_entry_t;
/*
+ * A lightweight entry is for short-lived or transient uses, like iterating or
+ * inspecting, when you don't care where it came from.
+ */
+typedef struct {
+ ddt_key_t ddlwe_key;
+ ddt_type_t ddlwe_type;
+ ddt_class_t ddlwe_class;
+ uint8_t ddlwe_nphys;
+ ddt_phys_t ddlwe_phys[DDT_PHYS_MAX];
+} ddt_lightweight_entry_t;
+
+/*
* In-core DDT object. This covers all entries and stats for a the whole pool
* for a given checksum type.
*/
@@ -241,7 +253,6 @@ extern uint64_t ddt_get_pool_dedup_ratio(spa_t *spa);
extern int ddt_get_pool_dedup_cached(spa_t *spa, uint64_t *psize);
extern ddt_t *ddt_select(spa_t *spa, const blkptr_t *bp);
-extern ddt_t *ddt_select_checksum(spa_t *spa, enum zio_checksum checksum);
extern void ddt_enter(ddt_t *ddt);
extern void ddt_exit(ddt_t *ddt);
extern void ddt_init(void);
@@ -263,7 +274,8 @@ extern void ddt_create(spa_t *spa);
extern int ddt_load(spa_t *spa);
extern void ddt_unload(spa_t *spa);
extern void ddt_sync(spa_t *spa, uint64_t txg);
-extern int ddt_walk(spa_t *spa, ddt_bookmark_t *ddb, ddt_entry_t *dde);
+extern int ddt_walk(spa_t *spa, ddt_bookmark_t *ddb,
+ ddt_lightweight_entry_t *ddlwe);
extern boolean_t ddt_addref(spa_t *spa, const blkptr_t *bp);
diff --git a/include/sys/ddt_impl.h b/include/sys/ddt_impl.h
index e97b71621..e88a046ab 100644
--- a/include/sys/ddt_impl.h
+++ b/include/sys/ddt_impl.h
@@ -41,6 +41,17 @@ extern "C" {
#define DDT_DIR_VERSION "version"
#define DDT_DIR_FLAGS "flags"
+/* Fill a lightweight entry from a live entry. */
+#define DDT_ENTRY_TO_LIGHTWEIGHT(ddt, dde, ddlwe) do { \
+ memset((ddlwe), 0, sizeof (*ddlwe)); \
+ (ddlwe)->ddlwe_key = (dde)->dde_key; \
+ (ddlwe)->ddlwe_type = (dde)->dde_type; \
+ (ddlwe)->ddlwe_class = (dde)->dde_class; \
+ (ddlwe)->ddlwe_nphys = DDT_NPHYS(ddt); \
+ for (int p = 0; p < (ddlwe)->ddlwe_nphys; p++) \
+ (ddlwe)->ddlwe_phys[p] = (dde)->dde_phys[p]; \
+} while (0)
+
/*
* Ops vector to access a specific DDT object type.
*/
@@ -91,7 +102,7 @@ extern void ddt_stat_add(ddt_stat_t *dst, const ddt_stat_t *src, uint64_t neg);
extern void ddt_object_name(ddt_t *ddt, ddt_type_t type, ddt_class_t clazz,
char *name);
extern int ddt_object_walk(ddt_t *ddt, ddt_type_t type, ddt_class_t clazz,
- uint64_t *walk, ddt_entry_t *dde);
+ uint64_t *walk, ddt_lightweight_entry_t *ddlwe);
extern int ddt_object_count(ddt_t *ddt, ddt_type_t type, ddt_class_t clazz,
uint64_t *count);
extern int ddt_object_info(ddt_t *ddt, ddt_type_t type, ddt_class_t clazz,
diff --git a/include/sys/dsl_scan.h b/include/sys/dsl_scan.h
index f32f59a2b..b91d7f4be 100644
--- a/include/sys/dsl_scan.h
+++ b/include/sys/dsl_scan.h
@@ -202,7 +202,7 @@ boolean_t dsl_scan_resilvering(struct dsl_pool *dp);
boolean_t dsl_scan_resilver_scheduled(struct dsl_pool *dp);
boolean_t dsl_dataset_unstable(struct dsl_dataset *ds);
void dsl_scan_ddt_entry(dsl_scan_t *scn, enum zio_checksum checksum,
- ddt_entry_t *dde, dmu_tx_t *tx);
+ ddt_lightweight_entry_t *ddlwe, dmu_tx_t *tx);
void dsl_scan_ds_destroyed(struct dsl_dataset *ds, struct dmu_tx *tx);
void dsl_scan_ds_snapshotted(struct dsl_dataset *ds, struct dmu_tx *tx);
void dsl_scan_ds_clone_swapped(struct dsl_dataset *ds1, struct dsl_dataset *ds2,