diff --git a/module/spl/spl-taskq.c b/module/spl/spl-taskq.c index 3605a0f3..6c1021b5 100644 --- a/module/spl/spl-taskq.c +++ b/module/spl/spl-taskq.c @@ -839,16 +839,26 @@ taskq_create(const char *name, int nthreads, pri_t pri, tqt->tqt_tq = tq; tqt->tqt_id = 0; + restart: tqt->tqt_thread = kthread_create(taskq_thread, tqt, "%s/%d", name, i); - if (tqt->tqt_thread) { + if (IS_ERR(tqt->tqt_thread)) { + /* Re-try on interrupted kthread_create() */ + if (signal_pending(current)) { + clear_thread_flag(TIF_SIGPENDING); + goto restart; + } + /* Re-try on a "real" ENOMEM */ + if (PTR_ERR(tqt->tqt_thread) == -ENOMEM) { + goto restart; + } + /* Return NULL on any other error */ + rc = 1; + } else { list_add(&tqt->tqt_thread_list, &tq->tq_thread_list); set_user_nice(tqt->tqt_thread, PRIO_TO_NICE(pri)); wake_up_process(tqt->tqt_thread); j++; - } else { - kmem_free(tqt, sizeof(taskq_thread_t)); - rc = 1; } } diff --git a/module/spl/spl-thread.c b/module/spl/spl-thread.c index 6b3bec50..13e6cd2b 100644 --- a/module/spl/spl-thread.c +++ b/module/spl/spl-thread.c @@ -126,9 +126,12 @@ __thread_create(caddr_t stk, size_t stksize, thread_func_t func, tp->tp_state = state; tp->tp_pri = pri; +retry: tsk = kthread_create(thread_generic_wrapper, (void *)tp, "%s", tp->tp_name); if (IS_ERR(tsk)) { + if (PTR_ERR(tsk) == -ENOMEM) + goto retry; SERROR("Failed to create thread: %ld\n", PTR_ERR(tsk)); SRETURN(NULL); }