diff options
author | Tim Chase <[email protected]> | 2015-02-24 12:53:31 -0600 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-02-27 13:54:15 -0800 |
commit | fdc5d98253c60e45be7efe62ed428d4c2344e394 (patch) | |
tree | 5c0ff0790092a6e33733bc35f3c43d7f2016d2b7 /cmd/ztest | |
parent | 8bdcfb53966313e9ff747e3028390c207cfdbe9a (diff) |
Avoid dladdr() in ztest
Under Linux, at least, dladdr() doesn't reliably work for functions which
aren't in a DSO. Add the function name to ztest_info[].
Signed-off-by: Tim Chase <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #3130
Diffstat (limited to 'cmd/ztest')
-rw-r--r-- | cmd/ztest/ztest.c | 83 |
1 files changed, 39 insertions, 44 deletions
diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index b6f2e234b..0602a7ec5 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -119,7 +119,6 @@ #include <unistd.h> #include <signal.h> #include <umem.h> -#include <dlfcn.h> #include <ctype.h> #include <math.h> #include <sys/fs/zfs.h> @@ -297,6 +296,7 @@ typedef struct ztest_info { ztest_func_t *zi_func; /* test function */ uint64_t zi_iters; /* iterations per execution */ uint64_t *zi_interval; /* execute every <interval> seconds */ + const char *zi_funcname; /* name of test function */ } ztest_info_t; typedef struct ztest_shared_callstate { @@ -308,9 +308,6 @@ typedef struct ztest_shared_callstate { static ztest_shared_callstate_t *ztest_shared_callstate; #define ZTEST_GET_SHARED_CALLSTATE(c) (&ztest_shared_callstate[c]) -/* - * Note: these aren't static because we want dladdr() to work. - */ ztest_func_t ztest_dmu_read_write; ztest_func_t ztest_dmu_write_parallel; ztest_func_t ztest_dmu_object_alloc_free; @@ -347,40 +344,44 @@ uint64_t zopt_often = 1ULL * NANOSEC; /* every second */ uint64_t zopt_sometimes = 10ULL * NANOSEC; /* every 10 seconds */ uint64_t zopt_rarely = 60ULL * NANOSEC; /* every 60 seconds */ +#define ZTI_INIT(func, iters, interval) \ + { .zi_func = (func), \ + .zi_iters = (iters), \ + .zi_interval = (interval), \ + .zi_funcname = # func } + ztest_info_t ztest_info[] = { - { ztest_dmu_read_write, 1, &zopt_always }, - { ztest_dmu_write_parallel, 10, &zopt_always }, - { ztest_dmu_object_alloc_free, 1, &zopt_always }, - { ztest_dmu_commit_callbacks, 1, &zopt_always }, - { ztest_zap, 30, &zopt_always }, - { ztest_zap_parallel, 100, &zopt_always }, - { ztest_split_pool, 1, &zopt_always }, - { ztest_zil_commit, 1, &zopt_incessant }, - { ztest_zil_remount, 1, &zopt_sometimes }, - { ztest_dmu_read_write_zcopy, 1, &zopt_often }, - { ztest_dmu_objset_create_destroy, 1, &zopt_often }, - { ztest_dsl_prop_get_set, 1, &zopt_often }, - { ztest_spa_prop_get_set, 1, &zopt_sometimes }, + ZTI_INIT(ztest_dmu_read_write, 1, &zopt_always), + ZTI_INIT(ztest_dmu_write_parallel, 10, &zopt_always), + ZTI_INIT(ztest_dmu_object_alloc_free, 1, &zopt_always), + ZTI_INIT(ztest_dmu_commit_callbacks, 1, &zopt_always), + ZTI_INIT(ztest_zap, 30, &zopt_always), + ZTI_INIT(ztest_zap_parallel, 100, &zopt_always), + ZTI_INIT(ztest_split_pool, 1, &zopt_always), + ZTI_INIT(ztest_zil_commit, 1, &zopt_incessant), + ZTI_INIT(ztest_zil_remount, 1, &zopt_sometimes), + ZTI_INIT(ztest_dmu_read_write_zcopy, 1, &zopt_often), + ZTI_INIT(ztest_dmu_objset_create_destroy, 1, &zopt_often), + ZTI_INIT(ztest_dsl_prop_get_set, 1, &zopt_often), + ZTI_INIT(ztest_spa_prop_get_set, 1, &zopt_sometimes), #if 0 - { ztest_dmu_prealloc, 1, &zopt_sometimes }, + ZTI_INIT(ztest_dmu_prealloc, 1, &zopt_sometimes), #endif - { ztest_fzap, 1, &zopt_sometimes }, - { ztest_dmu_snapshot_create_destroy, 1, &zopt_sometimes }, - { ztest_spa_create_destroy, 1, &zopt_sometimes }, - { ztest_fault_inject, 1, &zopt_sometimes }, - { ztest_ddt_repair, 1, &zopt_sometimes }, - { ztest_dmu_snapshot_hold, 1, &zopt_sometimes }, - { ztest_reguid, 1, &zopt_rarely }, - { ztest_spa_rename, 1, &zopt_rarely }, - { ztest_scrub, 1, &zopt_rarely }, - { ztest_spa_upgrade, 1, &zopt_rarely }, - { ztest_dsl_dataset_promote_busy, 1, &zopt_rarely }, - { ztest_vdev_attach_detach, 1, &zopt_sometimes }, - { ztest_vdev_LUN_growth, 1, &zopt_rarely }, - { ztest_vdev_add_remove, 1, - &ztest_opts.zo_vdevtime }, - { ztest_vdev_aux_add_remove, 1, - &ztest_opts.zo_vdevtime }, + ZTI_INIT(ztest_fzap, 1, &zopt_sometimes), + ZTI_INIT(ztest_dmu_snapshot_create_destroy, 1, &zopt_sometimes), + ZTI_INIT(ztest_spa_create_destroy, 1, &zopt_sometimes), + ZTI_INIT(ztest_fault_inject, 1, &zopt_sometimes), + ZTI_INIT(ztest_ddt_repair, 1, &zopt_sometimes), + ZTI_INIT(ztest_dmu_snapshot_hold, 1, &zopt_sometimes), + ZTI_INIT(ztest_reguid, 1, &zopt_rarely), + ZTI_INIT(ztest_spa_rename, 1, &zopt_rarely), + ZTI_INIT(ztest_scrub, 1, &zopt_rarely), + ZTI_INIT(ztest_spa_upgrade, 1, &zopt_rarely), + ZTI_INIT(ztest_dsl_dataset_promote_busy, 1, &zopt_rarely), + ZTI_INIT(ztest_vdev_attach_detach, 1, &zopt_sometimes), + ZTI_INIT(ztest_vdev_LUN_growth, 1, &zopt_rarely), + ZTI_INIT(ztest_vdev_add_remove, 1, &ztest_opts.zo_vdevtime), + ZTI_INIT(ztest_vdev_aux_add_remove, 1, &ztest_opts.zo_vdevtime), }; #define ZTEST_FUNCS (sizeof (ztest_info) / sizeof (ztest_info_t)) @@ -5583,12 +5584,9 @@ ztest_execute(int test, ztest_info_t *zi, uint64_t id) atomic_add_64(&zc->zc_count, 1); atomic_add_64(&zc->zc_time, functime); - if (ztest_opts.zo_verbose >= 4) { - Dl_info dli; - (void) dladdr((void *)zi->zi_func, &dli); + if (ztest_opts.zo_verbose >= 4) (void) printf("%6.2f sec in %s\n", - (double)functime / NANOSEC, dli.dli_sname); - } + (double)functime / NANOSEC, zi->zi_funcname); } static void * @@ -6490,15 +6488,12 @@ main(int argc, char **argv) (void) printf("%7s %9s %s\n", "-----", "----", "--------"); for (f = 0; f < ZTEST_FUNCS; f++) { - Dl_info dli; - zi = &ztest_info[f]; zc = ZTEST_GET_SHARED_CALLSTATE(f); print_time(zc->zc_time, timebuf); - (void) dladdr((void *)zi->zi_func, &dli); (void) printf("%7llu %9s %s\n", (u_longlong_t)zc->zc_count, timebuf, - dli.dli_sname); + zi->zi_funcname); } (void) printf("\n"); } |