mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 2/5] splice: Add sync parameter to wakeup_pipe_readers()
Date: Sun, 29 Sep 2013 15:14:35 +0900	[thread overview]
Message-ID: <1380435278-10927-2-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1380435278-10927-1-git-send-email-namhyung@kernel.org>

So that it can handle both of sync and normal wakeups in one place.
And convert a sync user to reuse it.

Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 fs/splice.c |   21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/fs/splice.c b/fs/splice.c
index 320cc65585b2..77251152e1b8 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -164,11 +164,15 @@ static const struct pipe_buf_operations user_page_pipe_buf_ops = {
 	.get = generic_pipe_buf_get,
 };
 
-static void wakeup_pipe_readers(struct pipe_inode_info *pipe)
+static void wakeup_pipe_readers(struct pipe_inode_info *pipe, bool sync)
 {
 	smp_mb();
-	if (waitqueue_active(&pipe->wait))
-		wake_up_interruptible(&pipe->wait);
+	if (waitqueue_active(&pipe->wait)) {
+		if (sync)
+			wake_up_interruptible_sync(&pipe->wait);
+		else
+			wake_up_interruptible(&pipe->wait);
+	}
 	kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
 }
 
@@ -243,10 +247,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
 		}
 
 		if (do_wakeup) {
-			smp_mb();
-			if (waitqueue_active(&pipe->wait))
-				wake_up_interruptible_sync(&pipe->wait);
-			kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
+			wakeup_pipe_readers(pipe, true);
 			do_wakeup = 0;
 		}
 
@@ -258,7 +259,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
 	pipe_unlock(pipe);
 
 	if (do_wakeup)
-		wakeup_pipe_readers(pipe);
+		wakeup_pipe_readers(pipe, false);
 
 	while (page_nr < spd_pages)
 		spd->spd_release(spd, page_nr++);
@@ -1931,7 +1932,7 @@ retry:
 	 * If we put data in the output pipe, wakeup any potential readers.
 	 */
 	if (ret > 0)
-		wakeup_pipe_readers(opipe);
+		wakeup_pipe_readers(opipe, false);
 
 	if (input_wakeup)
 		wakeup_pipe_writers(ipipe);
@@ -2012,7 +2013,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
 	 * If we put data in the output pipe, wakeup any potential readers.
 	 */
 	if (ret > 0)
-		wakeup_pipe_readers(opipe);
+		wakeup_pipe_readers(opipe, false);
 
 	return ret;
 }
-- 
1.7.9.2


  reply	other threads:[~2013-09-29  6:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-29  6:14 [PATCH 1/5] splice: Get rid of duplicate f_mode checks Namhyung Kim
2013-09-29  6:14 ` Namhyung Kim [this message]
2013-09-29  6:14 ` [PATCH 3/5] splice: Add sync parameter to wakeup_pipe_writers() Namhyung Kim
2013-09-29  6:14 ` [PATCH 4/5] splice: Use sync wakeup for splice_from_pipe_next() Namhyung Kim
2013-09-29  6:14 ` [PATCH 5/5] pipe: Do not use sync wakeups Namhyung Kim

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=1380435278-10927-2-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®