Skip to content

Commit df2e19a

Browse files
author
Kent Overstreet
committed
bcachefs: thread_with_stdio: fix spinning instead of exiting
bch2_stdio_redirect_vprintf() was missing a check for stdio->done, i.e. exiting. This caused the thread attempting to print to spin, and since it was being called from the kthread ran by thread_with_stdio, the userspace side hung as well. Change it to return -EPIPE - i.e. writing to a pipe that's been closed. Reported-by: Jan Solanti <jhs@psonet.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 6846100 commit df2e19a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/bcachefs/thread_with_file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,10 @@ ssize_t bch2_stdio_redirect_vprintf(struct stdio_redirect *stdio, bool nonblocki
455455
struct stdio_buf *buf = &stdio->output;
456456
unsigned long flags;
457457
ssize_t ret;
458-
459458
again:
459+
if (stdio->done)
460+
return -EPIPE;
461+
460462
spin_lock_irqsave(&buf->lock, flags);
461463
ret = bch2_darray_vprintf(&buf->buf, GFP_NOWAIT, fmt, args);
462464
spin_unlock_irqrestore(&buf->lock, flags);

0 commit comments

Comments
 (0)