diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index f503ee6571..7735434206 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -2196,6 +2196,7 @@ dump_block_stats(spa_t *spa) * it's not part of any space map) is a double allocation, * reference to a freed block, or an unclaimed log block. */ + bzero(&zcb, sizeof(zdb_cb_t)); zdb_leak_init(spa, &zcb); /* diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index 1290ef2646..6d4e6742d2 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -5275,6 +5275,11 @@ ztest_run(ztest_shared_t *zs) } kernel_fini(); + + list_destroy(&zcl.zcl_callbacks); + mutex_destroy(&zcl.zcl_callbacks_lock); + rw_destroy(&zs->zs_name_lock); + mutex_destroy(&zs->zs_vdev_lock); } static void @@ -5345,12 +5350,8 @@ ztest_freeze(ztest_shared_t *zs) spa_close(spa, FTAG); kernel_fini(); - list_destroy(&zcl.zcl_callbacks); - - (void) mutex_destroy(&zcl.zcl_callbacks_lock); - - (void) rw_destroy(&zs->zs_name_lock); - (void) mutex_destroy(&zs->zs_vdev_lock); + rw_destroy(&zs->zs_name_lock); + mutex_destroy(&zs->zs_vdev_lock); } void @@ -5453,6 +5454,7 @@ main(int argc, char **argv) ztest_random_fd = open("/dev/urandom", O_RDONLY); + dprintf_setup(&argc, argv); process_options(argc, argv); /* Override location of zpool.cache */ diff --git a/lib/libzpool/include/sys/zfs_context.h b/lib/libzpool/include/sys/zfs_context.h index 5649d4762e..837ddce6ec 100644 --- a/lib/libzpool/include/sys/zfs_context.h +++ b/lib/libzpool/include/sys/zfs_context.h @@ -504,6 +504,7 @@ typedef struct callb_cpr { #define zone_dataset_visible(x, y) (1) #define INGLOBALZONE(z) (1) +extern char *kmem_vasprintf(const char *fmt, va_list adx); extern char *kmem_asprintf(const char *fmt, ...); #define strfree(str) kmem_free((str), strlen(str)+1) diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index c7bac38b8f..9d5b1c9547 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -1120,25 +1120,27 @@ ksiddomain_rele(ksiddomain_t *ksid) umem_free(ksid, sizeof (ksiddomain_t)); } -/* - * Do not change the length of the returned string; it must be freed - * with strfree(). - */ +char * +kmem_vasprintf(const char *fmt, va_list adx) +{ + char *buf = NULL; + va_list adx_copy; + + va_copy(adx_copy, adx); + VERIFY(vasprintf(&buf, fmt, adx_copy) != -1); + va_end(adx_copy); + + return (buf); +} + char * kmem_asprintf(const char *fmt, ...) { - int size; + char *buf = NULL; va_list adx; - char *buf; va_start(adx, fmt); - size = vsnprintf(NULL, 0, fmt, adx) + 1; - va_end(adx); - - buf = kmem_alloc(size, KM_SLEEP); - - va_start(adx, fmt); - size = vsnprintf(buf, size, fmt, adx); + VERIFY(vasprintf(&buf, fmt, adx) != -1); va_end(adx); return (buf); diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 51f912c142..8e0e910e08 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -727,7 +727,7 @@ dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, else dmu_buf_will_dirty(db, tx); - bcopy(buf, (char *)db->db_data + bufoff, tocpy); + (void) memcpy((char *)db->db_data + bufoff, buf, tocpy); if (tocpy == db->db_size) dmu_buf_fill_done(db, tx); diff --git a/module/zfs/spa_history.c b/module/zfs/spa_history.c index e5ceed9ff6..243f2b4ab3 100644 --- a/module/zfs/spa_history.c +++ b/module/zfs/spa_history.c @@ -432,6 +432,7 @@ log_internal(history_internal_events_t event, spa_t *spa, dmu_tx_t *tx, const char *fmt, va_list adx) { history_arg_t *ha; + va_list adx_copy; /* * If this is part of creating a pool, not everything is @@ -441,7 +442,9 @@ log_internal(history_internal_events_t event, spa_t *spa, return; ha = kmem_alloc(sizeof (history_arg_t), KM_SLEEP); - ha->ha_history_str = kmem_asprintf(fmt, adx); + va_copy(adx_copy, adx); + ha->ha_history_str = kmem_vasprintf(fmt, adx_copy); + va_end(adx_copy); ha->ha_log_type = LOG_INTERNAL; ha->ha_event = event; ha->ha_zone = NULL; diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c index 228fc14fff..90d98fb4d7 100644 --- a/module/zfs/spa_misc.c +++ b/module/zfs/spa_misc.c @@ -234,13 +234,8 @@ kmem_cache_t *spa_buffer_pool; int spa_mode_global; #ifdef ZFS_DEBUG -#if defined(_KERNEL) && defined(HAVE_SPL) -/* All filtering done by the SPL */ -int zfs_flags = ~0; -#else /* Everything except dprintf is on by default in debug builds */ int zfs_flags = ~ZFS_DEBUG_DPRINTF; -#endif #else int zfs_flags = 0; #endif diff --git a/module/zpios/zpios.c b/module/zpios/zpios.c index ff2db3b39b..9aa3b5c1bb 100644 --- a/module/zpios/zpios.c +++ b/module/zpios/zpios.c @@ -443,7 +443,7 @@ zpios_dmu_write(run_args_t *run_args, objset_t *os, uint64_t object, { struct dmu_tx *tx; int rc, how = TXG_WAIT; - int flags = 0; +// int flags = 0; if (run_args->flags & DMU_WRITE_NOWAIT) how = TXG_NOWAIT; @@ -467,10 +467,10 @@ zpios_dmu_write(run_args_t *run_args, objset_t *os, uint64_t object, break; } - if (run_args->flags & DMU_WRITE_ZC) - flags |= DMU_WRITE_ZEROCOPY; +// if (run_args->flags & DMU_WRITE_ZC) +// flags |= DMU_WRITE_ZEROCOPY; - dmu_write_impl(os, object, offset, size, buf, tx, flags); + dmu_write(os, object, offset, size, buf, tx); dmu_tx_commit(tx); return 0; @@ -482,8 +482,8 @@ zpios_dmu_read(run_args_t *run_args, objset_t *os, uint64_t object, { int flags = 0; - if (run_args->flags & DMU_READ_ZC) - flags |= DMU_READ_ZEROCOPY; +// if (run_args->flags & DMU_READ_ZC) +// flags |= DMU_READ_ZEROCOPY; if (run_args->flags & DMU_READ_NOPF) flags |= DMU_READ_NO_PREFETCH;