Skip to content

Commit

Permalink
Merge commit 'refs/top-bases/linux-kernel-disk' into linux-kernel-disk
Browse files Browse the repository at this point in the history
  • Loading branch information
behlendorf committed Aug 4, 2009
2 parents 118c1e9 + f88cbd6 commit f73936b
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 135 deletions.
3 changes: 0 additions & 3 deletions ChangeLog
Expand Up @@ -54,9 +54,6 @@
* module/zcommon/zfs_prop.c: Export new quota related symbols.
* lib/libzfs/libzfs_util.c: Increase buffer size for nvlist which
is needed for large configurations.
* lib/libzpool/kernel.c: Reimplement user kthreads based on pthread
thread specific data. This resolves previous scalabily concerns about
the cost of calling curthread which previously required a list walk.

* Bug fixes:
* lib/libspl/include/sys/zfs_debug.h: Removed duplicate file.
Expand Down
40 changes: 8 additions & 32 deletions cmd/ztest/ztest.c
Expand Up @@ -141,6 +141,7 @@ typedef struct ztest_args {
objset_t *za_os;
zilog_t *za_zilog;
kthread_t *za_thread;
kt_did_t za_threadid;
uint64_t za_instance;
uint64_t za_random;
uint64_t za_diroff;
Expand All @@ -156,7 +157,6 @@ typedef struct ztest_args {
ztest_block_tag_t za_wbt;
dmu_object_info_t za_doi;
dmu_buf_t *za_dbuf;
boolean_t za_exited;
} ztest_args_t;

typedef void ztest_func_t(ztest_args_t *);
Expand Down Expand Up @@ -253,8 +253,6 @@ typedef struct ztest_shared {
kmutex_t zs_sync_lock[ZTEST_SYNC_LOCKS];
uint64_t zs_seq[ZTEST_SYNC_LOCKS];
ztest_cb_list_t zs_cb_list;
kmutex_t zs_thr_lock;
kcondvar_t zs_thr_cv;
} ztest_shared_t;

static char ztest_dev_template[] = "%s/%s.%llua";
Expand All @@ -266,7 +264,6 @@ static int ztest_dump_core = 1;

static uint64_t metaslab_sz;
static boolean_t ztest_exiting;
static boolean_t resume_thr_exited;

extern uint64_t metaslab_gang_bang;
extern uint64_t metaslab_df_alloc_threshold;
Expand Down Expand Up @@ -3822,8 +3819,6 @@ ztest_resume_thread(void *arg)
ztest_resume(spa);
}

resume_thr_exited = B_TRUE;

thread_exit();
return (NULL);
}
Expand Down Expand Up @@ -3889,13 +3884,6 @@ ztest_thread(void *arg)
break;
}

mutex_enter(&zs->zs_thr_lock);
za->za_exited = B_TRUE;
mutex_exit(&zs->zs_thr_lock);

/* Announce that the thread has finished */
cv_broadcast(&zs->zs_thr_cv);

thread_exit();
return (NULL);
}
Expand All @@ -3912,14 +3900,13 @@ ztest_run(char *pool)
spa_t *spa;
char name[100];
kthread_t *resume_thread;
kt_did_t resume_id;

ztest_exiting = B_FALSE;

mutex_init(&zs->zs_vdev_lock, NULL, MUTEX_DEFAULT, NULL);
rw_init(&zs->zs_name_lock, NULL, RW_DEFAULT, NULL);
mutex_init(&zs->zs_cb_list.zcl_callbacks_lock,NULL,MUTEX_DEFAULT,NULL);
mutex_init(&zs->zs_thr_lock, NULL, MUTEX_DEFAULT, NULL);
cv_init(&zs->zs_thr_cv, NULL, CV_DEFAULT, NULL);

list_create(&zs->zs_cb_list.zcl_callbacks, sizeof (ztest_cb_data_t),
offsetof(ztest_cb_data_t, zcd_node));
Expand Down Expand Up @@ -3992,9 +3979,9 @@ ztest_run(char *pool)
/*
* Create a thread to periodically resume suspended I/O.
*/
resume_thr_exited = B_FALSE;
VERIFY3P((resume_thread = thread_create(NULL, 0, ztest_resume_thread,
spa, TS_RUN, NULL, 0, 0)), !=, NULL);
spa, THR_BOUND, NULL, 0, 0)), !=, NULL);
resume_id = resume_thread->t_tid;

