mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 18:59:33 +03:00
ddt: only create tables for dedup-capable checksums
Most values in zio_checksum can never be used for dedup, partly because the dedup= property only offers a limited list, but also some values (eg ZIO_CHECKSUM_OFF) aren't real and will never be seen. A true flag would be better than a hardcoded list, but thats more cleanup elsewhere than I want to do right now. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <rob.norris@klarasystems.com> Sponsored-by: Klara, Inc. Sponsored-by: iXsystems, Inc. Closes #15887
This commit is contained in:
parent
406562c563
commit
d961954688
@ -1965,6 +1965,8 @@ dump_all_ddts(spa_t *spa)
|
|||||||
|
|
||||||
for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
|
for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
|
||||||
ddt_t *ddt = spa->spa_ddt[c];
|
ddt_t *ddt = spa->spa_ddt[c];
|
||||||
|
if (!ddt)
|
||||||
|
continue;
|
||||||
for (ddt_type_t type = 0; type < DDT_TYPES; type++) {
|
for (ddt_type_t type = 0; type < DDT_TYPES; type++) {
|
||||||
for (ddt_class_t class = 0; class < DDT_CLASSES;
|
for (ddt_class_t class = 0; class < DDT_CLASSES;
|
||||||
class++) {
|
class++) {
|
||||||
@ -6062,6 +6064,8 @@ zdb_ddt_leak_init(spa_t *spa, zdb_cb_t *zcb)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ASSERT(ddt_phys_total_refcnt(&dde) > 1);
|
ASSERT(ddt_phys_total_refcnt(&dde) > 1);
|
||||||
|
ddt_t *ddt = spa->spa_ddt[ddb.ddb_checksum];
|
||||||
|
VERIFY(ddt);
|
||||||
|
|
||||||
for (p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
|
for (p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
|
||||||
if (ddp->ddp_phys_birth == 0)
|
if (ddp->ddp_phys_birth == 0)
|
||||||
@ -6076,7 +6080,7 @@ zdb_ddt_leak_init(spa_t *spa, zdb_cb_t *zcb)
|
|||||||
zcb->zcb_dedup_blocks++;
|
zcb->zcb_dedup_blocks++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ddt_t *ddt = spa->spa_ddt[ddb.ddb_checksum];
|
|
||||||
ddt_enter(ddt);
|
ddt_enter(ddt);
|
||||||
VERIFY(ddt_lookup(ddt, &blk, B_TRUE) != NULL);
|
VERIFY(ddt_lookup(ddt, &blk, B_TRUE) != NULL);
|
||||||
ddt_exit(ddt);
|
ddt_exit(ddt);
|
||||||
@ -7949,6 +7953,8 @@ dump_mos_leaks(spa_t *spa)
|
|||||||
for (uint64_t cksum = 0;
|
for (uint64_t cksum = 0;
|
||||||
cksum < ZIO_CHECKSUM_FUNCTIONS; cksum++) {
|
cksum < ZIO_CHECKSUM_FUNCTIONS; cksum++) {
|
||||||
ddt_t *ddt = spa->spa_ddt[cksum];
|
ddt_t *ddt = spa->spa_ddt[cksum];
|
||||||
|
if (!ddt)
|
||||||
|
continue;
|
||||||
mos_obj_refd(ddt->ddt_object[type][class]);
|
mos_obj_refd(ddt->ddt_object[type][class]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,15 @@
|
|||||||
#include <sys/dsl_scan.h>
|
#include <sys/dsl_scan.h>
|
||||||
#include <sys/abd.h>
|
#include <sys/abd.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These are the only checksums valid for dedup. They must match the list
|
||||||
|
* from dedup_table in zfs_prop.c
|
||||||
|
*/
|
||||||
|
#define DDT_CHECKSUM_VALID(c) \
|
||||||
|
(c == ZIO_CHECKSUM_SHA256 || c == ZIO_CHECKSUM_SHA512 || \
|
||||||
|
c == ZIO_CHECKSUM_SKEIN || c == ZIO_CHECKSUM_EDONR || \
|
||||||
|
c == ZIO_CHECKSUM_BLAKE3)
|
||||||
|
|
||||||
static kmem_cache_t *ddt_cache;
|
static kmem_cache_t *ddt_cache;
|
||||||
static kmem_cache_t *ddt_entry_cache;
|
static kmem_cache_t *ddt_entry_cache;
|
||||||
|
|
||||||
@ -400,6 +409,7 @@ ddt_phys_total_refcnt(const ddt_entry_t *dde)
|
|||||||
ddt_t *
|
ddt_t *
|
||||||
ddt_select(spa_t *spa, const blkptr_t *bp)
|
ddt_select(spa_t *spa, const blkptr_t *bp)
|
||||||
{
|
{
|
||||||
|
ASSERT(DDT_CHECKSUM_VALID(BP_GET_CHECKSUM(bp)));
|
||||||
return (spa->spa_ddt[BP_GET_CHECKSUM(bp)]);
|
return (spa->spa_ddt[BP_GET_CHECKSUM(bp)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,8 +639,10 @@ ddt_create(spa_t *spa)
|
|||||||
{
|
{
|
||||||
spa->spa_dedup_checksum = ZIO_DEDUPCHECKSUM;
|
spa->spa_dedup_checksum = ZIO_DEDUPCHECKSUM;
|
||||||
|
|
||||||
for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++)
|
for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
|
||||||
|
if (DDT_CHECKSUM_VALID(c))
|
||||||
spa->spa_ddt[c] = ddt_table_alloc(spa, c);
|
spa->spa_ddt[c] = ddt_table_alloc(spa, c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -648,6 +660,9 @@ ddt_load(spa_t *spa)
|
|||||||
return (error == ENOENT ? 0 : error);
|
return (error == ENOENT ? 0 : error);
|
||||||
|
|
||||||
for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
|
for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
|
||||||
|
if (!DDT_CHECKSUM_VALID(c))
|
||||||
|
continue;
|
||||||
|
|
||||||
ddt_t *ddt = spa->spa_ddt[c];
|
ddt_t *ddt = spa->spa_ddt[c];
|
||||||
for (ddt_type_t type = 0; type < DDT_TYPES; type++) {
|
for (ddt_type_t type = 0; type < DDT_TYPES; type++) {
|
||||||
for (ddt_class_t class = 0; class < DDT_CLASSES;
|
for (ddt_class_t class = 0; class < DDT_CLASSES;
|
||||||
@ -967,6 +982,8 @@ ddt_walk(spa_t *spa, ddt_bookmark_t *ddb, ddt_entry_t *dde)
|
|||||||
do {
|
do {
|
||||||
do {
|
do {
|
||||||
ddt_t *ddt = spa->spa_ddt[ddb->ddb_checksum];
|
ddt_t *ddt = spa->spa_ddt[ddb->ddb_checksum];
|
||||||
|
if (ddt == NULL)
|
||||||
|
continue;
|
||||||
int error = ENOENT;
|
int error = ENOENT;
|
||||||
if (ddt_object_exists(ddt, ddb->ddb_type,
|
if (ddt_object_exists(ddt, ddb->ddb_type,
|
||||||
ddb->ddb_class)) {
|
ddb->ddb_class)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user