From 9b3a044099fb5d7bb8249432870a23137fd498cb Mon Sep 17 00:00:00 2001 From: Tim Chase Date: Sat, 24 Jan 2015 12:40:59 -0600 Subject: [PATCH] Revert "Add ddt, ddt_entry, and l2arc_hdr caches" This reverts commit ecf3d9b8e63e5659269e15db527380c65780f71a. Conflicts: module/zfs/arc.c module/zfs/ddt.c module/zfs/spa_misc.c --- include/sys/ddt.h | 2 -- module/zfs/arc.c | 17 +++++++---------- module/zfs/ddt.c | 37 ++++++++----------------------------- module/zfs/spa_misc.c | 2 -- 4 files changed, 15 insertions(+), 43 deletions(-) diff --git a/include/sys/ddt.h b/include/sys/ddt.h index b7977aae0357..77e1d4d5eb87 100644 --- a/include/sys/ddt.h +++ b/include/sys/ddt.h @@ -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); diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 214e7d471b1b..30c99f5f428d 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -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) @@ -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); } /* @@ -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--) @@ -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(); @@ -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); @@ -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); } @@ -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); } @@ -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; diff --git a/module/zfs/ddt.c b/module/zfs/ddt.c index 4d9fab6392b8..41edceae4058 100644 --- a/module/zfs/ddt.c +++ b/module/zfs/ddt.c @@ -37,9 +37,6 @@ #include #include -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. */ @@ -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)); @@ -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; @@ -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 @@ -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, @@ -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 @@ -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); } diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c index c17043657497..6bcc86ab43ce 100644 --- a/module/zfs/spa_misc.c +++ b/module/zfs/spa_misc.c @@ -1783,7 +1783,6 @@ spa_init(int mode) refcount_init(); unique_init(); range_tree_init(); - ddt_init(); zio_init(); dmu_init(); zil_init(); @@ -1808,7 +1807,6 @@ spa_fini(void) zil_fini(); dmu_fini(); zio_fini(); - ddt_fini(); range_tree_fini(); unique_fini(); refcount_fini();