From c17486b2178fc545c50d48effd4be47d33208933 Mon Sep 17 00:00:00 2001 From: Gvozden Neskovic Date: Sat, 26 Nov 2016 21:30:44 +0100 Subject: [PATCH] Add missing *_destroy/*_fini calls The proposed debugging enhancements in zfsonlinux/spl#587 identified the following missing *_destroy/*_fini calls. Reviewed-by: Brian Behlendorf Signed-off-by: Gvozden Neskovic Closes #5428 --- cmd/raidz_test/raidz_test.c | 2 ++ include/sys/zfs_ratelimit.h | 1 + module/icp/core/kcf_mech_tabs.c | 16 +++++++++++++++- module/icp/core/kcf_prov_tabs.c | 6 ++++++ module/icp/core/kcf_sched.c | 20 +++++++++++++++++--- module/zcommon/zfs_comutil.c | 12 ++++++++++++ module/zfs/dmu_objset.c | 1 + module/zfs/dsl_deadlist.c | 2 +- module/zfs/dsl_pool.c | 1 + module/zfs/vdev.c | 3 +++ module/zfs/zap.c | 2 +- module/zfs/zap_micro.c | 3 ++- module/zfs/zfs_znode.c | 2 ++ 13 files changed, 64 insertions(+), 7 deletions(-) diff --git a/cmd/raidz_test/raidz_test.c b/cmd/raidz_test/raidz_test.c index 500ac3dae..a2b7e6cbf 100644 --- a/cmd/raidz_test/raidz_test.c +++ b/cmd/raidz_test/raidz_test.c @@ -729,6 +729,8 @@ exit: (ulong_t)tried_comb); } + mutex_destroy(&sem_mtx); + return (sweep_state == SWEEP_ERROR ? SWEEP_ERROR : 0); } diff --git a/include/sys/zfs_ratelimit.h b/include/sys/zfs_ratelimit.h index b9f9f73dc..f36e07841 100644 --- a/include/sys/zfs_ratelimit.h +++ b/include/sys/zfs_ratelimit.h @@ -33,5 +33,6 @@ typedef struct { int zfs_ratelimit(zfs_ratelimit_t *rl); void zfs_ratelimit_init(zfs_ratelimit_t *rl, unsigned int burst, unsigned int interval); +void zfs_ratelimit_fini(zfs_ratelimit_t *rl); #endif /* _SYS_ZFS_RATELIMIT_H */ diff --git a/module/icp/core/kcf_mech_tabs.c b/module/icp/core/kcf_mech_tabs.c index cac34a44a..723bfdb60 100644 --- a/module/icp/core/kcf_mech_tabs.c +++ b/module/icp/core/kcf_mech_tabs.c @@ -140,7 +140,21 @@ kcf_mech_hash_find(char *mechname) void kcf_destroy_mech_tabs(void) { - if (kcf_mech_hash) mod_hash_destroy_hash(kcf_mech_hash); + int i, max; + kcf_ops_class_t class; + kcf_mech_entry_t *me_tab; + + if (kcf_mech_hash) + mod_hash_destroy_hash(kcf_mech_hash); + + mutex_destroy(&kcf_mech_tabs_lock); + + for (class = KCF_FIRST_OPSCLASS; class <= KCF_LAST_OPSCLASS; class++) { + max = kcf_mech_tabs_tab[class].met_size; + me_tab = kcf_mech_tabs_tab[class].met_tab; + for (i = 0; i < max; i++) + mutex_destroy(&(me_tab[i].me_mutex)); + } } /* diff --git a/module/icp/core/kcf_prov_tabs.c b/module/icp/core/kcf_prov_tabs.c index c29832046..94e6937bc 100644 --- a/module/icp/core/kcf_prov_tabs.c +++ b/module/icp/core/kcf_prov_tabs.c @@ -67,6 +67,8 @@ static uint_t prov_tab_max = KCF_MAX_PROVIDERS; void kcf_prov_tab_destroy(void) { + mutex_destroy(&prov_tab_mutex); + if (prov_tab) kmem_free(prov_tab, prov_tab_max * sizeof (kcf_provider_desc_t *)); @@ -485,6 +487,10 @@ kcf_free_provider_desc(kcf_provider_desc_t *desc) if (desc->pd_sched_info.ks_taskq != NULL) taskq_destroy(desc->pd_sched_info.ks_taskq); + mutex_destroy(&desc->pd_lock); + cv_destroy(&desc->pd_resume_cv); + cv_destroy(&desc->pd_remove_cv); + kmem_free(desc, sizeof (kcf_provider_desc_t)); } diff --git a/module/icp/core/kcf_sched.c b/module/icp/core/kcf_sched.c index 90136c421..f9bcfe094 100644 --- a/module/icp/core/kcf_sched.c +++ b/module/icp/core/kcf_sched.c @@ -1056,17 +1056,28 @@ kcf_sched_destroy(void) if (kcf_misc_kstat) kstat_delete(kcf_misc_kstat); - if (kcfpool) + if (kcfpool) { + mutex_destroy(&kcfpool->kp_thread_lock); + cv_destroy(&kcfpool->kp_nothr_cv); + mutex_destroy(&kcfpool->kp_user_lock); + cv_destroy(&kcfpool->kp_user_cv); + kmem_free(kcfpool, sizeof (kcf_pool_t)); + } for (i = 0; i < REQID_TABLES; i++) { - if (kcf_reqid_table[i]) + if (kcf_reqid_table[i]) { + mutex_destroy(&(kcf_reqid_table[i]->rt_lock)); kmem_free(kcf_reqid_table[i], sizeof (kcf_reqid_table_t)); + } } - if (gswq) + if (gswq) { + mutex_destroy(&gswq->gs_lock); + cv_destroy(&gswq->gs_cv); kmem_free(gswq, sizeof (kcf_global_swq_t)); + } if (kcf_context_cache) kmem_cache_destroy(kcf_context_cache); @@ -1074,6 +1085,9 @@ kcf_sched_destroy(void) kmem_cache_destroy(kcf_areq_cache); if (kcf_sreq_cache) kmem_cache_destroy(kcf_sreq_cache); + + mutex_destroy(&ntfy_list_lock); + cv_destroy(&ntfy_list_cv); } /* diff --git a/module/zcommon/zfs_comutil.c b/module/zcommon/zfs_comutil.c index 704ef84c7..52cb7e365 100644 --- a/module/zcommon/zfs_comutil.c +++ b/module/zcommon/zfs_comutil.c @@ -225,6 +225,17 @@ zfs_ratelimit_init(zfs_ratelimit_t *rl, unsigned int burst, mutex_init(&rl->lock, NULL, MUTEX_DEFAULT, NULL); } +/* + * Finalize rate limit struct + * + * rl: zfs_ratelimit_t struct + */ +void +zfs_ratelimit_fini(zfs_ratelimit_t *rl) +{ + mutex_destroy(&rl->lock); +} + /* * Re-implementation of the kernel's __ratelimit() function * @@ -275,5 +286,6 @@ EXPORT_SYMBOL(zfs_zpl_version_map); EXPORT_SYMBOL(zfs_spa_version_map); EXPORT_SYMBOL(zfs_history_event_names); EXPORT_SYMBOL(zfs_ratelimit_init); +EXPORT_SYMBOL(zfs_ratelimit_fini); EXPORT_SYMBOL(zfs_ratelimit); #endif diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c index 43de05c50..946e4602f 100644 --- a/module/zfs/dmu_objset.c +++ b/module/zfs/dmu_objset.c @@ -846,6 +846,7 @@ dmu_objset_evict_done(objset_t *os) mutex_destroy(&os->os_userused_lock); mutex_destroy(&os->os_obj_lock); mutex_destroy(&os->os_user_ptr_lock); + mutex_destroy(&os->os_upgrade_lock); for (int i = 0; i < TXG_SIZE; i++) { multilist_destroy(os->os_dirty_dnodes[i]); } diff --git a/module/zfs/dsl_deadlist.c b/module/zfs/dsl_deadlist.c index e7046b786..258e626fa 100644 --- a/module/zfs/dsl_deadlist.c +++ b/module/zfs/dsl_deadlist.c @@ -120,6 +120,7 @@ dsl_deadlist_close(dsl_deadlist_t *dl) dsl_deadlist_entry_t *dle; dl->dl_os = NULL; + mutex_destroy(&dl->dl_lock); if (dl->dl_oldfmt) { dl->dl_oldfmt = B_FALSE; @@ -136,7 +137,6 @@ dsl_deadlist_close(dsl_deadlist_t *dl) avl_destroy(&dl->dl_tree); } dmu_buf_rele(dl->dl_dbuf, dl); - mutex_destroy(&dl->dl_lock); dl->dl_dbuf = NULL; dl->dl_phys = NULL; } diff --git a/module/zfs/dsl_pool.c b/module/zfs/dsl_pool.c index eb3e6eeb3..c98938f3c 100644 --- a/module/zfs/dsl_pool.c +++ b/module/zfs/dsl_pool.c @@ -348,6 +348,7 @@ dsl_pool_close(dsl_pool_t *dp) rrw_destroy(&dp->dp_config_rwlock); mutex_destroy(&dp->dp_lock); + cv_destroy(&dp->dp_spaceavail_cv); taskq_destroy(dp->dp_iput_taskq); if (dp->dp_blkstats) vmem_free(dp->dp_blkstats, sizeof (zfs_all_blkstats_t)); diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index dfb1ef522..3b2ba8e25 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -710,6 +710,9 @@ vdev_free(vdev_t *vd) mutex_destroy(&vd->vdev_stat_lock); mutex_destroy(&vd->vdev_probe_lock); + zfs_ratelimit_fini(&vd->vdev_delay_rl); + zfs_ratelimit_fini(&vd->vdev_checksum_rl); + if (vd == spa->spa_root_vdev) spa->spa_root_vdev = NULL; diff --git a/module/zfs/zap.c b/module/zfs/zap.c index 435278c6e..ee9962bff 100644 --- a/module/zfs/zap.c +++ b/module/zfs/zap.c @@ -84,7 +84,7 @@ fzap_upgrade(zap_t *zap, dmu_tx_t *tx, zap_flags_t flags) zap->zap_dbu.dbu_evict_func_sync = zap_evict_sync; zap->zap_dbu.dbu_evict_func_async = NULL; - mutex_init(&zap->zap_f.zap_num_entries_mtx, 0, 0, 0); + mutex_init(&zap->zap_f.zap_num_entries_mtx, 0, MUTEX_DEFAULT, 0); zap->zap_f.zap_block_shift = highbit64(zap->zap_dbuf->db_size) - 1; zp = zap_f_phys(zap); diff --git a/module/zfs/zap_micro.c b/module/zfs/zap_micro.c index 28c80e549..2cb9f42ae 100644 --- a/module/zfs/zap_micro.c +++ b/module/zfs/zap_micro.c @@ -404,7 +404,8 @@ mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db) zap->zap_dbuf = db; if (zap_block_type != ZBT_MICRO) { - mutex_init(&zap->zap_f.zap_num_entries_mtx, 0, 0, 0); + mutex_init(&zap->zap_f.zap_num_entries_mtx, 0, MUTEX_DEFAULT, + 0); zap->zap_f.zap_block_shift = highbit64(db->db_size) - 1; if (zap_block_type != ZBT_HEADER || zap_magic != ZAP_MAGIC) { winner = NULL; /* No actual winner here... */ diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c index 93437afb3..522621668 100644 --- a/module/zfs/zfs_znode.c +++ b/module/zfs/zfs_znode.c @@ -1913,6 +1913,8 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx) mutex_destroy(&zfsvfs->z_hold_locks[i]); } + mutex_destroy(&zfsvfs->z_znodes_lock); + vmem_free(zfsvfs->z_hold_trees, sizeof (avl_tree_t) * size); vmem_free(zfsvfs->z_hold_locks, sizeof (kmutex_t) * size); kmem_free(sb, sizeof (struct super_block)); -- 2.40.0