1ioctl_fideduperange(2)        System Calls Manual       ioctl_fideduperange(2)
2
3
4

NAME

6       ioctl_fideduperange - share some the data of one file with another file
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <linux/fs.h>      /* Definition of FIDEDUPERANGE and
13                                     FILE_DEDUPE_* constants*/
14       #include <sys/ioctl.h>
15
16       int ioctl(int src_fd, FIDEDUPERANGE, struct file_dedupe_range *arg);
17

DESCRIPTION

19       If  a filesystem supports files sharing physical storage between multi‐
20       ple files, this ioctl(2) operation can be used to make some of the data
21       in the src_fd file appear in the dest_fd file by sharing the underlying
22       storage if the file data is identical  ("deduplication").   Both  files
23       must  reside within the same filesystem.  This reduces storage consump‐
24       tion by allowing the filesystem to store one shared copy of  the  data.
25       If  a  file  write should occur to a shared region, the filesystem must
26       ensure that the changes remain private to the file being written.  This
27       behavior is commonly referred to as "copy on write".
28
29       This  ioctl  performs the "compare and share if identical" operation on
30       up to src_length bytes from file descriptor src_fd at  offset  src_off‐
31       set.   This  information  is  conveyed  in a structure of the following
32       form:
33
34           struct file_dedupe_range {
35               __u64 src_offset;
36               __u64 src_length;
37               __u16 dest_count;
38               __u16 reserved1;
39               __u32 reserved2;
40               struct file_dedupe_range_info info[0];
41           };
42
43       Deduplication is atomic with regards to concurrent writes, so no  locks
44       need to be taken to obtain a consistent deduplicated copy.
45
46       The fields reserved1 and reserved2 must be zero.
47
48       Destinations  for the deduplication operation are conveyed in the array
49       at the end of the structure.  The number of destinations  is  given  in
50       dest_count,  and the destination information is conveyed in the follow‐
51       ing form:
52
53           struct file_dedupe_range_info {
54               __s64 dest_fd;
55               __u64 dest_offset;
56               __u64 bytes_deduped;
57               __s32 status;
58               __u32 reserved;
59           };
60
61       Each deduplication operation targets src_length bytes in file  descrip‐
62       tor  dest_fd  at  offset dest_offset.  The field reserved must be zero.
63       During the call, src_fd must be open for reading and  dest_fd  must  be
64       open  for  writing.   The combined size of the struct file_dedupe_range
65       and the struct file_dedupe_range_info array must not exceed the  system
66       page  size.  The maximum size of src_length is filesystem dependent and
67       is typically 16 MiB.  This limit  will  be  enforced  silently  by  the
68       filesystem.   By  convention, the storage used by src_fd is mapped into
69       dest_fd and the previous contents in dest_fd are freed.
70
71       Upon successful completion of this ioctl, the number of bytes  success‐
72       fully  deduplicated  is returned in bytes_deduped and a status code for
73       the deduplication operation is returned in status.  If  even  a  single
74       byte in the range does not match, the deduplication request will be ig‐
75       nored and status set to FILE_DEDUPE_RANGE_DIFFERS.  The status code  is
76       set  to  FILE_DEDUPE_RANGE_SAME  for  success, a negative error code in
77       case of error, or FILE_DEDUPE_RANGE_DIFFERS if the data did not match.
78

RETURN VALUE

80       On error, -1 is returned, and errno is set to indicate the error.
81

ERRORS

83       Possible errors include (but are not limited to) the following:
84
85       EBADF  src_fd is not open for reading; dest_fd is not open for  writing
86              or  is  open  for  append-only  writes;  or the filesystem which
87              src_fd resides on does not support deduplication.
88
89       EINVAL The filesystem does not support deduplicating the ranges of  the
90              given files.  This error can also appear if either file descrip‐
91              tor represents a device, FIFO, or socket.  Disk filesystems gen‐
92              erally  require the offset and length arguments to be aligned to
93              the fundamental block size.  Neither Btrfs nor XFS support over‐
94              lapping deduplication ranges in the same file.
95
96       EISDIR One of the files is a directory and the filesystem does not sup‐
97              port shared regions in directories.
98
99       ENOMEM The kernel was unable to allocate sufficient memory  to  perform
100              the  operation or dest_count is so large that the input argument
101              description spans more than a single page of memory.
102
103       EOPNOTSUPP
104              This can appear if the filesystem does not support deduplicating
105              either  file  descriptor, or if either file descriptor refers to
106              special inodes.
107
108       EPERM  dest_fd is immutable.
109
110       ETXTBSY
111              One of the files is a swap file.  Swap files cannot share  stor‐
112              age.
113
114       EXDEV  dest_fd and src_fd are not on the same mounted filesystem.
115

VERSIONS

117       Some  filesystems may limit the amount of data that can be deduplicated
118       in a single call.
119

STANDARDS

121       Linux.
122

HISTORY

124       Linux 4.5.
125
126       It was previously known as BTRFS_IOC_FILE_EXTENT_SAME and  was  private
127       to Btrfs.
128

NOTES

130       Because  a copy-on-write operation requires the allocation of new stor‐
131       age, the fallocate(2) operation may unshare shared blocks to  guarantee
132       that subsequent writes will not fail because of lack of disk space.
133

SEE ALSO

135       ioctl(2)
136
137
138
139Linux man-pages 6.04              2023-03-30            ioctl_fideduperange(2)
Impressum