2016-06-09 17:36:58 +00:00
|
|
|
.\" Copyright (c) 2016, Oracle. All rights reserved.
|
2016-03-15 16:48:17 +00:00
|
|
|
.\"
|
2016-06-09 17:36:58 +00:00
|
|
|
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
|
|
|
|
.\" This is free documentation; you can redistribute it and/or
|
2016-03-15 16:48:17 +00:00
|
|
|
.\" modify it under the terms of the GNU General Public License as
|
2016-06-09 17:36:58 +00:00
|
|
|
.\" published by the Free Software Foundation; either version 2 of
|
|
|
|
.\" the License, or (at your option) any later version.
|
2016-03-15 16:48:17 +00:00
|
|
|
.\"
|
2016-06-09 17:36:58 +00:00
|
|
|
.\" The GNU General Public License's references to "object code"
|
|
|
|
.\" and "executables" are to be interpreted as the output of any
|
|
|
|
.\" document formatting or typesetting system, including
|
|
|
|
.\" intermediate and printed output.
|
|
|
|
.\"
|
|
|
|
.\" This manual is distributed in the hope that it will be useful,
|
2016-03-15 16:48:17 +00:00
|
|
|
.\" 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.
|
|
|
|
.\"
|
2016-06-09 17:36:58 +00:00
|
|
|
.\" You should have received a copy of the GNU General Public
|
|
|
|
.\" License along with this manual; if not, see
|
|
|
|
.\" <http://www.gnu.org/licenses/>.
|
2016-03-15 16:48:17 +00:00
|
|
|
.\" %%%LICENSE_END
|
ldd.1, localedef.1, add_key.2, chroot.2, clone.2, fork.2, futex.2, get_mempolicy.2, get_robust_list.2, getitimer.2, getpriority.2, ioctl.2, ioctl_ficlonerange.2, ioctl_fideduperange.2, kcmp.2, kill.2, lookup_dcookie.2, mmap.2, mount.2, open.2, pciconfig_read.2, perf_event_open.2, prctl.2, process_vm_readv.2, ptrace.2, quotactl.2, recv.2, setfsgid.2, setfsuid.2, sysinfo.2, umask.2, umount.2, unshare.2, utimensat.2, wait.2, assert.3, fmax.3, fmin.3, getauxval.3, inet_pton.3, malloc_hook.3, memmem.3, mkdtemp.3, mktemp.3, printf.3, strcasecmp.3, strcat.3, strtoul.3, strxfrm.3, console_codes.4, console_ioctl.4, lirc.4, tty.4, vcs.4, charmap.5, elf.5, locale.5, proc.5, repertoiremap.5, utmp.5, capabilities.7, cgroup_namespaces.7, cgroups.7, charsets.7, cp1251.7, cp1252.7, credentials.7, feature_test_macros.7, iso_8859-1.7, iso_8859-15.7, iso_8859-5.7, koi8-r.7, koi8-u.7, man-pages.7, mount_namespaces.7, namespaces.7, netlink.7, pid_namespaces.7, unix.7, user_namespaces.7, utf-8.7: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-07-17 16:07:58 +00:00
|
|
|
.TH IOCTL-FIDEDUPERANGE 2 2016-07-17 "Linux" "Linux Programmer's Manual"
|
2016-03-15 16:48:17 +00:00
|
|
|
.SH NAME
|
|
|
|
ioctl_fideduperange \- 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 " src_fd ", FIDEDUPERANGE, struct file_dedupe_range * " arg );
|
|
|
|
.SH DESCRIPTION
|
|
|
|
If a filesystem supports files sharing physical storage between multiple
|
|
|
|
files, this
|
|
|
|
.BR ioctl (2)
|
2016-06-08 10:31:06 +00:00
|
|
|
operation can be used to make some of the data in the
|
2016-03-15 16:48:17 +00:00
|
|
|
.B src_fd
|
|
|
|
file appear in the
|
|
|
|
.B dest_fd
|
|
|
|
file by sharing the underlying storage if the file data is identical
|
2016-06-08 10:24:06 +00:00
|
|
|
("deduplication").
|
2016-06-08 16:40:40 +00:00
|
|
|
Both files must reside within the same filesystem.
|
2016-06-08 10:24:06 +00:00
|
|
|
This reduces storage consumption by allowing the filesystem
|
|
|
|
to store one shared copy of the data.
|
|
|
|
If a file write should occur to a shared
|
2016-03-15 16:48:17 +00:00
|
|
|
region, the filesystem must ensure that the changes remain private to the file
|
2016-06-08 10:24:06 +00:00
|
|
|
being written.
|
|
|
|
This behavior is commonly referred to as "copy on write".
|
2016-03-15 16:48:17 +00:00
|
|
|
|
|
|
|
This ioctl performs the "compare and share if identical" operation on up to
|
|
|
|
.IR src_length
|
|
|
|
bytes from file descriptor
|
|
|
|
.IR src_fd
|
|
|
|
at offset
|
|
|
|
.IR src_offset ".
|
|
|
|
This information is conveyed in a structure of the following form:
|
|
|
|
.in +4n
|
|
|
|
.nf
|
|
|
|
|
|
|
|
struct file_dedupe_range {
|
2016-06-08 10:31:06 +00:00
|
|
|
__u64 src_offset;
|
|
|
|
__u64 src_length;
|
|
|
|
__u16 dest_count;
|
|
|
|
__u16 reserved1;
|
|
|
|
__u32 reserved2;
|
|
|
|
struct file_dedupe_range_info info[0];
|
2016-03-15 16:48:17 +00:00
|
|
|
};
|
|
|
|
.fi
|
|
|
|
.in
|
|
|
|
Deduplication is atomic with regards to concurrent writes, so no locks need to
|
|
|
|
be taken to obtain a consistent deduplicated copy.
|
|
|
|
|
2016-07-17 16:08:45 +00:00
|
|
|
The fields
|
2016-03-15 16:48:17 +00:00
|
|
|
.IR reserved1 " and " reserved2
|
|
|
|
must be zero.
|
|
|
|
|
|
|
|
Destinations for the deduplication operation are conveyed in the array at the
|
2016-06-08 10:24:06 +00:00
|
|
|
end of the structure.
|
|
|
|
The number of destinations is given in
|
2016-03-15 16:48:17 +00:00
|
|
|
.IR dest_count ",
|
|
|
|
and the destination information is conveyed in the following form:
|
|
|
|
|
|
|
|
.in +4n
|
|
|
|
.nf
|
|
|
|
struct file_dedupe_range_info {
|
|
|
|
__s64 dest_fd;
|
|
|
|
__u64 dest_offset;
|
|
|
|
__u64 bytes_deduped;
|
|
|
|
__s32 status;
|
|
|
|
__u32 reserved;
|
|
|
|
};
|
|
|
|
|
|
|
|
.fi
|
|
|
|
.in
|
|
|
|
|
|
|
|
Each deduplication operation targets
|
|
|
|
.IR length
|
|
|
|
bytes in file descriptor
|
|
|
|
.IR dest_fd
|
|
|
|
at offset
|
2016-10-18 01:54:35 +00:00
|
|
|
.IR dest_offset ".
|
2016-03-15 16:48:17 +00:00
|
|
|
The field
|
|
|
|
.IR reserved
|
|
|
|
must be zero.
|
2016-10-18 01:54:35 +00:00
|
|
|
During the call,
|
|
|
|
.IR src_fd
|
|
|
|
must be open for reading and
|
|
|
|
.IR dest_fd
|
|
|
|
must be open for writing.
|
|
|
|
For any call to this ioctl, there may not be more than 65,536
|
|
|
|
requests attached; each request may not exceed 16MiB.
|
|
|
|
By convention, the storage used by
|
|
|
|
.IR src_fd
|
|
|
|
is mapped into
|
|
|
|
.IR dest_fd
|
|
|
|
and the previous contents in
|
|
|
|
.IR dest_fd
|
|
|
|
are freed.
|
2016-03-15 16:48:17 +00:00
|
|
|
|
|
|
|
Upon successful completion of this ioctl, the number of bytes successfully
|
|
|
|
deduplicated is returned in
|
|
|
|
.IR bytes_deduped
|
|
|
|
and a status code for the deduplication operation is returned in
|
|
|
|
.IR status ".
|
2016-10-18 01:54:35 +00:00
|
|
|
If even a single byte in the range does not match, the deduplication
|
|
|
|
request will be ignored and
|
|
|
|
.IR status
|
|
|
|
set to
|
|
|
|
.BR FILE_DEDUPE_RANGE_DIFFERS .
|
2016-03-15 16:48:17 +00:00
|
|
|
The
|
|
|
|
.IR status
|
|
|
|
code is set to
|
2016-10-18 01:54:35 +00:00
|
|
|
.B FILE_DEDUPE_RANGE_SAME
|
2016-03-15 16:48:17 +00:00
|
|
|
for success, a negative error code in case of error, or
|
|
|
|
.B FILE_DEDUPE_RANGE_DIFFERS
|
|
|
|
if the data did not match.
|
|
|
|
|
|
|
|
.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
|
2016-08-07 16:59:43 +00:00
|
|
|
.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 deduplication.
|
2016-03-15 16:48:17 +00:00
|
|
|
.TP
|
|
|
|
.B EINVAL
|
|
|
|
The filesystem does not support deduplicating the ranges of the given files.
|
2016-06-08 10:31:06 +00:00
|
|
|
This error can also appear if either file descriptor represents
|
|
|
|
a device, FIFO, or socket.
|
2016-06-08 10:24:06 +00:00
|
|
|
Disk filesystems generally require the offset and length arguments
|
|
|
|
to be aligned to the fundamental block size.
|
2016-06-08 10:31:06 +00:00
|
|
|
Neither Btrfs nor XFS support
|
2016-03-15 16:48:17 +00:00
|
|
|
overlapping deduplication ranges in the same file.
|
|
|
|
.TP
|
2016-08-07 16:59:43 +00:00
|
|
|
.B EISDIR
|
|
|
|
One of the files is a directory and the filesystem does not support shared
|
|
|
|
regions in directories.
|
|
|
|
.TP
|
|
|
|
.B EOPNOTSUPP
|
|
|
|
This can appear if the filesystem does not support deduplicating either file
|
2016-10-18 01:54:35 +00:00
|
|
|
descriptor, or if either file descriptor refers to special inodes.
|
2016-03-15 16:48:17 +00:00
|
|
|
.TP
|
|
|
|
.B EPERM
|
|
|
|
.IR dest_fd
|
|
|
|
is immutable.
|
|
|
|
.TP
|
|
|
|
.B ETXTBSY
|
2016-06-08 10:24:06 +00:00
|
|
|
One of the files is a swap file.
|
|
|
|
Swap files cannot share storage.
|
2016-03-15 16:48:17 +00:00
|
|
|
.TP
|
2016-08-07 16:59:43 +00:00
|
|
|
.B EXDEV
|
|
|
|
.IR dest_fd " and " src_fd
|
|
|
|
are not on the same mounted filesystem.
|
2016-06-08 10:31:58 +00:00
|
|
|
.SH VERSIONS
|
|
|
|
This ioctl operation first appeared in Linux 4.5.
|
|
|
|
It was previously known as
|
2016-06-08 10:31:06 +00:00
|
|
|
.B BTRFS_IOC_FILE_EXTENT_SAME
|
|
|
|
and was private to Btrfs.
|
2016-06-08 10:31:58 +00:00
|
|
|
.SH CONFORMING TO
|
|
|
|
This API is Linux-specific.
|
2016-03-15 16:48:17 +00:00
|
|
|
.SH NOTES
|
2016-06-08 10:31:06 +00:00
|
|
|
Because a copy-on-write operation requires the allocation of new storage, the
|
|
|
|
.BR fallocate (2)
|
|
|
|
operation may unshare shared blocks to guarantee that subsequent writes will
|
2016-03-15 16:48:17 +00:00
|
|
|
not fail because of lack of disk space.
|
|
|
|
|
|
|
|
Some filesystems may limit the amount of data that can be deduplicated in a
|
|
|
|
single call.
|
|
|
|
.SH SEE ALSO
|
|
|
|
.BR ioctl (2)
|