diff options
author | Brian Behlendorf <[email protected]> | 2009-03-19 19:49:55 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2009-03-19 19:49:55 -0700 |
commit | 8cdcf1ef446166d61daf3fd269596a6f5a15cf28 (patch) | |
tree | 45867ddc3cffc22a7b0610a31a67b4844fc431fc /cmd | |
parent | 2518c98d9e448b93a35441a9c20f8de74aff7c2a (diff) | |
parent | f681a33757374bf7e2ebd9ff59070af9c541c759 (diff) |
Merge branch 'fix-branch' into refs/top-bases/zfs-branch
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zdb/zdb.c | 1 | ||||
-rw-r--r-- | cmd/zinject/translate.c | 2 | ||||
-rw-r--r-- | cmd/ztest/ztest.c | 115 |
3 files changed, 59 insertions, 59 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index fb9c4be6f..b0a40d6b0 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 4127339ed..d8654594d 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 019c57385..f1937362b 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 * @@ -851,7 +851,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); @@ -869,7 +869,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"); @@ -898,7 +898,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); @@ -954,7 +954,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); } /* @@ -980,7 +980,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); @@ -1040,7 +1040,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; } @@ -1133,7 +1133,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); } /* @@ -1149,7 +1149,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. @@ -1180,7 +1180,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 */ @@ -1279,7 +1279,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); @@ -1322,7 +1322,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); @@ -1404,7 +1404,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); } /* @@ -1418,7 +1418,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); @@ -1431,7 +1431,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); } /* @@ -1929,7 +1929,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; @@ -1980,7 +1980,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; @@ -2033,7 +2033,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 */ @@ -2052,13 +2052,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; @@ -2066,7 +2066,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; @@ -2446,7 +2446,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); @@ -2485,7 +2485,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); } /* @@ -2649,7 +2649,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); @@ -2701,7 +2701,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); } @@ -2939,18 +2939,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 * @@ -3040,16 +3037,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. @@ -3116,7 +3112,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, @@ -3165,7 +3162,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); @@ -3173,7 +3170,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", @@ -3184,7 +3181,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, @@ -3192,12 +3189,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); @@ -3216,14 +3213,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); @@ -3232,7 +3229,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); /* |