X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=module%2Fzfs%2Fddt.c;h=18c6cef5a84fecbc5fc0b9601ea1abaaba43212e;hb=2a4a9dc2f09d7672268af4a4f70e1a26b481b5e9;hp=ae9d2a5e139cf6113267952301df58cee314ce0a;hpb=d6320ddb78fa89c4d0fc2af00ae53c7c70992f96;p=zfs.git diff --git a/module/zfs/ddt.c b/module/zfs/ddt.c index ae9d2a5..18c6cef 100644 --- a/module/zfs/ddt.c +++ b/module/zfs/ddt.c @@ -120,7 +120,9 @@ ddt_object_load(ddt_t *ddt, enum ddt_type type, enum ddt_class class) /* * Seed the cached statistics. */ - VERIFY(ddt_object_info(ddt, type, class, &doi) == 0); + error = ddt_object_info(ddt, type, class, &doi); + if (error) + return (error); ddo->ddo_count = ddt_object_count(ddt, type, class); ddo->ddo_dspace = doi.doi_physical_blocks_512 << 9; @@ -501,6 +503,7 @@ ddt_get_dedup_stats(spa_t *spa, ddt_stat_t *dds_total) { ddt_histogram_t *ddh_total; + /* XXX: Move to a slab */ ddh_total = kmem_zalloc(sizeof (ddt_histogram_t), KM_SLEEP); ddt_get_dedup_histogram(spa, ddh_total); ddt_histogram_stat(dds_total, ddh_total); @@ -649,6 +652,7 @@ ddt_alloc(const ddt_key_t *ddk) { ddt_entry_t *dde; + /* XXX: Move to a slab */ dde = kmem_zalloc(sizeof (ddt_entry_t), KM_SLEEP); cv_init(&dde->dde_cv, NULL, CV_DEFAULT, NULL); @@ -797,7 +801,8 @@ ddt_table_alloc(spa_t *spa, enum zio_checksum c) { ddt_t *ddt; - ddt = kmem_zalloc(sizeof (*ddt), KM_SLEEP); + /* XXX: Move to a slab */ + ddt = kmem_zalloc(sizeof (*ddt), KM_SLEEP | KM_NODEBUG); mutex_init(&ddt->ddt_lock, NULL, MUTEX_DEFAULT, NULL); avl_create(&ddt->ddt_tree, ddt_entry_compare, @@ -888,7 +893,7 @@ boolean_t ddt_class_contains(spa_t *spa, enum ddt_class max_class, const blkptr_t *bp) { ddt_t *ddt; - ddt_entry_t dde; + ddt_entry_t *dde; enum ddt_type type; enum ddt_class class; @@ -899,14 +904,20 @@ ddt_class_contains(spa_t *spa, enum ddt_class max_class, const blkptr_t *bp) return (B_TRUE); ddt = spa->spa_ddt[BP_GET_CHECKSUM(bp)]; + dde = kmem_alloc(sizeof(ddt_entry_t), KM_SLEEP); - ddt_key_fill(&dde.dde_key, bp); + ddt_key_fill(&(dde->dde_key), bp); - for (type = 0; type < DDT_TYPES; type++) - for (class = 0; class <= max_class; class++) - if (ddt_object_lookup(ddt, type, class, &dde) == 0) + for (type = 0; type < DDT_TYPES; type++) { + for (class = 0; class <= max_class; class++) { + if (ddt_object_lookup(ddt, type, class, dde) == 0) { + kmem_free(dde, sizeof(ddt_entry_t)); return (B_TRUE); + } + } + } + kmem_free(dde, sizeof(ddt_entry_t)); return (B_FALSE); } @@ -1184,3 +1195,8 @@ ddt_walk(spa_t *spa, ddt_bookmark_t *ddb, ddt_entry_t *dde) return (ENOENT); } + +#if defined(_KERNEL) && defined(HAVE_SPL) +module_param(zfs_dedup_prefetch, int, 0644); +MODULE_PARM_DESC(zfs_dedup_prefetch,"Enable prefetching dedup-ed blks"); +#endif