Support post-3.13 kthread_create() semantics.

Provide spl_kthread_create() as a wrapper to the kernel's kthread_create()
to provide pre-3.13 semantics.  Re-try if the call is interrupted or if it
would have returned -ENOMEM.  Otherwise return NULL.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #339
This commit is contained in:
Tim Chase
2014-03-26 08:29:24 -05:00
committed by Brian Behlendorf
parent e19101e08f
commit 17a527cb0f
6 changed files with 38 additions and 9 deletions
+2 -1
View File
@@ -38,6 +38,7 @@
#include <linux/file_compat.h>
#include <linux/swap.h>
#include <sys/sysmacros.h>
#include <sys/thread.h>
#include <spl-debug.h>
#include <spl-trace.h>
#include <spl-ctl.h>
@@ -415,7 +416,7 @@ spl_debug_dumplog(int flags)
spl_debug_dumplog_internal(&dp);
} else {
tsk = kthread_create(spl_debug_dumplog_thread,(void *)&dp,"spl_debug");
tsk = spl_kthread_create(spl_debug_dumplog_thread,(void *)&dp,"spl_debug");
if (tsk == NULL)
return -ENOMEM;
+1 -1
View File
@@ -839,7 +839,7 @@ taskq_create(const char *name, int nthreads, pri_t pri,
tqt->tqt_tq = tq;
tqt->tqt_id = 0;
tqt->tqt_thread = kthread_create(taskq_thread, tqt,
tqt->tqt_thread = spl_kthread_create(taskq_thread, tqt,
"%s/%d", name, i);
if (tqt->tqt_thread) {
list_add(&tqt->tqt_thread_list, &tq->tq_thread_list);
+1 -1
View File
@@ -126,7 +126,7 @@ __thread_create(caddr_t stk, size_t stksize, thread_func_t func,
tp->tp_state = state;
tp->tp_pri = pri;
tsk = kthread_create(thread_generic_wrapper, (void *)tp,
tsk = spl_kthread_create(thread_generic_wrapper, (void *)tp,
"%s", tp->tp_name);
if (IS_ERR(tsk)) {
SERROR("Failed to create thread: %ld\n", PTR_ERR(tsk));