From: walter harms <wharms-fPG8STNUNVg@public.gmane.org>
To: "Darrick J. Wong" <darrick.wong-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/2] man2: document FICLONE and FICLONERANGE
Date: Sat, 19 Mar 2016 18:04:54 +0100 [thread overview]
Message-ID: <56ED86B6.2000506@bfs.de> (raw)
In-Reply-To: <20160315164810.30909.3152.stgit-PTl6brltDGh4DFYR7WNSRA@public.gmane.org>
hi,
i tried to understand the man page and had some problems
(maybe because i am not an FS expert)
So far i understand the use case is to make a virtual copy
of a file (or range). but it works only on the same fs.
reading this:
https://lwn.net/Articles/331576/
I got the impression there is already a syscall ?
Since when is this function available ?
Perhaps you can add a simple use case so readers get a better
idea how/why to use this ?
just my 2 cents,
re,
wh
Am 15.03.2016 17:48, schrieb Darrick J. Wong:
> Document the FICLONE and FICLONERANGE ioctls, formerly known as the
> BTRFS_IOC_CLONE and BTRFS_IOC_CLONE_RANGE ioctls.
>
> Signed-off-by: Darrick J. Wong <darrick.wong-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> ---
> man2/ioctl_ficlone.2 | 1
> man2/ioctl_ficlonerange.2 | 124 +++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 125 insertions(+)
> create mode 100644 man2/ioctl_ficlone.2
> create mode 100644 man2/ioctl_ficlonerange.2
>
>
> diff --git a/man2/ioctl_ficlone.2 b/man2/ioctl_ficlone.2
> new file mode 100644
> index 0000000..19bb348
> --- /dev/null
> +++ b/man2/ioctl_ficlone.2
> @@ -0,0 +1 @@
> +.so man2/ioctl_ficlonerange.2
> diff --git a/man2/ioctl_ficlonerange.2 b/man2/ioctl_ficlonerange.2
> new file mode 100644
> index 0000000..c5c72aa
> --- /dev/null
> +++ b/man2/ioctl_ficlonerange.2
> @@ -0,0 +1,124 @@
> +.\" Copyright (C) 2016 Oracle. All rights reserved.
> +.\"
> +.\" %%%LICENSE_START(VERBATIM)
> +.\" This program is free software; you can redistribute it and/or
> +.\" modify it under the terms of the GNU General Public License as
> +.\" published by the Free Software Foundation.
> +.\"
> +.\" This program is distributed in the hope that it would be useful,
> +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
> +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +.\" GNU General Public License for more details.
> +.\"
> +.\" You should have received a copy of the GNU General Public License
> +.\" along with this program; if not, write the Free Software Foundation,
> +.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> +.\" %%%LICENSE_END
> +.TH IOCTL-FICLONERANGE 2 2016-02-10 "Linux" "Linux Programmer's Manual"
> +.SH NAME
> +ioctl_ficlonerange, ioctl_ficlone \- share some the data of one file with another file
> +.SH SYNOPSIS
> +.br
> +.B #include <sys/ioctl.h>
> +.br
> +.B #include <linux/fs.h>
> +.sp
> +.BI "int ioctl(int " dest_fd ", FICLONERANGE, struct file_clone_range * " arg );
> +.br
> +.BI "int ioctl(int " dest_fd ", FICLONE, int " src_fd );
> +.SH DESCRIPTION
> +If a filesystem supports files sharing physical storage between multiple
> +files ("reflink"), this
> +.BR ioctl (2)
> +system call can be used to make some of the data in the
> +.B src_fd
> +file appear in the
> +.B dest_fd
> +file by sharing the underlying storage, which is faster than making a separate
> +physical copy of the data. If a file write should occur to a shared region,
> +the filesystem must ensure that the changes remain private to the file being
> +written. This behavior is commonly referred to as "copy on write".
> +
> +This ioctl reflinks up to
> +.IR src_length
> +bytes from file descriptor
> +.IR src_fd
> +at offset
> +.IR src_offset
> +into the file
> +.IR dest_fd
> +at offset
> +.IR dest_offset ",
> +provided that both are files. This information is conveyed in a structure of
> +the following form:
> +.in +4n
> +.nf
> +
> +struct file_clone_range {
> + __s64 src_fd;
> + __u64 src_offset;
> + __u64 src_length;
> + __u64 dest_offset;
> +};
> +
> +.fi
> +.in
> +Clones are atomic with regards to concurrent writes, so no locks need to be
> +taken to obtain a consistent cloned copy.
> +
> +The FICLONE ioctl clones entire files.
> +.SH RETURN VALUE
> +On error, \-1 is returned, and
> +.I errno
> +is set to indicate the error.
> +.PP
> +.SH ERRORS
> +Error codes can be one of, but are not limited to, the following:
> +.TP
> +.B EXDEV
> +.IR dest_fd " and " src_fd
> +are not on the same mounted filesystem.
> +.TP
> +.B EISDIR
> +One of the files is a directory and the filesystem does not support shared
> +regions in directories.
> +.TP
> +.B EINVAL
> +The filesystem does not support reflinking the ranges of the given files. This
> +error can also appear if either file descriptor represents a device, fifo, or
> +socket. Disk filesystems generally require the offset and length arguments
> +to be aligned to the fundamental block size. XFS and btrfs do not support
> +overlapping reflink ranges in the same file.
> +.TP
> +.B EBADF
> +.IR src_fd
> +is not open for reading;
> +.IR dest_fd
> +is not open for writing or is open for append-only writes; or the filesystem
> +which
> +.IR src_fd
> +resides on does not support reflink.
> +.TP
> +.B EPERM
> +.IR dest_fd
> +is immutable.
> +.TP
> +.B ETXTBSY
> +One of the files is a swap file. Swap files cannot share storage.
> +.TP
> +.B EOPNOTSUPP
> +This can appear if the filesystem does not support reflinking either file
> +descriptor.
> +.SH NOTES
> +Because a copy on write operation requires the allocation of new storage, the
> +.B fallocate (2)
> +operation may un-share shared blocks to guarantee that subsequent writes will
> +not fail because of lack of disk space.
> +.SH CONFORMING TO
> +This API is Linux-specific. This ioctl was previously known as
> +.B BTRFS_IOC_CLONE_RANGE
> +and was private to btrfs.
> +.fi
> +.in
> +.SH SEE ALSO
> +.BR ioctl (2)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-man" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: mtk.manpages@gmail.com, linux-fsdevel@vger.kernel.org,
linux-api@vger.kernel.org, linux-man@vger.kernel.org
Subject: Re: [PATCH 1/2] man2: document FICLONE and FICLONERANGE
Date: Sat, 19 Mar 2016 18:04:54 +0100 [thread overview]
Message-ID: <56ED86B6.2000506@bfs.de> (raw)
In-Reply-To: <20160315164810.30909.3152.stgit@birch.djwong.org>
hi,
i tried to understand the man page and had some problems
(maybe because i am not an FS expert)
So far i understand the use case is to make a virtual copy
of a file (or range). but it works only on the same fs.
reading this:
https://lwn.net/Articles/331576/
I got the impression there is already a syscall ?
Since when is this function available ?
Perhaps you can add a simple use case so readers get a better
idea how/why to use this ?
just my 2 cents,
re,
wh
Am 15.03.2016 17:48, schrieb Darrick J. Wong:
> Document the FICLONE and FICLONERANGE ioctls, formerly known as the
> BTRFS_IOC_CLONE and BTRFS_IOC_CLONE_RANGE ioctls.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> man2/ioctl_ficlone.2 | 1
> man2/ioctl_ficlonerange.2 | 124 +++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 125 insertions(+)
> create mode 100644 man2/ioctl_ficlone.2
> create mode 100644 man2/ioctl_ficlonerange.2
>
>
> diff --git a/man2/ioctl_ficlone.2 b/man2/ioctl_ficlone.2
> new file mode 100644
> index 0000000..19bb348
> --- /dev/null
> +++ b/man2/ioctl_ficlone.2
> @@ -0,0 +1 @@
> +.so man2/ioctl_ficlonerange.2
> diff --git a/man2/ioctl_ficlonerange.2 b/man2/ioctl_ficlonerange.2
> new file mode 100644
> index 0000000..c5c72aa
> --- /dev/null
> +++ b/man2/ioctl_ficlonerange.2
> @@ -0,0 +1,124 @@
> +.\" Copyright (C) 2016 Oracle. All rights reserved.
> +.\"
> +.\" %%%LICENSE_START(VERBATIM)
> +.\" This program is free software; you can redistribute it and/or
> +.\" modify it under the terms of the GNU General Public License as
> +.\" published by the Free Software Foundation.
> +.\"
> +.\" This program is distributed in the hope that it would be useful,
> +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
> +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +.\" GNU General Public License for more details.
> +.\"
> +.\" You should have received a copy of the GNU General Public License
> +.\" along with this program; if not, write the Free Software Foundation,
> +.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> +.\" %%%LICENSE_END
> +.TH IOCTL-FICLONERANGE 2 2016-02-10 "Linux" "Linux Programmer's Manual"
> +.SH NAME
> +ioctl_ficlonerange, ioctl_ficlone \- share some the data of one file with another file
> +.SH SYNOPSIS
> +.br
> +.B #include <sys/ioctl.h>
> +.br
> +.B #include <linux/fs.h>
> +.sp
> +.BI "int ioctl(int " dest_fd ", FICLONERANGE, struct file_clone_range * " arg );
> +.br
> +.BI "int ioctl(int " dest_fd ", FICLONE, int " src_fd );
> +.SH DESCRIPTION
> +If a filesystem supports files sharing physical storage between multiple
> +files ("reflink"), this
> +.BR ioctl (2)
> +system call can be used to make some of the data in the
> +.B src_fd
> +file appear in the
> +.B dest_fd
> +file by sharing the underlying storage, which is faster than making a separate
> +physical copy of the data. If a file write should occur to a shared region,
> +the filesystem must ensure that the changes remain private to the file being
> +written. This behavior is commonly referred to as "copy on write".
> +
> +This ioctl reflinks up to
> +.IR src_length
> +bytes from file descriptor
> +.IR src_fd
> +at offset
> +.IR src_offset
> +into the file
> +.IR dest_fd
> +at offset
> +.IR dest_offset ",
> +provided that both are files. This information is conveyed in a structure of
> +the following form:
> +.in +4n
> +.nf
> +
> +struct file_clone_range {
> + __s64 src_fd;
> + __u64 src_offset;
> + __u64 src_length;
> + __u64 dest_offset;
> +};
> +
> +.fi
> +.in
> +Clones are atomic with regards to concurrent writes, so no locks need to be
> +taken to obtain a consistent cloned copy.
> +
> +The FICLONE ioctl clones entire files.
> +.SH RETURN VALUE
> +On error, \-1 is returned, and
> +.I errno
> +is set to indicate the error.
> +.PP
> +.SH ERRORS
> +Error codes can be one of, but are not limited to, the following:
> +.TP
> +.B EXDEV
> +.IR dest_fd " and " src_fd
> +are not on the same mounted filesystem.
> +.TP
> +.B EISDIR
> +One of the files is a directory and the filesystem does not support shared
> +regions in directories.
> +.TP
> +.B EINVAL
> +The filesystem does not support reflinking the ranges of the given files. This
> +error can also appear if either file descriptor represents a device, fifo, or
> +socket. Disk filesystems generally require the offset and length arguments
> +to be aligned to the fundamental block size. XFS and btrfs do not support
> +overlapping reflink ranges in the same file.
> +.TP
> +.B EBADF
> +.IR src_fd
> +is not open for reading;
> +.IR dest_fd
> +is not open for writing or is open for append-only writes; or the filesystem
> +which
> +.IR src_fd
> +resides on does not support reflink.
> +.TP
> +.B EPERM
> +.IR dest_fd
> +is immutable.
> +.TP
> +.B ETXTBSY
> +One of the files is a swap file. Swap files cannot share storage.
> +.TP
> +.B EOPNOTSUPP
> +This can appear if the filesystem does not support reflinking either file
> +descriptor.
> +.SH NOTES
> +Because a copy on write operation requires the allocation of new storage, the
> +.B fallocate (2)
> +operation may un-share shared blocks to guarantee that subsequent writes will
> +not fail because of lack of disk space.
> +.SH CONFORMING TO
> +This API is Linux-specific. This ioctl was previously known as
> +.B BTRFS_IOC_CLONE_RANGE
> +and was private to btrfs.
> +.fi
> +.in
> +.SH SEE ALSO
> +.BR ioctl (2)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-man" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-03-19 17:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-15 16:48 [PATCH v5 0/2] man-pages: document reflink/dedupe ioctls Darrick J. Wong
2016-03-15 16:48 ` Darrick J. Wong
[not found] ` <20160315164804.30909.83270.stgit-PTl6brltDGh4DFYR7WNSRA@public.gmane.org>
2016-03-15 16:48 ` [PATCH 1/2] man2: document FICLONE and FICLONERANGE Darrick J. Wong
2016-03-15 16:48 ` Darrick J. Wong
[not found] ` <20160315164810.30909.3152.stgit-PTl6brltDGh4DFYR7WNSRA@public.gmane.org>
2016-03-19 17:04 ` walter harms [this message]
2016-03-19 17:04 ` walter harms
[not found] ` <56ED86B6.2000506-fPG8STNUNVg@public.gmane.org>
2016-03-20 19:13 ` Darrick J. Wong
2016-03-20 19:13 ` Darrick J. Wong
2016-06-08 10:35 ` Michael Kerrisk (man-pages)
2016-06-08 10:35 ` Michael Kerrisk (man-pages)
2016-03-15 16:48 ` [PATCH 2/2] man2: document the FIDEDUPERANGE ioctl Darrick J. Wong
2016-03-15 16:48 ` Darrick J. Wong
[not found] ` <20160315164817.30909.61815.stgit-PTl6brltDGh4DFYR7WNSRA@public.gmane.org>
2016-06-08 10:35 ` Michael Kerrisk (man-pages)
2016-06-08 10:35 ` Michael Kerrisk (man-pages)
[not found] ` <97312350-d296-4e8a-3ae8-59e221a83ea9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-06-08 16:39 ` Darrick J. Wong
2016-06-08 16:39 ` Darrick J. Wong
2016-03-15 17:04 ` [PATCH v5 0/2] man-pages: document reflink/dedupe ioctls Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2015-12-19 8:56 [RFCv4 " Darrick J. Wong
2015-12-19 8:56 ` [PATCH 1/2] man2: document FICLONE and FICLONERANGE Darrick J. Wong
[not found] ` <20151219085613.12660.75735.stgit-PTl6brltDGh4DFYR7WNSRA@public.gmane.org>
2016-01-28 13:33 ` Christoph Hellwig
2016-01-28 13:33 ` Christoph Hellwig
[not found] ` <20160128133329.GA7610-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-01-28 19:18 ` Darrick J. Wong
2016-01-28 19:18 ` Darrick J. Wong
[not found] ` <20160128191814.GA5849-PTl6brltDGh4DFYR7WNSRA@public.gmane.org>
2016-03-15 8:27 ` Christoph Hellwig
2016-03-15 8:27 ` Christoph Hellwig
[not found] ` <20160315082737.GA1498-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-03-15 16:35 ` Darrick J. Wong
2016-03-15 16:35 ` Darrick J. Wong
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=56ED86B6.2000506@bfs.de \
--to=wharms-fpg8stnunvg@public.gmane.org \
--cc=darrick.wong-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/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.