diff options
author | Rob Norris <[email protected]> | 2023-07-03 22:16:04 +1000 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2024-08-16 12:02:22 -0700 |
commit | 4d686c3da53db5e5f3f3cc52060d9fbca2baf092 (patch) | |
tree | 9747b7af3a59ace608ba064b4bac7b08894ac4da /include/sys/ddt_impl.h | |
parent | d17ab631a9142b81b100d87f0619f5e59bc211ac (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/ddt_impl.h')
-rw-r--r-- | include/sys/ddt_impl.h | 13 |
1 files changed, 12 insertions, 1 deletions
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, |