[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <170873669018.1861398.16986816951760275853.stgit@frogsfrogsfrogs>
Date: Fri, 23 Feb 2024 17:15:49 -0800
From: "Darrick J. Wong" <djwong@...nel.org>
To: akpm@...ux-foundation.org, daniel@...o.nz, kent.overstreet@...ux.dev,
djwong@...nel.org
Cc: linux-xfs@...r.kernel.org, linux-bcachefs@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 08/10] thread_with_stdio: Mark completed in ->release()
From: Kent Overstreet <kent.overstreet@...ux.dev>
This fixes stdio_redirect_read() getting stuck, not noticing that the
pipe has been closed.
Signed-off-by: Kent Overstreet <kent.overstreet@...ux.dev>
Reviewed-by: Darrick J. Wong <djwong@...nel.org>
Signed-off-by: Darrick J. Wong <djwong@...nel.org>
---
lib/thread_with_file.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/lib/thread_with_file.c b/lib/thread_with_file.c
index 092996ca43fe7..f4946a437332a 100644
--- a/lib/thread_with_file.c
+++ b/lib/thread_with_file.c
@@ -201,6 +201,14 @@ EXPORT_SYMBOL_GPL(run_thread_with_file);
/* 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)
{
@@ -315,6 +323,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);
thread_with_file_exit(&thr->thr);
darray_exit(&thr->stdio.input.buf);
darray_exit(&thr->stdio.output.buf);
@@ -336,10 +345,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;
}
Powered by blists - more mailing lists