All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Zorro Lang <zlang@redhat.com>
Cc: linux-xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH v2] xfs_io: support splice data between two files
Date: Wed, 4 Sep 2019 08:20:34 +0300	[thread overview]
Message-ID: <CAOQ4uxiHZzF5VdC-v3jzorc26RSUdou0v=Vx-XwYT3BAzSwyZA@mail.gmail.com> (raw)
In-Reply-To: <20190519150026.24626-1-zlang@redhat.com>

On Sun, May 19, 2019 at 8:31 PM Zorro Lang <zlang@redhat.com> wrote:
>
> Add splice command into xfs_io, by calling splice(2) system call.
>
> Signed-off-by: Zorro Lang <zlang@redhat.com>
> ---
>
> Hi,
>
> Thanks the reviewing from Eric.
>
> If 'length' or 'soffset' or 'length + soffset' out of source file
> range, splice hanging there. V2 fix this issue.
>
> Thanks,
> Zorro
>
>  io/Makefile       |   2 +-
>  io/init.c         |   1 +
>  io/io.h           |   1 +
>  io/splice.c       | 194 ++++++++++++++++++++++++++++++++++++++++++++++
>  man/man8/xfs_io.8 |  26 +++++++
>  5 files changed, 223 insertions(+), 1 deletion(-)
>  create mode 100644 io/splice.c
>
...
> +static void
> +splice_help(void)
> +{
> +       printf(_(
> +"\n"
> +" Splice a range of bytes from the given offset between files through pipe\n"
> +"\n"
> +" Example:\n"
> +" 'splice filename 0 4096 32768' - splice 32768 bytes from filename at offset\n"
> +"                                  0 into the open file at position 4096\n"
> +" 'splice filename' - splice all bytes from filename into the open file at\n"
> +" '                   position 0\n"
> +"\n"
> +" Copies data between one file and another.  Because this copying is done\n"
> +" within the kernel, sendfile does not need to transfer data to and from user\n"
> +" space.\n"
> +" -m -- SPLICE_F_MOVE flag, attempt to move pages instead of copying.\n"
> +" Offset and length in the source/destination file can be optionally specified.\n"
> +"\n"));
> +}
> +

splice belongs to a family of syscalls that can be used to transfer
data between files.

xfs_io already has several different sets of arguments for commands
from that family, providing different subset of control to user:

copy_range [-s src_off] [-d dst_off] [-l len] src_file | -f N -- Copy
a range of data between two files
dedupe infile src_off dst_off len -- dedupes a number of bytes at a
specified offset
reflink infile [src_off dst_off len] -- reflinks an entire file, or a
number of bytes at a specified offset
sendfile -i infile | -f N [off len] -- Transfer data directly between
file descriptors

I recently added '-f N' option to copy_range that was needed by a test.
Since you are adding a new command I must ask if it would not be
appropriate to add this capability in the first place.
Even if not added now, we should think about how the command options
would look like if we do want to add it later.
I would really hate to see a forth mutation of argument list...

An extreme solution would be to use the super set of all explicit options:

splice [-m] <-i infile | -f N> [-s src_off] [-d dst_off] [-l len]

We could later add optional support for -s -d -l -i flags to all of the
commands above and then we will have a unified format.

Personally, I have no objection that splice could also use the
"simple" arguments list as you implemented it, since reflink is
going to have to continue to support this usage anyway.

Thanks,
Amir.

  parent reply	other threads:[~2019-09-04  5:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-19 15:00 [PATCH v2] xfs_io: support splice data between two files Zorro Lang
2019-09-03 22:24 ` Darrick J. Wong
2019-09-04  5:20 ` Amir Goldstein [this message]
2019-09-04  5:47   ` Zorro Lang
2019-09-04 11:14     ` Amir Goldstein

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='CAOQ4uxiHZzF5VdC-v3jzorc26RSUdou0v=Vx-XwYT3BAzSwyZA@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zlang@redhat.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.