~ubuntu-branches/ubuntu/wily/spl-linux/wily

« back to all changes in this revision

Viewing changes to module/spl/spl-thread.c

  • Committer: Package Import Robot
  • Author(s): Liang Guo
  • Date: 2014-07-31 15:16:53 UTC
  • Revision ID: package-import@ubuntu.com-20140731151653-tgao12alohj26jcs
Tags: upstream-0.6.3+git20140731
ImportĀ upstreamĀ versionĀ 0.6.3+git20140731

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
        tp->tp_state = state;
127
127
        tp->tp_pri   = pri;
128
128
 
129
 
        tsk = kthread_create(thread_generic_wrapper, (void *)tp,
 
129
        tsk = spl_kthread_create(thread_generic_wrapper, (void *)tp,
130
130
                             "%s", tp->tp_name);
131
131
        if (IS_ERR(tsk)) {
132
132
                SERROR("Failed to create thread: %ld\n", PTR_ERR(tsk));
137
137
        SRETURN((kthread_t *)tsk);
138
138
}
139
139
EXPORT_SYMBOL(__thread_create);
 
140
 
 
141
/*
 
142
 * spl_kthread_create - Wrapper providing pre-3.13 semantics for
 
143
 * kthread_create() in which it is not killable and less likely
 
144
 * to return -ENOMEM.
 
145
 */
 
146
struct task_struct *
 
147
spl_kthread_create(int (*func)(void *), void *data, const char namefmt[], ...)
 
148
{
 
149
        struct task_struct *tsk;
 
150
        va_list args;
 
151
        char name[TASK_COMM_LEN];
 
152
 
 
153
        va_start(args, namefmt);
 
154
        vsnprintf(name, sizeof(name), namefmt, args);
 
155
        va_end(args);
 
156
        do {
 
157
                tsk = kthread_create(func, data, "%s", name);
 
158
                if (IS_ERR(tsk)) {
 
159
                        if (signal_pending(current)) {
 
160
                                clear_thread_flag(TIF_SIGPENDING);
 
161
                                continue;
 
162
                        }
 
163
                        if (PTR_ERR(tsk) == -ENOMEM)
 
164
                                continue;
 
165
                        return (NULL);
 
166
                } else
 
167
                        return (tsk);
 
168
        } while (1);
 
169
}
 
170
EXPORT_SYMBOL(spl_kthread_create);