Skip to content

Commit

Permalink
Revert "Add ddt, ddt_entry, and l2arc_hdr caches"
Browse files Browse the repository at this point in the history
This reverts commit ecf3d9b.

Conflicts:
	module/zfs/arc.c
	module/zfs/ddt.c
	module/zfs/spa_misc.c
  • Loading branch information
dweeezil authored and kernelOfTruth committed Apr 30, 2015
1 parent 9061015 commit 9b3a044
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 43 deletions.
2 changes: 0 additions & 2 deletions include/sys/ddt.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ extern void ddt_decompress(uchar_t *src, void *dst, size_t s_len, size_t d_len);
extern ddt_t *ddt_select(spa_t *spa, const blkptr_t *bp);
extern void ddt_enter(ddt_t *ddt);
extern void ddt_exit(ddt_t *ddt);
extern void ddt_init(void);
extern void ddt_fini(void);
extern ddt_entry_t *ddt_lookup(ddt_t *ddt, const blkptr_t *bp, boolean_t add);
extern void ddt_prefetch(spa_t *spa, const blkptr_t *bp);
extern void ddt_remove(ddt_t *ddt, ddt_entry_t *dde);
Expand Down
17 changes: 7 additions & 10 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,6 @@ buf_hash_remove(arc_buf_hdr_t *buf)
*/
static kmem_cache_t *hdr_cache;
static kmem_cache_t *buf_cache;
static kmem_cache_t *l2arc_hdr_cache;

static void
buf_fini(void)
Expand All @@ -815,7 +814,6 @@ buf_fini(void)
mutex_destroy(&buf_hash_table.ht_locks[i].ht_lock);
kmem_cache_destroy(hdr_cache);
kmem_cache_destroy(buf_cache);
kmem_cache_destroy(l2arc_hdr_cache);
}

/*
Expand Down Expand Up @@ -917,8 +915,6 @@ buf_init(void)
0, hdr_cons, hdr_dest, NULL, NULL, NULL, 0);
buf_cache = kmem_cache_create("arc_buf_t", sizeof (arc_buf_t),
0, buf_cons, buf_dest, NULL, NULL, NULL, 0);
l2arc_hdr_cache = kmem_cache_create("l2arc_buf_hdr_t", L2HDR_SIZE,
0, NULL, NULL, NULL, NULL, NULL, 0);

for (i = 0; i < 256; i++)
for (ct = zfs_crc64_table + i, *ct = i, j = 8; j > 0; j--)
Expand Down Expand Up @@ -1616,7 +1612,7 @@ arc_hdr_destroy(arc_buf_hdr_t *hdr)
ARCSTAT_INCR(arcstat_l2_asize, -l2hdr->b_asize);
vdev_space_update(l2hdr->b_dev->l2ad_vdev,
-l2hdr->b_asize, 0, 0);
kmem_cache_free(l2arc_hdr_cache, l2hdr);
kmem_free(l2hdr, sizeof (l2arc_buf_hdr_t));
arc_space_return(L2HDR_SIZE, ARC_SPACE_L2HDRS);
if (hdr->b_state == arc_l2c_only)
l2arc_hdr_stat_remove();
Expand Down Expand Up @@ -3736,7 +3732,8 @@ arc_release(arc_buf_t *buf, void *tag)
ARCSTAT_INCR(arcstat_l2_asize, -l2hdr->b_asize);
vdev_space_update(l2hdr->b_dev->l2ad_vdev,
-l2hdr->b_asize, 0, 0);
kmem_cache_free(l2arc_hdr_cache, l2hdr);
list_remove(l2hdr->b_dev->l2ad_buflist, hdr);
kmem_free(l2hdr, sizeof (l2arc_buf_hdr_t));
arc_space_return(L2HDR_SIZE, ARC_SPACE_L2HDRS);
ARCSTAT_INCR(arcstat_l2_size, -buf_size);
mutex_exit(&l2arc_buflist_mtx);
Expand Down Expand Up @@ -4621,7 +4618,7 @@ l2arc_write_done(zio_t *zio)
ARCSTAT_INCR(arcstat_l2_asize, -abl2->b_asize);
bytes_dropped += abl2->b_asize;
ab->b_l2hdr = NULL;
kmem_cache_free(l2arc_hdr_cache, abl2);
kmem_free(abl2, sizeof (l2arc_buf_hdr_t));
arc_space_return(L2HDR_SIZE, ARC_SPACE_L2HDRS);
ARCSTAT_INCR(arcstat_l2_size, -ab->b_size);
}
Expand Down Expand Up @@ -4880,7 +4877,7 @@ l2arc_evict(l2arc_dev_t *dev, uint64_t distance, boolean_t all)
ARCSTAT_INCR(arcstat_l2_asize, -abl2->b_asize);
bytes_evicted += abl2->b_asize;
ab->b_l2hdr = NULL;
kmem_cache_free(l2arc_hdr_cache, abl2);
kmem_free(abl2, sizeof (l2arc_buf_hdr_t));
arc_space_return(L2HDR_SIZE, ARC_SPACE_L2HDRS);
ARCSTAT_INCR(arcstat_l2_size, -ab->b_size);
}
Expand Down Expand Up @@ -5026,9 +5023,9 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz,
/*
* Create and add a new L2ARC header.
*/
l2hdr = kmem_cache_alloc(l2arc_hdr_cache, KM_SLEEP);
l2hdr = kmem_zalloc(sizeof (l2arc_buf_hdr_t),
KM_PUSHPAGE);
l2hdr->b_dev = dev;
l2hdr->b_daddr = 0;
arc_space_consume(L2HDR_SIZE, ARC_SPACE_L2HDRS);

