From c25b8f99f8dcbe898b81728e6a9dab107df4fc0b Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 11 Aug 2017 08:51:44 -0700 Subject: Simplify threads, mutexs, cvs and rwlocks * Simplify threads, mutexs, cvs and rwlocks * Update the zk_thread_create() function to use the same trick as Illumos. Specifically, cast the new pthread_t to a void pointer and return that as the kthread_t *. This avoids the issues associated with managing a wrapper structure and is safe as long as the callers never attempt to dereference it. * Update all function prototypes passed to pthread_create() to match the expected prototype. We were getting away this with before since the function were explicitly cast. * Replaced direct zk_thread_create() calls with thread_create() for code consistency. All consumers of libzpool now use the proper wrappers. * The mutex_held() calls were converted to MUTEX_HELD(). * Removed all mutex_owner() calls and retired the interface. Instead use MUTEX_HELD() which provides the same information and allows the implementation details to be hidden. In this case the use of the pthread_equals() function. * The kthread_t, kmutex_t, krwlock_t, and krwlock_t types had any non essential fields removed. In the case of kthread_t and kcondvar_t they could be directly typedef'd to pthread_t and pthread_cond_t respectively. * Removed all extra ASSERTS from the thread, mutex, rwlock, and cv wrapper functions. In practice, pthreads already provides the vast majority of checks as long as we check the return code. Removing this code from our wrappers help readability. * Added TS_JOINABLE state flag to pass to request a joinable rather than detached thread. This isn't a standard thread_create() state but it's the least invasive way to pass this information and is only used by ztest. TEST_ZTEST_TIMEOUT=3600 Chunwei Chen Reviewed-by: Tom Caputi Signed-off-by: Brian Behlendorf Closes #4547 Closes #5503 Closes #5523 Closes #6377 Closes #6495 --- module/zfs/txg.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'module/zfs/txg.c') diff --git a/module/zfs/txg.c b/module/zfs/txg.c index 65bd7f93a..8b1ec9c05 100644 --- a/module/zfs/txg.c +++ b/module/zfs/txg.c @@ -108,8 +108,8 @@ * now transition to the syncing state. */ -static void txg_sync_thread(dsl_pool_t *dp); -static void txg_quiesce_thread(dsl_pool_t *dp); +static void txg_sync_thread(void *dp); +static void txg_quiesce_thread(void *dp); int zfs_txg_timeout = 5; /* max seconds worth of delta per txg */ @@ -477,8 +477,9 @@ txg_wait_callbacks(dsl_pool_t *dp) } static void -txg_sync_thread(dsl_pool_t *dp) +txg_sync_thread(void *arg) { + dsl_pool_t *dp = (dsl_pool_t *)arg; spa_t *spa = dp->dp_spa; tx_state_t *tx = &dp->dp_tx; callb_cpr_t cpr; @@ -561,8 +562,9 @@ txg_sync_thread(dsl_pool_t *dp) } static void -txg_quiesce_thread(dsl_pool_t *dp) +txg_quiesce_thread(void *arg) { + dsl_pool_t *dp = (dsl_pool_t *)arg; tx_state_t *tx = &dp->dp_tx; callb_cpr_t cpr; -- cgit v1.2.3