Lines Matching refs:thr

14 void bch2_thread_with_file_exit(struct thread_with_file *thr)  in bch2_thread_with_file_exit()  argument
16 if (thr->task) { in bch2_thread_with_file_exit()
17 kthread_stop(thr->task); in bch2_thread_with_file_exit()
18 put_task_struct(thr->task); in bch2_thread_with_file_exit()
22 int bch2_run_thread_with_file(struct thread_with_file *thr, in bch2_run_thread_with_file() argument
40 thr->ret = 0; in bch2_run_thread_with_file()
41 thr->task = kthread_create(fn, thr, "%s", name); in bch2_run_thread_with_file()
42 ret = PTR_ERR_OR_ZERO(thr->task); in bch2_run_thread_with_file()
51 file = anon_inode_getfile(name, fops, thr, fd_flags); in bch2_run_thread_with_file()
56 get_task_struct(thr->task); in bch2_run_thread_with_file()
57 wake_up_process(thr->task); in bch2_run_thread_with_file()
63 if (thr->task) in bch2_run_thread_with_file()
64 kthread_stop(thr->task); in bch2_run_thread_with_file()
106 static void thread_with_stdio_done(struct thread_with_stdio *thr) in thread_with_stdio_done() argument
108 thr->thr.done = true; in thread_with_stdio_done()
109 thr->stdio.done = true; in thread_with_stdio_done()
110 wake_up(&thr->stdio.input.wait); in thread_with_stdio_done()
111 wake_up(&thr->stdio.output.wait); in thread_with_stdio_done()
117 struct thread_with_stdio *thr = in thread_with_stdio_read() local
118 container_of(file->private_data, struct thread_with_stdio, thr); in thread_with_stdio_read()
119 struct stdio_buf *buf = &thr->stdio.output; in thread_with_stdio_read()
124 ret = wait_event_interruptible(buf->wait, stdio_redirect_has_output(&thr->stdio)); in thread_with_stdio_read()
127 } else if (!stdio_redirect_has_output(&thr->stdio)) in thread_with_stdio_read()
156 struct thread_with_stdio *thr = in thread_with_stdio_release() local
157 container_of(file->private_data, struct thread_with_stdio, thr); in thread_with_stdio_release()
159 thread_with_stdio_done(thr); in thread_with_stdio_release()
160 bch2_thread_with_file_exit(&thr->thr); in thread_with_stdio_release()
161 darray_exit(&thr->stdio.input.buf); in thread_with_stdio_release()
162 darray_exit(&thr->stdio.output.buf); in thread_with_stdio_release()
163 thr->ops->exit(thr); in thread_with_stdio_release()
170 struct thread_with_stdio *thr = in thread_with_stdio_write() local
171 container_of(file->private_data, struct thread_with_stdio, thr); in thread_with_stdio_write()
172 struct stdio_buf *buf = &thr->stdio.input; in thread_with_stdio_write()
177 if (thr->thr.done) { in thread_with_stdio_write()
215 stdio_redirect_has_input_space(&thr->stdio)); in thread_with_stdio_write()
226 struct thread_with_stdio *thr = in thread_with_stdio_poll() local
227 container_of(file->private_data, struct thread_with_stdio, thr); in thread_with_stdio_poll()
229 poll_wait(file, &thr->stdio.output.wait, wait); in thread_with_stdio_poll()
230 poll_wait(file, &thr->stdio.input.wait, wait); in thread_with_stdio_poll()
234 if (stdio_redirect_has_output(&thr->stdio)) in thread_with_stdio_poll()
236 if (stdio_redirect_has_input_space(&thr->stdio)) in thread_with_stdio_poll()
238 if (thr->thr.done) in thread_with_stdio_poll()
245 struct thread_with_stdio *thr = in thread_with_stdout_poll() local
246 container_of(file->private_data, struct thread_with_stdio, thr); in thread_with_stdout_poll()
248 poll_wait(file, &thr->stdio.output.wait, wait); in thread_with_stdout_poll()
252 if (stdio_redirect_has_output(&thr->stdio)) in thread_with_stdout_poll()
254 if (thr->thr.done) in thread_with_stdout_poll()
261 struct thread_with_stdio *thr = in thread_with_stdio_flush() local
262 container_of(file->private_data, struct thread_with_stdio, thr); in thread_with_stdio_flush()
264 return thr->thr.ret; in thread_with_stdio_flush()
269 struct thread_with_stdio *thr = in thread_with_stdio_ioctl() local
270 container_of(file->private_data, struct thread_with_stdio, thr); in thread_with_stdio_ioctl()
272 if (thr->ops->unlocked_ioctl) in thread_with_stdio_ioctl()
273 return thr->ops->unlocked_ioctl(thr, cmd, p); in thread_with_stdio_ioctl()
296 struct thread_with_stdio *thr = arg; in thread_with_stdio_fn() local
298 thr->thr.ret = thr->ops->fn(thr); in thread_with_stdio_fn()
300 thread_with_stdio_done(thr); in thread_with_stdio_fn()
304 void bch2_thread_with_stdio_init(struct thread_with_stdio *thr, in bch2_thread_with_stdio_init() argument
307 stdio_buf_init(&thr->stdio.input); in bch2_thread_with_stdio_init()
308 stdio_buf_init(&thr->stdio.output); in bch2_thread_with_stdio_init()
309 thr->ops = ops; in bch2_thread_with_stdio_init()
312 int __bch2_run_thread_with_stdio(struct thread_with_stdio *thr) in __bch2_run_thread_with_stdio() argument
314 return bch2_run_thread_with_file(&thr->thr, &thread_with_stdio_fops, thread_with_stdio_fn); in __bch2_run_thread_with_stdio()
317 int bch2_run_thread_with_stdio(struct thread_with_stdio *thr, in bch2_run_thread_with_stdio() argument
320 bch2_thread_with_stdio_init(thr, ops); in bch2_run_thread_with_stdio()
322 return __bch2_run_thread_with_stdio(thr); in bch2_run_thread_with_stdio()
325 int bch2_run_thread_with_stdout(struct thread_with_stdio *thr, in bch2_run_thread_with_stdout() argument
328 stdio_buf_init(&thr->stdio.input); in bch2_run_thread_with_stdout()
329 stdio_buf_init(&thr->stdio.output); in bch2_run_thread_with_stdout()
330 thr->ops = ops; in bch2_run_thread_with_stdout()
332 return bch2_run_thread_with_file(&thr->thr, &thread_with_stdout_fops, thread_with_stdio_fn); in bch2_run_thread_with_stdout()