mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vegard Nossum <vegard.nossum@gmail.com>
To: Max Kellermann <mk@cm4all.com>
Cc: linux-kernel@vger.kernel.org, jens.axboe@oracle.com, w@1wt.eu
Subject: Re: [splice PATCH 3/3] splice: added support for pipe-to-pipe  splice()
Date: Thu, 30 Apr 2009 15:35:24 +0200	[thread overview]
Message-ID: <19f34abd0904300635v2d8af8eeh1a8aa9cf6f4eb1c9@mail.gmail.com> (raw)
In-Reply-To: <20090430120354.5689.75240.stgit@rabbit.intern.cm-ag>

2009/4/30 Max Kellermann <mk@cm4all.com>:
> This patch enables the splice() system call to copy buffers from one
> pipe to another.  This obvious and trivial use case for splice() was
> not supported until now.
>
> It reuses the functions link_ipipe_prep() and link_opipe_prep() from
> the tee() system call implementation.
>
> Signed-off-by: Max Kellermann <mk@cm4all.com>
> ---
>
>  fs/splice.c |  166 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 166 insertions(+), 0 deletions(-)
>
> diff --git a/fs/splice.c b/fs/splice.c
> index 96135eb..f69a88f 100644
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -902,6 +902,156 @@ ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, struct file *out,
>
>  EXPORT_SYMBOL(generic_splice_sendpage);
>
> +static int link_ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags);
> +static int link_opipe_prep(struct pipe_inode_info *pipe, unsigned int flags);
> +
> +/**
> + * Returns the nth pipe buffer after the current one.
> + *
> + * @i the buffer index, relative to the current one
> + */
> +static inline struct pipe_buffer *
> +pipe_buffer_at(struct pipe_inode_info *pipe, unsigned i)
> +{
> +       BUG_ON(i >= PIPE_BUFFERS);
> +
> +       return pipe->bufs + ((pipe->curbuf + i) & (PIPE_BUFFERS - 1));
> +}
> +
> +/**
> + * Splice pages from one pipe to another.
> + *
> + * @ipipe the input pipe
> + * @opipe the output pipe
> + * @len the maximum number of bytes to move
> + * @flags splice modifier flags
> + */
> +static long do_splice_pipes(struct pipe_inode_info *ipipe,
> +                           struct pipe_inode_info *opipe,
> +                           size_t len, unsigned int flags)
> +{
> +       struct pipe_buffer *ibuf, *obuf;
> +       long ret;
> +       int do_wakeup = 0;
> +
> +       if (ipipe == opipe)
> +               /* cannot splice a pipe to itself */
> +               return -EINVAL;
> +

What happens if you splice two pipes, in separate threads, to each other? :-)


Vegard

  reply	other threads:[~2009-04-30 13:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-30 12:03 [splice PATCH 1/3] splice: use "long" for tee() return values Max Kellermann
2009-04-30 12:03 ` [splice PATCH 2/3] tee: don't return 0 when another task drains/fills a pipe Max Kellermann
2009-04-30 12:03 ` [splice PATCH 3/3] splice: added support for pipe-to-pipe splice() Max Kellermann
2009-04-30 13:35   ` Vegard Nossum [this message]
2009-04-30 13:50     ` Max Kellermann

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=19f34abd0904300635v2d8af8eeh1a8aa9cf6f4eb1c9@mail.gmail.com \
    --to=vegard.nossum@gmail.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mk@cm4all.com \
    --cc=w@1wt.eu \
    /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®