Hoist the btrfs EXTENT_SAME ioctl up to the VFS and make the name more systematic (FIDEDUPERANGE).
Showing the changes to include/uapi (1 of 5 files). Show all
Unified · Split
| @@ -52,6 +52,35 @@ struct fstrim_range { · 51 unmodified lines | ||
| 52 | 52 | __u64 minlen; |
| 53 | 53 | }; |
| 54 | 54 | |
| 55 | +/* extent-same (dedupe) ioctls; these MUST match the btrfs ioctl definitions */ | |
| 56 | +#define FILE_DEDUPE_RANGE_SAME 0 | |
| 57 | +#define FILE_DEDUPE_RANGE_DIFFERS 1 | |
| 58 | + | |
| 59 | +/* from struct btrfs_ioctl_file_extent_same_info */ | |
| 60 | +struct file_dedupe_range_info { | |
| 61 | + __s64 dest_fd; /* in - destination file */ | |
| 62 | + __u64 dest_offset; /* in - start of extent in destination */ | |
| 63 | + __u64 bytes_deduped; /* out - total # of bytes we were able | |
| 64 | + * to dedupe from this file. */ | |
| 65 | + /* status of this dedupe operation: | |
| 66 | + * < 0 for error | |
| 67 | + * == FILE_DEDUPE_RANGE_SAME if dedupe succeeds | |
| 68 | + * == FILE_DEDUPE_RANGE_DIFFERS if data differs | |
| 69 | + */ | |
| 70 | + __s32 status; /* out - see above description */ | |
| 71 | + __u32 reserved; /* must be zero */ | |
| 72 | +}; | |
| 73 | + | |
| 74 | +/* from struct btrfs_ioctl_file_extent_same_args */ | |
| 75 | +struct file_dedupe_range { | |
| 76 | + __u64 src_offset; /* in - start of extent in source */ | |
| 77 | + __u64 src_length; /* in - length of extent */ | |
| 78 | + __u16 dest_count; /* in - total elements in info array */ | |
| 79 | + __u16 reserved1; /* must be zero */ | |
| 80 | + __u32 reserved2; /* must be zero */ | |
| 81 | + struct file_dedupe_range_info info[0]; | |
| 82 | +}; | |
| 83 | + | |
| 55 | 84 | /* And dynamically-tunable limits and defaults: */ |
| 56 | 85 | struct files_stat_struct { |
| 57 | 86 | unsigned long nr_files; /* read only */ |
| @@ -168,6 +197,7 @@ struct inodes_stat_t { · 110 unmodified lines | ||
| 168 | 197 | #define FITRIM _IOWR('X', 121, struct fstrim_range) /* Trim */ |
| 169 | 198 | #define FICLONE _IOW(0x94, 9, int) |
| 170 | 199 | #define FICLONERANGE _IOW(0x94, 13, struct file_clone_range) |
| 200 | +#define FIDEDUPERANGE _IOWR(0x94, 54, struct file_dedupe_range) | |
| 171 | 201 | |
| 172 | 202 | #define FS_IOC_GETFLAGS _IOR('f', 1, long) |
| 173 | 203 | #define FS_IOC_SETFLAGS _IOW('f', 2, long) |