summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2009-03-19 19:49:53 -0700
committerBrian Behlendorf <[email protected]>2009-03-19 19:49:53 -0700
commitf681a33757374bf7e2ebd9ff59070af9c541c759 (patch)
treeb28a33420c9d44f9a010c946e6821127f9b809a9 /cmd
parent97d74db43395c6b6ef5966afd2bd0d926566fbf7 (diff)
parent05cec154f5ea29ccd0238ea5c58ee3c2451e4779 (diff)
Merge commit 'refs/top-bases/fix-branch' into fix-branch
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zdb/zdb.c1
-rw-r--r--cmd/zinject/translate.c2
-rw-r--r--cmd/ztest/ztest.c115
3 files changed, 59 insertions, 59 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c
index 09f23c1b2..0ced25865 100644
--- a/cmd/zdb/zdb.c
+++ b/cmd/zdb/zdb.c
@@ -52,6 +52,7 @@
#include <sys/zfs_fuid.h>
#include <sys/arc.h>
#undef ZFS_MAXNAMELEN
+#undef verify
#include <libzfs.h>
const char cmdname[] = "zdb";
diff --git a/cmd/zinject/translate.c b/cmd/zinject/translate.c
index 0264aca6f..c85e024b6 100644
--- a/cmd/zinject/translate.c
+++ b/cmd/zinject/translate.c
@@ -25,6 +25,8 @@
#include <libzfs.h>
+#undef verify /* both libzfs.h and zfs_context.h want to define this */
+
#include <sys/zfs_context.h>
#include <errno.h>
diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c
index ce494fa79..4503a3d02 100644
--- a/cmd/ztest/ztest.c
+++ b/cmd/ztest/ztest.c
@@ -138,7 +138,7 @@ typedef struct ztest_args {
spa_t *za_spa;
objset_t *za_os;
zilog_t *za_zilog;
- pthread_t za_thread;
+ thread_t za_thread;
uint64_t za_instance;
uint64_t za_random;
uint64_t za_diroff;
@@ -221,18 +221,18 @@ ztest_info_t ztest_info[] = {
* Stuff we need to share writably between parent and child.
*/
typedef struct ztest_shared {
- pthread_mutex_t zs_vdev_lock;
- pthread_rwlock_t zs_name_lock;
- uint64_t zs_vdev_primaries;
- uint64_t zs_vdev_aux;
- uint64_t zs_enospc_count;
- hrtime_t zs_start_time;
- hrtime_t zs_stop_time;
- uint64_t zs_alloc;
- uint64_t zs_space;
- ztest_info_t zs_info[ZTEST_FUNCS];
- pthread_mutex_t zs_sync_lock[ZTEST_SYNC_LOCKS];
- uint64_t zs_seq[ZTEST_SYNC_LOCKS];
+ mutex_t zs_vdev_lock;
+ rwlock_t zs_name_lock;
+ uint64_t zs_vdev_primaries;
+ uint64_t zs_vdev_aux;
+ uint64_t zs_enospc_count;
+ hrtime_t zs_start_time;
+ hrtime_t zs_stop_time;
+ uint64_t zs_alloc;
+ uint64_t zs_space;
+ ztest_info_t zs_info[ZTEST_FUNCS];
+ mutex_t zs_sync_lock[ZTEST_SYNC_LOCKS];
+ uint64_t zs_seq[ZTEST_SYNC_LOCKS];
} ztest_shared_t;
static char ztest_dev_template[] = "%s/%s.%llua";
@@ -804,7 +804,7 @@ ztest_spa_create_destroy(ztest_args_t *za)
* Attempt to create an existing pool. It shouldn't matter
* what's in the nvroot; we should fail with EEXIST.
*/
- (void) pthread_rwlock_rdlock(&ztest_shared->zs_name_lock);
+ (void) rw_rdlock(&ztest_shared->zs_name_lock);
nvroot = make_vdev_root("/dev/bogus", NULL, 0, 0, 0, 0, 0, 1);
error = spa_create(za->za_pool, nvroot, NULL, NULL, NULL);
nvlist_free(nvroot);
@@ -820,7 +820,7 @@ ztest_spa_create_destroy(ztest_args_t *za)
fatal(0, "spa_destroy() = %d", error);
spa_close(spa, FTAG);
- (void) pthread_rwlock_unlock(&ztest_shared->zs_name_lock);
+ (void) rw_unlock(&ztest_shared->zs_name_lock);
}
static vdev_t *
@@ -850,7 +850,7 @@ ztest_vdev_add_remove(ztest_args_t *za)
nvlist_t *nvroot;
int error;
- (void) pthread_mutex_lock(&ztest_shared->zs_vdev_lock);
+ (void) mutex_lock(&ztest_shared->zs_vdev_lock);
spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER);
@@ -868,7 +868,7 @@ ztest_vdev_add_remove(ztest_args_t *za)
error = spa_vdev_add(spa, nvroot);
nvlist_free(nvroot);
- (void) pthread_mutex_unlock(&ztest_shared->zs_vdev_lock);
+ (void) mutex_unlock(&ztest_shared->zs_vdev_lock);
if (error == ENOSPC)
ztest_record_enospc("spa_vdev_add");
@@ -897,7 +897,7 @@ ztest_vdev_aux_add_remove(ztest_args_t *za)
aux = ZPOOL_CONFIG_L2CACHE;
}
- (void) pthread_mutex_lock(&ztest_shared->zs_vdev_lock);
+ (void) mutex_lock(&ztest_shared->zs_vdev_lock);
spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER);
@@ -953,7 +953,7 @@ ztest_vdev_aux_add_remove(ztest_args_t *za)
fatal(0, "spa_vdev_remove(%llu) = %d", guid, error);
}
- (void) pthread_mutex_unlock(&ztest_shared->zs_vdev_lock);
+ (void) mutex_unlock(&ztest_shared->zs_vdev_lock);
}
/*
@@ -979,7 +979,7 @@ ztest_vdev_attach_detach(ztest_args_t *za)
int oldvd_is_log;
int error, expected_error;
- (void) pthread_mutex_lock(&ztest_shared->zs_vdev_lock);
+ (void) mutex_lock(&ztest_shared->zs_vdev_lock);
spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER);
@@ -1039,7 +1039,7 @@ ztest_vdev_attach_detach(ztest_args_t *za)
if (error != 0 && error != ENODEV && error != EBUSY &&
error != ENOTSUP)
fatal(0, "detach (%s) returned %d", oldpath, error);
- (void) pthread_mutex_unlock(&ztest_shared->zs_vdev_lock);
+ (void) mutex_unlock(&ztest_shared->zs_vdev_lock);
return;
}
@@ -1132,7 +1132,7 @@ ztest_vdev_attach_detach(ztest_args_t *za)
(longlong_t)newsize, replacing, error, expected_error);
}
- (void) pthread_mutex_unlock(&ztest_shared->zs_vdev_lock);
+ (void) mutex_unlock(&ztest_shared->zs_vdev_lock);
}
/*
@@ -1148,7 +1148,7 @@ ztest_vdev_LUN_growth(ztest_args_t *za)
size_t fsize;
int fd;
- (void) pthread_mutex_lock(&ztest_shared->zs_vdev_lock);
+ (void) mutex_lock(&ztest_shared->zs_vdev_lock);
/*
* Pick a random leaf vdev.
@@ -1179,7 +1179,7 @@ ztest_vdev_LUN_growth(ztest_args_t *za)
(void) close(fd);
}
- (void) pthread_mutex_unlock(&ztest_shared->zs_vdev_lock);
+ (void) mutex_unlock(&ztest_shared->zs_vdev_lock);
}
/* ARGSUSED */
@@ -1278,7 +1278,7 @@ ztest_dmu_objset_create_destroy(ztest_args_t *za)
uint64_t seq;
uint64_t objects;
- (void) pthread_rwlock_rdlock(&ztest_shared->zs_name_lock);
+ (void) rw_rdlock(&ztest_shared->zs_name_lock);
(void) snprintf(name, 100, "%s/%s_temp_%llu", za->za_pool, za->za_pool,
(u_longlong_t)za->za_instance);
@@ -1321,7 +1321,7 @@ ztest_dmu_objset_create_destroy(ztest_args_t *za)
if (error) {
if (error == ENOSPC) {
ztest_record_enospc("dmu_objset_create");
- (void) pthread_rwlock_unlock(&ztest_shared->zs_name_lock);
+ (void) rw_unlock(&ztest_shared->zs_name_lock);
return;
}
fatal(0, "dmu_objset_create(%s) = %d", name, error);
@@ -1403,7 +1403,7 @@ ztest_dmu_objset_create_destroy(ztest_args_t *za)
if (error)
fatal(0, "dmu_objset_destroy(%s) = %d", name, error);
- (void) pthread_rwlock_unlock(&ztest_shared->zs_name_lock);
+ (void) rw_unlock(&ztest_shared->zs_name_lock);
}
/*
@@ -1417,7 +1417,7 @@ ztest_dmu_snapshot_create_destroy(ztest_args_t *za)
char snapname[100];
char osname[MAXNAMELEN];
- (void) pthread_rwlock_rdlock(&ztest_shared->zs_name_lock);
+ (void) rw_rdlock(&ztest_shared->zs_name_lock);
dmu_objset_name(os, osname);
(void) snprintf(snapname, 100, "%s@%llu", osname,
(u_longlong_t)za->za_instance);
@@ -1430,7 +1430,7 @@ ztest_dmu_snapshot_create_destroy(ztest_args_t *za)
ztest_record_enospc("dmu_take_snapshot");
else if (error != 0 && error != EEXIST)
fatal(0, "dmu_take_snapshot() = %d", error);
- (void) pthread_rwlock_unlock(&ztest_shared->zs_name_lock);
+ (void) rw_unlock(&ztest_shared->zs_name_lock);
}
/*
@@ -1928,7 +1928,7 @@ ztest_dmu_write_parallel(ztest_args_t *za)
int bs = ZTEST_DIROBJ_BLOCKSIZE;
int do_free = 0;
uint64_t off, txg, txg_how;
- pthread_mutex_t *lp;
+ mutex_t *lp;
char osname[MAXNAMELEN];
char iobuf[SPA_MAXBLOCKSIZE];
blkptr_t blk = { 0 };
@@ -1978,7 +1978,7 @@ ztest_dmu_write_parallel(ztest_args_t *za)
txg = dmu_tx_get_txg(tx);
lp = &ztest_shared->zs_sync_lock[b];
- (void) pthread_mutex_lock(lp);
+ (void) mutex_lock(lp);
wbt->bt_objset = dmu_objset_id(os);
wbt->bt_object = ZTEST_DIROBJ;
@@ -2031,7 +2031,7 @@ ztest_dmu_write_parallel(ztest_args_t *za)
dmu_write(os, ZTEST_DIROBJ, off, btsize, wbt, tx);
}
- (void) pthread_mutex_unlock(lp);
+ (void) mutex_unlock(lp);
if (ztest_random(1000) == 0)
(void) poll(NULL, 0, 1); /* open dn_notxholds window */
@@ -2050,13 +2050,13 @@ ztest_dmu_write_parallel(ztest_args_t *za)
/*
* dmu_sync() the block we just wrote.
*/
- (void) pthread_mutex_lock(lp);
+ (void) mutex_lock(lp);
blkoff = P2ALIGN_TYPED(off, bs, uint64_t);
error = dmu_buf_hold(os, ZTEST_DIROBJ, blkoff, FTAG, &db);
za->za_dbuf = db;
if (error) {
- (void) pthread_mutex_unlock(lp);
+ (void) mutex_unlock(lp);
return;
}
blkoff = off - blkoff;
@@ -2064,7 +2064,7 @@ ztest_dmu_write_parallel(ztest_args_t *za)
dmu_buf_rele(db, FTAG);
za->za_dbuf = NULL;
- (void) pthread_mutex_unlock(lp);
+ (void) mutex_unlock(lp);
if (error)
return;
@@ -2444,7 +2444,7 @@ ztest_dsl_prop_get_set(ztest_args_t *za)
char osname[MAXNAMELEN];
int error;
- (void) pthread_rwlock_rdlock(&ztest_shared->zs_name_lock);
+ (void) rw_rdlock(&ztest_shared->zs_name_lock);
dmu_objset_name(os, osname);
@@ -2483,7 +2483,7 @@ ztest_dsl_prop_get_set(ztest_args_t *za)
}
}
- (void) pthread_rwlock_unlock(&ztest_shared->zs_name_lock);
+ (void) rw_unlock(&ztest_shared->zs_name_lock);
}
/*
@@ -2647,7 +2647,7 @@ ztest_spa_rename(ztest_args_t *za)
int error;
spa_t *spa;
- (void) pthread_rwlock_wrlock(&ztest_shared->zs_name_lock);
+ (void) rw_wrlock(&ztest_shared->zs_name_lock);
oldname = za->za_pool;
newname = umem_alloc(strlen(oldname) + 5, UMEM_NOFAIL);
@@ -2699,7 +2699,7 @@ ztest_spa_rename(ztest_args_t *za)
umem_free(newname, strlen(newname) + 1);
- (void) pthread_rwlock_unlock(&ztest_shared->zs_name_lock);
+ (void) rw_unlock(&ztest_shared->zs_name_lock);
}
@@ -2937,18 +2937,15 @@ ztest_spa_import_export(char *oldname, char *newname)
nvlist_free(config);
}
-static void *
-ztest_resume(void *arg)
+static void
+ztest_resume(spa_t *spa)
{
- spa_t *spa = arg;
-
if (spa_suspended(spa)) {
spa_vdev_state_enter(spa);
vdev_clear(spa, NULL);
(void) spa_vdev_state_exit(spa, NULL, 0);
zio_resume(spa);
}
- return (NULL);
}
static void *
@@ -3038,16 +3035,15 @@ ztest_run(char *pool)
ztest_args_t *za;
spa_t *spa;
char name[100];
- pthread_t resume_tid;
+ thread_t resume_tid;
ztest_exiting = B_FALSE;
- (void) pthread_mutex_init(&zs->zs_vdev_lock, NULL);
- (void) pthread_rwlock_init(&zs->zs_name_lock, NULL);
+ (void) _mutex_init(&zs->zs_vdev_lock, USYNC_THREAD, NULL);
+ (void) rwlock_init(&zs->zs_name_lock, USYNC_THREAD, NULL);
for (t = 0; t < ZTEST_SYNC_LOCKS; t++)
- (void) pthread_mutex_init(&zs->zs_sync_lock[t], NULL);
-
+ (void) _mutex_init(&zs->zs_sync_lock[t], USYNC_THREAD, NULL);
/*
* Destroy one disk before we even start.
@@ -3114,7 +3110,8 @@ ztest_run(char *pool)
/*
* Create a thread to periodically resume suspended I/O.
*/
- VERIFY(pthread_create(&resume_tid, NULL, ztest_resume_thread, spa)==0);
+ VERIFY(thr_create(0, 0, ztest_resume_thread, spa, THR_BOUND,
+ &resume_tid) == 0);
/*
* Verify that we can safely inquire about about any object,
@@ -3163,7 +3160,7 @@ ztest_run(char *pool)
if (t < zopt_datasets) {
int test_future = FALSE;
- (void) pthread_rwlock_rdlock(&ztest_shared->zs_name_lock);
+ (void) rw_rdlock(&ztest_shared->zs_name_lock);
(void) snprintf(name, 100, "%s/%s_%d", pool, pool, d);
error = dmu_objset_create(name, DMU_OST_OTHER, NULL, 0,
ztest_create_cb, NULL);
@@ -3171,7 +3168,7 @@ ztest_run(char *pool)
test_future = TRUE;
} else if (error == ENOSPC) {
zs->zs_enospc_count++;
- (void) pthread_rwlock_unlock(&ztest_shared->zs_name_lock);
+ (void) rw_unlock(&ztest_shared->zs_name_lock);
break;
} else if (error != 0) {
fatal(0, "dmu_objset_create(%s) = %d",
@@ -3182,7 +3179,7 @@ ztest_run(char *pool)
if (error)
fatal(0, "dmu_objset_open('%s') = %d",
name, error);
- (void) pthread_rwlock_unlock(&ztest_shared->zs_name_lock);
+ (void) rw_unlock(&ztest_shared->zs_name_lock);
if (test_future)
ztest_dmu_check_future_leak(&za[t]);
zil_replay(za[d].za_os, za[d].za_os,
@@ -3190,12 +3187,12 @@ ztest_run(char *pool)
za[d].za_zilog = zil_open(za[d].za_os, NULL);
}
- VERIFY(pthread_create(&za[t].za_thread, NULL, ztest_thread,
- &za[t]) == 0);
+ VERIFY(thr_create(0, 0, ztest_thread, &za[t], THR_BOUND,
+ &za[t].za_thread) == 0);
}
while (--t >= 0) {
- VERIFY(pthread_join(za[t].za_thread, NULL) == 0);
+ VERIFY(thr_join(za[t].za_thread, NULL, NULL) == 0);
if (t < zopt_datasets) {
zil_close(za[t].za_zilog);
dmu_objset_close(za[t].za_os);
@@ -3214,14 +3211,14 @@ ztest_run(char *pool)
* If we had out-of-space errors, destroy a random objset.
*/
if (zs->zs_enospc_count != 0) {
- (void) pthread_rwlock_rdlock(&ztest_shared->zs_name_lock);
+ (void) rw_rdlock(&ztest_shared->zs_name_lock);
d = (int)ztest_random(zopt_datasets);
(void) snprintf(name, 100, "%s/%s_%d", pool, pool, d);
if (zopt_verbose >= 3)
(void) printf("Destroying %s to free up space\n", name);
(void) dmu_objset_find(name, ztest_destroy_cb, &za[d],
DS_FIND_SNAPSHOTS | DS_FIND_CHILDREN);
- (void) pthread_rwlock_unlock(&ztest_shared->zs_name_lock);
+ (void) rw_unlock(&ztest_shared->zs_name_lock);
}
txg_wait_synced(spa_get_dsl(spa), 0);
@@ -3230,7 +3227,7 @@ ztest_run(char *pool)
/* Kill the resume thread */
ztest_exiting = B_TRUE;
- VERIFY(pthread_join(resume_tid, NULL) == 0);
+ VERIFY(thr_join(resume_tid, NULL, NULL) == 0);
ztest_resume(spa);
/*