diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-02-08 20:27:06 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-03-13 21:22:00 -0400 |
commit | 8f9320d3a3993e76c8097fb8567ba5f3eb2cb91b (patch) | |
tree | 677879026ebb25f06554a1874369a4434f04ed80 /fs/bcachefs/thread_with_file.c | |
parent | 032b3fd0571a8d7e22c7d8c97bdfc76f17717de2 (diff) |
bcachefs: thread_with_stdio: Mark completed in ->release()
This fixes stdio_redirect_read() getting stuck, not noticing that the
pipe has been closed.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/thread_with_file.c')
-rw-r--r-- | fs/bcachefs/thread_with_file.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/bcachefs/thread_with_file.c b/fs/bcachefs/thread_with_file.c index dde9679b68b4..83186e824e88 100644 --- a/fs/bcachefs/thread_with_file.c +++ b/fs/bcachefs/thread_with_file.c @@ -97,6 +97,14 @@ static void stdio_buf_init(struct stdio_buf *buf) /* thread_with_stdio */ +static void thread_with_stdio_done(struct thread_with_stdio *thr) +{ + thr->thr.done = true; + thr->stdio.done = true; + wake_up(&thr->stdio.input.wait); + wake_up(&thr->stdio.output.wait); +} + static ssize_t thread_with_stdio_read(struct file *file, char __user *ubuf, size_t len, loff_t *ppos) { @@ -142,6 +150,7 @@ static int thread_with_stdio_release(struct inode *inode, struct file *file) struct thread_with_stdio *thr = container_of(file->private_data, struct thread_with_stdio, thr); + thread_with_stdio_done(thr); bch2_thread_with_file_exit(&thr->thr); darray_exit(&thr->stdio.input.buf); darray_exit(&thr->stdio.output.buf); @@ -235,10 +244,7 @@ static int thread_with_stdio_fn(void *arg) thr->fn(thr); - thr->thr.done = true; - thr->stdio.done = true; - wake_up(&thr->stdio.input.wait); - wake_up(&thr->stdio.output.wait); + thread_with_stdio_done(thr); return 0; } |