ab->b_flags |= ARC_L2_WRITING;
Expand Down
37 changes: 8 additions & 29 deletions module/zfs/ddt.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
#include <sys/zio_compress.h>
#include <sys/dsl_scan.h>

static kmem_cache_t *ddt_cache;
static kmem_cache_t *ddt_entry_cache;

/*
* Enable/disable prefetching of dedup-ed blocks which are going to be freed.
*/
Expand Down Expand Up @@ -517,7 +514,7 @@ ddt_get_dedup_stats(spa_t *spa, ddt_stat_t *dds_total)
{
ddt_histogram_t *ddh_total;

ddh_total = kmem_zalloc(sizeof (ddt_histogram_t), KM_SLEEP);
ddh_total = kmem_zalloc(sizeof (ddt_histogram_t), KM_PUSHPAGE);
ddt_get_dedup_histogram(spa, ddh_total);
ddt_histogram_stat(dds_total, ddh_total);
kmem_free(ddh_total, sizeof (ddt_histogram_t));
Expand Down Expand Up @@ -664,29 +661,12 @@ ddt_exit(ddt_t *ddt)
mutex_exit(&ddt->ddt_lock);
}

void
ddt_init(void)
{
ddt_cache = kmem_cache_create("ddt_cache",
sizeof (ddt_t), 0, NULL, NULL, NULL, NULL, NULL, 0);
ddt_entry_cache = kmem_cache_create("ddt_entry_cache",
sizeof (ddt_entry_t), 0, NULL, NULL, NULL, NULL, NULL, 0);
}

void
ddt_fini(void)
{
kmem_cache_destroy(ddt_entry_cache);
kmem_cache_destroy(ddt_cache);
}

static ddt_entry_t *
ddt_alloc(const ddt_key_t *ddk)
{
ddt_entry_t *dde;

dde = kmem_cache_alloc(ddt_entry_cache, KM_SLEEP);
bzero(dde, sizeof (ddt_entry_t));
dde = kmem_zalloc(sizeof (ddt_entry_t), KM_PUSHPAGE);
cv_init(&dde->dde_cv, NULL, CV_DEFAULT, NULL);

dde->dde_key = *ddk;
Expand All @@ -708,7 +688,7 @@ ddt_free(ddt_entry_t *dde)
abd_free(dde->dde_repair_data, DDK_GET_PSIZE(&dde->dde_key));

cv_destroy(&dde->dde_cv);
kmem_cache_free(ddt_entry_cache, dde);
kmem_free(dde, sizeof (*dde));
}

void
Expand Down Expand Up @@ -833,8 +813,7 @@ ddt_table_alloc(spa_t *spa, enum zio_checksum c)
{
ddt_t *ddt;

ddt = kmem_cache_alloc(ddt_cache, KM_SLEEP);
bzero(ddt, sizeof (ddt_t));
ddt = kmem_zalloc(sizeof (*ddt), KM_PUSHPAGE);

mutex_init(&ddt->ddt_lock, NULL, MUTEX_DEFAULT, NULL);
avl_create(&ddt->ddt_tree, ddt_entry_compare,
Expand All @@ -856,7 +835,7 @@ ddt_table_free(ddt_t *ddt)
avl_destroy(&ddt->ddt_tree);
avl_destroy(&ddt->ddt_repair_tree);
mutex_destroy(&ddt->ddt_lock);
kmem_cache_free(ddt_cache, ddt);
kmem_free(ddt, sizeof (*ddt));
}

void
Expand Down Expand Up @@ -936,20 +915,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_cache_alloc(ddt_entry_cache, KM_SLEEP);
dde = kmem_alloc(sizeof (ddt_entry_t), KM_PUSHPAGE);

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) {
kmem_cache_free(ddt_entry_cache, dde);
kmem_free(dde, sizeof (ddt_entry_t));
return (B_TRUE);
}
}
}

kmem_cache_free(ddt_entry_cache, dde);
kmem_free(dde, sizeof (ddt_entry_t));
return (B_FALSE);
}

Expand Down
2 changes: 0 additions & 2 deletions module/zfs/spa_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,6 @@ spa_init(int mode)
refcount_init();
unique_init();
range_tree_init();
ddt_init();
zio_init();
dmu_init();
zil_init();
Expand All @@ -1808,7 +1807,6 @@ spa_fini(void)
zil_fini();
dmu_fini();
zio_fini();
ddt_fini();
range_tree_fini();
unique_fini();
refcount_fini();
Expand Down

0 comments on commit 9b3a044

Please sign in to comment.