Lines Matching refs:thr

14 void bch2_thread_with_file_exit(struct thread_with_file *thr)
16 if (thr->task) {
17 kthread_stop(thr->task);
18 put_task_struct(thr->task);
22 int bch2_run_thread_with_file(struct thread_with_file *thr,
40 thr->ret = 0;
41 thr->task = kthread_create(fn, thr, "%s", name);
42 ret = PTR_ERR_OR_ZERO(thr->task);
51 file = anon_inode_getfile(name, fops, thr, fd_flags);
56 get_task_struct(thr->task);
57 wake_up_process(thr->task);
63 if (thr->task)
64 kthread_stop(thr->task);
101 static void thread_with_stdio_done(struct thread_with_stdio *thr)
103 thr->thr.done = true;
104 thr->stdio.done = true;
105 wake_up(&thr->stdio.input.wait);
106 wake_up(&thr->stdio.output.wait);
112 struct thread_with_stdio *thr =
113 container_of(file->private_data, struct thread_with_stdio, thr);
114 struct stdio_buf *buf = &thr->stdio.output;
119 ret = wait_event_interruptible(buf->wait, stdio_redirect_has_output(&thr->stdio));
122 } else if (!stdio_redirect_has_output(&thr->stdio))
151 struct thread_with_stdio *thr =
152 container_of(file->private_data, struct thread_with_stdio, thr);
154 thread_with_stdio_done(thr);
155 bch2_thread_with_file_exit(&thr->thr);
156 darray_exit(&thr->stdio.input.buf);
157 darray_exit(&thr->stdio.output.buf);
158 thr->ops->exit(thr);
165 struct thread_with_stdio *thr =
166 container_of(file->private_data, struct thread_with_stdio, thr);
167 struct stdio_buf *buf = &thr->stdio.input;
172 if (thr->thr.done) {
206 stdio_redirect_has_input_space(&thr->stdio));
217 struct thread_with_stdio *thr =
218 container_of(file->private_data, struct thread_with_stdio, thr);
220 poll_wait(file, &thr->stdio.output.wait, wait);
221 poll_wait(file, &thr->stdio.input.wait, wait);
225 if (stdio_redirect_has_output(&thr->stdio))
227 if (stdio_redirect_has_input_space(&thr->stdio))
229 if (thr->thr.done)
236 struct thread_with_stdio *thr =
237 container_of(file->private_data, struct thread_with_stdio, thr);
239 poll_wait(file, &thr->stdio.output.wait, wait);
243 if (stdio_redirect_has_output(&thr->stdio))
245 if (thr->thr.done)
252 struct thread_with_stdio *thr =
253 container_of(file->private_data, struct thread_with_stdio, thr);
255 return thr->thr.ret;
260 struct thread_with_stdio *thr =
261 container_of(file->private_data, struct thread_with_stdio, thr);
263 if (thr->ops->unlocked_ioctl)
264 return thr->ops->unlocked_ioctl(thr, cmd, p);
289 struct thread_with_stdio *thr = arg;
291 thr->thr.ret = thr->ops->fn(thr);
293 thread_with_stdio_done(thr);
297 void bch2_thread_with_stdio_init(struct thread_with_stdio *thr,
300 stdio_buf_init(&thr->stdio.input);
301 stdio_buf_init(&thr->stdio.output);
302 thr->ops = ops;
305 int __bch2_run_thread_with_stdio(struct thread_with_stdio *thr)
307 return bch2_run_thread_with_file(&thr->thr, &thread_with_stdio_fops, thread_with_stdio_fn);
310 int bch2_run_thread_with_stdio(struct thread_with_stdio *thr,
313 bch2_thread_with_stdio_init(thr, ops);
315 return __bch2_run_thread_with_stdio(thr);
318 int bch2_run_thread_with_stdout(struct thread_with_stdio *thr,
321 stdio_buf_init(&thr->stdio.input);
322 stdio_buf_init(&thr->stdio.output);
323 thr->ops = ops;
325 return bch2_run_thread_with_file(&thr->thr, &thread_with_stdout_fops, thread_with_stdio_fn);