Skip to content

Commit

Permalink
splice: fix misuse of SPLICE_F_NONBLOCK
Browse files Browse the repository at this point in the history
SPLICE_F_NONBLOCK is clearly documented to only affect blocking on the
pipe.  In __generic_file_splice_read(), however, it causes an EAGAIN
if the page is currently being read.

This makes it impossible to write an application that only wants
failure if the pipe 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 fill it 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>
CC: stable@kernel.org
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
  • Loading branch information
Miklos Szeredi authored and Jens Axboe committed Aug 7, 2010
1 parent 7901d14 commit 6965031
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,17 +399,7 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
* 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
Expand Down

0 comments on commit 6965031

Please sign in to comment.