Skip to content

Commit

Permalink
OpenZFS 6871 - libzpool implementation of thread_create should enforc…
Browse files Browse the repository at this point in the history
…e length is 0

Porting notes:
- Several direct callers of zk_thread_create() are passing TS_RUN for the
length.  The `len` and `state` were inverted,this commit fixes them.

Authored by: Eli Rosenthal <[email protected]>
Reviewed by: Paul Dagnelie <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Approved by: Robert Mustacchi <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Ported-by: George Melikov [email protected]

OpenZFS-issue: https://www.illumos.org/issues/6871
OpenZFS-commit: openzfs/openzfs@8fc9228
Closes openzfs#5621
  • Loading branch information
gmelikov authored and behlendorf committed Jan 24, 2017
1 parent 9ef3906 commit e2a65ad
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/raidz_test/raidz_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ run_sweep(void)

VERIFY3P(zk_thread_create(NULL, 0,
(thread_func_t)sweep_thread,
(void *) opts, TS_RUN, NULL, 0, 0,
(void *) opts, 0, NULL, TS_RUN, 0,
PTHREAD_CREATE_JOINABLE), !=, NULL);
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/ztest/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -6240,7 +6240,7 @@ ztest_run(ztest_shared_t *zs)
* Create a thread to periodically resume suspended I/O.
*/
VERIFY3P((resume_thread = zk_thread_create(NULL, 0,
(thread_func_t)ztest_resume_thread, spa, TS_RUN, NULL, 0, 0,
(thread_func_t)ztest_resume_thread, spa, 0, NULL, TS_RUN, 0,
PTHREAD_CREATE_JOINABLE)), !=, NULL);

#if 0
Expand Down Expand Up @@ -6296,7 +6296,7 @@ ztest_run(ztest_shared_t *zs)

VERIFY3P(thread = zk_thread_create(NULL, 0,
(thread_func_t)ztest_thread,
(void *)(uintptr_t)t, TS_RUN, NULL, 0, 0,
(void *)(uintptr_t)t, 0, NULL, TS_RUN, 0,
PTHREAD_CREATE_JOINABLE), !=, NULL);
tid[t] = thread->t_tid;
}
Expand Down
2 changes: 1 addition & 1 deletion include/sys/zfs_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ typedef struct kthread {
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,
thread_func_t func, void *arg, uint64_t len,
proc_t *pp, int state, pri_t pri, int detachstate);
extern void zk_thread_join(kt_did_t tid);

Expand Down
3 changes: 2 additions & 1 deletion lib/libzpool/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,14 @@ zk_thread_helper(void *arg)

kthread_t *
zk_thread_create(caddr_t stk, size_t stksize, thread_func_t func, void *arg,
size_t len, proc_t *pp, int state, pri_t pri, int detachstate)
uint64_t len, proc_t *pp, int state, pri_t pri, int detachstate)
{
kthread_t *kt;
pthread_attr_t attr;
char *stkstr;

ASSERT0(state & ~TS_RUN);
ASSERT0(len);

kt = umem_zalloc(sizeof (kthread_t), UMEM_NOFAIL);
kt->t_func = func;
Expand Down

0 comments on commit e2a65ad

Please sign in to comment.