Skip to contentSkip to conversation

ext4: Add EXT4_IOC_TRANSFER_BLOCK_RANGE ioctl

PATCH In review Namjae Jeon 1 participant 1 message Jun 23, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/3 ext4: Add EXT4_IOC_TRANSFER_BLOCK_RANGE ioctl

From: Namjae Jeon <[email protected]>

The EXT4_IOC_TRANSFER_BLOCK_RANGE ioctl transfers the data blocks lying between [start, "start + length") form source file and append them to destination file (represented by dest_fd).
This operation leaves a hole in the source file from where data blocks are transfrered.
If there is any fallocated area beyond isize of destination it will be truncated.

---
 fs/ext4/ext4.h    |   10 +-
 fs/ext4/extents.c |  471 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ext4/ioctl.c   |   47 ++++++
 3 files changed, 527 insertions(+), 1 deletion(-)
fs/ext4/ext4.h +9 -1
index 246a03a..8f01855 100644
@@ -591,6 +591,7 @@ enum {
 #define EXT4_IOC_RESIZE_FS		_IOW('f', 16, __u64)
 #define EXT4_IOC_SWAP_BOOT		_IO('f', 17)
 #define EXT4_IOC_TRUNCATE_BLOCK_RANGE	_IOW('f', 18, struct truncate_range)
+#define EXT4_IOC_TRANSFER_BLOCK_RANGE	_IOW('f', 19, struct transfer_range)
 
 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
 /*
@@ -688,6 +689,12 @@ struct truncate_range {
 	__u32 length;
 };
 
+struct transfer_range {
+	__u32 dest_fd;
+	__u32 start_block;
+	__u32 length;
+};
+
 #define EXT4_EPOCH_BITS 2
 #define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1)
 #define EXT4_NSEC_MASK  (~0UL << EXT4_EPOCH_BITS)
@@ -2700,7 +2707,8 @@ extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 			__u64 start, __u64 len);
 extern int ext4_ext_truncate_range(struct inode *inode, ext4_lblk_t start,
 				   ext4_lblk_t end, ext4_lblk_t last_block);
-
+extern int ext4_ext_transfer_range(struct inode *sinode, struct inode *dinode,
+				   __u32 start_block, __u32 end_block);
 
 /* move_extent.c */
 extern void ext4_double_down_write_data_sem(struct inode *first,
fs/ext4/extents.c +471 -0

474 lines not on this page · raw message

fs/ext4/ioctl.c +47 -0

53 lines not on this page · raw message

Signature · 1 line
1.7.9.5