diff options
author | Mark Fasheh <mfasheh@suse.de> | 2013-08-06 14:42:51 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-09-01 08:05:00 -0400 |
commit | 416161db9b63e353a8fb79d1369779175102fca1 (patch) | |
tree | 60627f898b85d3173e83222d12fc9f677e84730e /include/uapi | |
parent | 4b384318a74e38eb248f74f9a92a700d2ce841f1 (diff) |
btrfs: offline dedupe
This patch adds an ioctl, BTRFS_IOC_FILE_EXTENT_SAME which will try to
de-duplicate a list of extents across a range of files.
Internally, the ioctl re-uses code from the clone ioctl. This avoids
rewriting a large chunk of extent handling code.
Userspace passes in an array of file, offset pairs along with a length
argument. The ioctl will then (for each dedupe) do a byte-by-byte comparison
of the user data before deduping the extent. Status and number of bytes
deduped are returned for each operation.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Reviewed-by: Zach Brown <zab@redhat.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'include/uapi')
-rw-r--r-- | include/uapi/linux/btrfs.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h index 05aed70627e2..90d7bd9d839c 100644 --- a/include/uapi/linux/btrfs.h +++ b/include/uapi/linux/btrfs.h | |||
@@ -305,6 +305,31 @@ struct btrfs_ioctl_clone_range_args { | |||
305 | #define BTRFS_DEFRAG_RANGE_COMPRESS 1 | 305 | #define BTRFS_DEFRAG_RANGE_COMPRESS 1 |
306 | #define BTRFS_DEFRAG_RANGE_START_IO 2 | 306 | #define BTRFS_DEFRAG_RANGE_START_IO 2 |
307 | 307 | ||
308 | #define BTRFS_SAME_DATA_DIFFERS 1 | ||
309 | /* For extent-same ioctl */ | ||
310 | struct btrfs_ioctl_same_extent_info { | ||
311 | __s64 fd; /* in - destination file */ | ||
312 | __u64 logical_offset; /* in - start of extent in destination */ | ||
313 | __u64 bytes_deduped; /* out - total # of bytes we were able | ||
314 | * to dedupe from this file */ | ||
315 | /* status of this dedupe operation: | ||
316 | * 0 if dedup succeeds | ||
317 | * < 0 for error | ||
318 | * == BTRFS_SAME_DATA_DIFFERS if data differs | ||
319 | */ | ||
320 | __s32 status; /* out - see above description */ | ||
321 | __u32 reserved; | ||
322 | }; | ||
323 | |||
324 | struct btrfs_ioctl_same_args { | ||
325 | __u64 logical_offset; /* in - start of extent in source */ | ||
326 | __u64 length; /* in - length of extent */ | ||
327 | __u16 dest_count; /* in - total elements in info array */ | ||
328 | __u16 reserved1; | ||
329 | __u32 reserved2; | ||
330 | struct btrfs_ioctl_same_extent_info info[0]; | ||
331 | }; | ||
332 | |||
308 | struct btrfs_ioctl_space_info { | 333 | struct btrfs_ioctl_space_info { |
309 | __u64 flags; | 334 | __u64 flags; |
310 | __u64 total_bytes; | 335 | __u64 total_bytes; |
@@ -579,4 +604,7 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code) | |||
579 | struct btrfs_ioctl_get_dev_stats) | 604 | struct btrfs_ioctl_get_dev_stats) |
580 | #define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \ | 605 | #define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \ |
581 | struct btrfs_ioctl_dev_replace_args) | 606 | struct btrfs_ioctl_dev_replace_args) |
607 | #define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, \ | ||
608 | struct btrfs_ioctl_same_args) | ||
609 | |||
582 | #endif /* _UAPI_LINUX_BTRFS_H */ | 610 | #endif /* _UAPI_LINUX_BTRFS_H */ |