Re: [PATCH] splice: fix problem with sys_tee and SPLICE_F_NONBLOCK

From: Jens Axboe
Date: Tue Feb 19 2008 - 15:26:03 EST


On Tue, Feb 19 2008, Johann Felix Soden wrote:
> From: Johann Felix Soden <johfel@xxxxxxxxxxxxxxxxxxxxx>
>
> With SPLICE_F_NONBLOCK sys_tee should return number of duplicated bytes,
> not only -EAGAIN on success.

?

The current behaviour is to return bytes tee'd, or return -EAGAIN for
zero bytes if SPLICE_F_NONBLOCK is set. It doesn't return "-EAGAIN on
success", not sure what you mean there.

> This patch also solves the problem, which is described on
> http://article.gmane.org/gmane.linux.kernel/642502.
>
> Signed-off-by: Johann Felix Soden <johfel@xxxxxxxxxxxxxxxxxxxxx>
> ---
> fs/splice.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/fs/splice.c b/fs/splice.c
> index 9b559ee..184fd66 100644
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -1711,7 +1711,7 @@ static long do_tee(struct file *in, struct file *out, size_t len,
> ret = link_opipe_prep(opipe, flags);
> if (!ret) {
> ret = link_pipe(ipipe, opipe, len, flags);
> - if (!ret && (flags & SPLICE_F_NONBLOCK))
> + if (ret < 0 && (flags & SPLICE_F_NONBLOCK))
> ret = -EAGAIN;
> }
> }

Perhaps it's just me, but this doesn't make a lot of sense. You override
any other error with EAGAIN, hm? In fact the only < 0 value that
link_pipe() will return is -EPIPE, which is perfectly in sync with that
a pipe write will return if there are no readers attached.

--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/