linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Schauer <lukas@schauer.dev>
To: linux-kernel@vger.kernel.org
Cc: Alan Cox <alan@redhat.com>, David Howells <dhowells@redhat.com>
Subject: [PATCH] fs/pipe: wakeup wr_wait after setting max_usage
Date: Wed, 24 Mar 2021 15:23:32 +0100	[thread overview]
Message-ID: <20210324142332.xfcuvuv2lfjkfznn@vista> (raw)

[-- Attachment #1: Type: text/plain, Size: 1342 bytes --]

With commit c73be61cede5882f9605a852414db559c0ebedfd a regression was
introduced that would lock up resized pipes under certain conditions.

In that commit resizing the pipe ring size was moved to a different
function, doing that moved the wakeup for pipe->wr_wait before actually
raising pipe->max_usage. If a pipe was full before the resize occured it
would result in the wakeup never actually triggering pipe_write,
resulting in a deadlock.

This patch moves the wakeup for pipe->wr_wait back to the original
pipe_set_size function, after pipe->max_usage has actually been updated.
---
 fs/pipe.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/pipe.c b/fs/pipe.c
index bfd946a9ad01..58916ad905b4 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1282,8 +1282,6 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
 	pipe->tail = tail;
 	pipe->head = head;

-	/* This might have made more room for writers */
-	wake_up_interruptible(&pipe->wr_wait);
 	return 0;
 }

@@ -1335,6 +1333,10 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg)

 	pipe->max_usage = nr_slots;
 	pipe->nr_accounted = nr_slots;
+
+	/* This might have made more room for writers */
+	wake_up_interruptible(&pipe->wr_wait);
+
 	return pipe->max_usage * PAGE_SIZE;

 out_revert_acct:
--
2.31.0



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

                 reply	other threads:[~2021-03-24 14:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210324142332.xfcuvuv2lfjkfznn@vista \
    --to=lukas@schauer.dev \
    --cc=alan@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).