All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: Jens Axboe <axboe@kernel.dk>
Cc: xiaosuo@gmail.com, tim.gardner@canonical.com,
	torvalds@linux-foundation.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] splice: fix misuse of SPLICE_F_NONBLOCK
Date: Tue, 29 Jun 2010 13:13:05 +0200	[thread overview]
Message-ID: <E1OTYkT-0008Io-0s@pomaz-ex.szeredi.hu> (raw)
In-Reply-To: <E1OTYfk-0008GY-PJ@pomaz-ex.szeredi.hu> (message from Miklos Szeredi on Tue, 29 Jun 2010 13:08:12 +0200)

From: Miklos Szeredi <mszeredi@suse.cz>

SPLICE_F_NONBLOCK is clearly documented to only affect blocking on the
destination pipe and not on the source file.

In __generic_file_splice_read(), however, it returns EAGAIN if the
page is currently being read.

This makes it impossible to write an application that only wants
failure if the pipe buffer is full.  For example if the same process
is handling both ends of a pipe and isn't otherwise able to determine
whether a splice to the pipe will fit or not.

We could make the read non-blocking on O_NONBLOCK or some other splice
flag, but for now this is the simplest fix.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 fs/splice.c |   12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

Index: linux-2.6/fs/splice.c
===================================================================
--- linux-2.6.orig/fs/splice.c	2010-06-29 12:46:30.000000000 +0200
+++ linux-2.6/fs/splice.c	2010-06-29 12:46:32.000000000 +0200
@@ -399,17 +399,7 @@ __generic_file_splice_read(struct file *
 		 * If the page isn't uptodate, we may need to start io on it
 		 */
 		if (!PageUptodate(page)) {
-			/*
-			 * If in nonblock mode then dont block on waiting
-			 * for an in-flight io page
-			 */
-			if (flags & SPLICE_F_NONBLOCK) {
-				if (!trylock_page(page)) {
-					error = -EAGAIN;
-					break;
-				}
-			} else
-				lock_page(page);
+			lock_page(page);
 
 			/*
 			 * Page was truncated, or invalidated by the

  parent reply	other threads:[~2010-06-29 11:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-29 11:08 [PATCH 0/3] splice fixes Miklos Szeredi
2010-06-29 11:09 ` [PATCH 1/3] splice: direct_splice_actor() should not use pos in sd Miklos Szeredi
2010-06-29 11:10 ` [PATCH 2/3] splice: check f_mode for seekable file Miklos Szeredi
2010-06-29 11:13 ` Miklos Szeredi [this message]
2010-06-29 11:15 ` [PATCH 0/3] splice fixes Jens Axboe
2010-06-29 12:05   ` Miklos Szeredi
2010-06-29 12:05     ` Jens Axboe
2010-07-07 20:38       ` Andrew Morton
2010-07-08 13:36         ` Jens Axboe
2010-07-08 13:38           ` Jens Axboe
2010-07-08 17:25             ` Andrew Morton
2010-07-08 17:30               ` Jens Axboe

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=E1OTYkT-0008Io-0s@pomaz-ex.szeredi.hu \
    --to=miklos@szeredi.hu \
    --cc=axboe@kernel.dk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tim.gardner@canonical.com \
    --cc=torvalds@linux-foundation.org \
    --cc=xiaosuo@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.