1

fs/pipe: remove unnecessary spinlock from pipe_write()

This reverts commit 8df441294d ("pipe: Check for ring full inside of
the spinlock in pipe_write()") which was obsoleted by commit
c73be61ced ("pipe: Add general notification queue support") because
now pipe_write() fails early with -EXDEV if there is a watch_queue.

Without a watch_queue, no notifications can be posted to the pipe and
mutex protection is enough, as can be seen in splice_pipe_to_pipe()
which does not use the spinlock either.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Message-Id: <20230921075755.1378787-3-max.kellermann@ionos.com>
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Max Kellermann 2023-09-21 09:57:54 +02:00 committed by Christian Brauner
parent b4bd6b4bac
commit dfaabf916b
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2

View File

@ -505,16 +505,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
* it, either the reader will consume it or it'll still * it, either the reader will consume it or it'll still
* be there for the next write. * be there for the next write.
*/ */
spin_lock_irq(&pipe->rd_wait.lock);
head = pipe->head;
if (pipe_full(head, pipe->tail, pipe->max_usage)) {
spin_unlock_irq(&pipe->rd_wait.lock);
continue;
}
pipe->head = head + 1; pipe->head = head + 1;
spin_unlock_irq(&pipe->rd_wait.lock);
/* Insert it into the buffer array */ /* Insert it into the buffer array */
buf = &pipe->bufs[head & mask]; buf = &pipe->bufs[head & mask];