summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/spl/spl-thread.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/module/spl/spl-thread.c b/module/spl/spl-thread.c
index b0fa4d795..a74b9d9ac 100644
--- a/module/spl/spl-thread.c
+++ b/module/spl/spl-thread.c
@@ -137,3 +137,31 @@ __thread_create(caddr_t stk, size_t stksize, thread_func_t func,
SRETURN((kthread_t *)tsk);
}
EXPORT_SYMBOL(__thread_create);
+
+/*
+ * spl_kthread_create - Wrapper providing pre-3.13 semantics for
+ * kthread_create() in which it is not killable and less likely
+ * to return -ENOMEM.
+ */
+struct task_struct *
+spl_kthread_create(int (*func)(void *), void *data, const char namefmt[], ...)
+{
+ struct task_struct *tsk;
+ va_list args;
+
+ va_start(args, namefmt);
+ do {
+ tsk = kthread_create(func, data, namefmt, args);
+ if (IS_ERR(tsk)) {
+ if (signal_pending(current)) {
+ clear_thread_flag(TIF_SIGPENDING);
+ continue;
+ }
+ if (PTR_ERR(tsk) == -ENOMEM)
+ continue;
+ return (NULL);
+ } else
+ return (tsk);
+ } while (1);
+}
+EXPORT_SYMBOL(spl_kthread_create);