Skip to content

Commit e95aada

Browse files
lukas2511brauner
authored andcommitted
pipe: wakeup wr_wait after setting max_usage
Commit c73be61 ("pipe: Add general notification queue support") a regression was introduced that would lock up resized pipes under certain conditions. See the reproducer in [1]. The 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. Set @max_usage and @nr_accounted before waking writers if this isn't a watch queue. Link: https://bugzilla.kernel.org/show_bug.cgi?id=212295 [1] Link: https://lore.kernel.org/r/20231201-orchideen-modewelt-e009de4562c6@brauner Fixes: c73be61 ("pipe: Add general notification queue support") Reviewed-by: David Howells <dhowells@redhat.com> Cc: <stable@vger.kernel.org> Signed-off-by: Lukas Schauer <lukas@schauer.dev> [Christian Brauner <brauner@kernel.org>: rewrite to account for watch queues] Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 055ca83 commit e95aada

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/pipe.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,11 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
13241324
pipe->tail = tail;
13251325
pipe->head = head;
13261326

1327+
if (!pipe_has_watch_queue(pipe)) {
1328+
pipe->max_usage = nr_slots;
1329+
pipe->nr_accounted = nr_slots;
1330+
}
1331+
13271332
spin_unlock_irq(&pipe->rd_wait.lock);
13281333

13291334
/* This might have made more room for writers */
@@ -1375,8 +1380,6 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned int arg)
13751380
if (ret < 0)
13761381
goto out_revert_acct;
13771382

1378-
pipe->max_usage = nr_slots;
1379-
pipe->nr_accounted = nr_slots;
13801383
return pipe->max_usage * PAGE_SIZE;
13811384

13821385
out_revert_acct:

0 commit comments

Comments
 (0)