/*
* Verify that we can safely inquire about about any object,
Expand Down Expand Up @@ -4070,18 +4057,13 @@ ztest_run(char *pool)
za[d].za_zilog = zil_open(za[d].za_os, NULL);
}

za[t].za_exited = B_FALSE;

VERIFY3P((za[t].za_thread = thread_create(NULL, 0, ztest_thread,
&za[t], TS_RUN, NULL, 0, 0)), !=, NULL);
&za[t], THR_BOUND, NULL, 0, 0)), !=, NULL);
za[t].za_threadid = za[t].za_thread->t_tid;
}

while (--t >= 0) {
mutex_enter(&zs->zs_thr_lock);
while (!za[t].za_exited)
cv_wait(&zs->zs_thr_cv, &zs->zs_thr_lock);
mutex_exit(&zs->zs_thr_lock);

VERIFY(thread_join(za[t].za_threadid, NULL, NULL) == 0);
if (t < zopt_datasets) {
zil_close(za[t].za_zilog);
dmu_objset_close(za[t].za_os);
Expand Down Expand Up @@ -4120,11 +4102,7 @@ ztest_run(char *pool)

/* Kill the resume thread */
ztest_exiting = B_TRUE;

/* Wait for the resume thread to exit */
while (!resume_thr_exited)
(void) poll(NULL, 0, 200);

VERIFY(thread_join(resume_id, NULL, NULL) == 0);
ztest_resume(spa);

/*
Expand All @@ -4140,8 +4118,6 @@ ztest_run(char *pool)

list_destroy(&zs->zs_cb_list.zcl_callbacks);

cv_destroy(&zs->zs_thr_cv);
mutex_destroy(&zs->zs_thr_lock);
mutex_destroy(&zs->zs_cb_list.zcl_callbacks_lock);
rw_destroy(&zs->zs_name_lock);
mutex_destroy(&zs->zs_vdev_lock);
Expand Down
20 changes: 10 additions & 10 deletions lib/libzpool/include/sys/zfs_context.h
Expand Up @@ -198,34 +198,34 @@ _NOTE(CONSTCOND) } while (0)
/*
* Threads
*/
#define THR_BOUND 0x00000001
#define TS_RUN 0x00000002

#define STACK_SIZE 8192 /* x86/x64 */

typedef void (*thread_func_t)(void);
typedef void (*thread_func_arg_t)(void *);
typedef void (*thread_func_t)(void *);
typedef pthread_t kt_did_t;

typedef struct kthread {
list_node_t t_node;
kt_did_t t_tid;
thread_func_t t_func;
void * t_arg;
pthread_attr_t t_attr;
} kthread_t;

/* XXX tsd_create()/tsd_destroy() missing */
#define tsd_get(key) pthread_getspecific(key)
#define tsd_set(key, val) pthread_setspecific(key, val)
#define curthread zk_thread_current()
#define thread_exit zk_thread_exit
#define thread_create(stk, stksize, func, arg, len, pp, state, pri) \
zk_thread_create(stk, stksize, (thread_func_t) func, arg, len, \
NULL, state, pri)
zk_thread_create(stk, stksize, (thread_func_t)func, arg, \
len, NULL, state, pri)
#define thread_join(tid, dtid, status) \
zk_thread_join(tid, dtid, status)

extern kthread_t *zk_thread_current(void);
extern void zk_thread_exit(void);
extern kthread_t *zk_thread_create(caddr_t stk, size_t stksize,
thread_func_t func, void *arg, size_t len,
void *pp, int state, pri_t pri);
extern int zk_thread_join(kt_did_t tid, kthread_t *dtid, void **status);

#define issig(why) (FALSE)
#define ISSIG(thr, why) (FALSE)
Expand Down Expand Up @@ -357,7 +357,7 @@ extern taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t);
extern taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t);
extern void taskq_destroy(taskq_t *);
extern void taskq_wait(taskq_t *);
extern int taskq_member(taskq_t *, kthread_t *);
extern int taskq_member(taskq_t *, void *);
extern void system_taskq_init(void);
extern void system_taskq_fini(void);

Expand Down

0 comments on commit f73936b

Please sign in to comment.