Skip to content

Commit 331573f

Browse files
namjaejeontytso
authored andcommitted
ext4: Add support FALLOC_FL_INSERT_RANGE for fallocate
This patch implements fallocate's FALLOC_FL_INSERT_RANGE for Ext4. 1) Make sure that both offset and len are block size aligned. 2) Update the i_size of inode by len bytes. 3) Compute the file's logical block number against offset. If the computed block number is not the starting block of the extent, split the extent such that the block number is the starting block of the extent. 4) Shift all the extents which are lying between [offset, last allocated extent] towards right by len bytes. This step will make a hole of len bytes at offset. Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
1 parent de92c8c commit 331573f

File tree

3 files changed

+292
-52
lines changed

3 files changed

+292
-52
lines changed

fs/ext4/ext4.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ typedef __u32 ext4_lblk_t;
9090
/* data type for block group number */
9191
typedef unsigned int ext4_group_t;
9292

93+
enum SHIFT_DIRECTION {
94+
SHIFT_LEFT = 0,
95+
SHIFT_RIGHT,
96+
};
97+
9398
/*
9499
* Flags used in mballoc's allocation_context flags field.
95100
*
@@ -2947,6 +2952,7 @@ extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
29472952
__u64 start, __u64 len);
29482953
extern int ext4_ext_precache(struct inode *inode);
29492954
extern int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len);
2955+
extern int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len);
29502956
extern int ext4_swap_extents(handle_t *handle, struct inode *inode1,
29512957
struct inode *inode2, ext4_lblk_t lblk1,
29522958
ext4_lblk_t lblk2, ext4_lblk_t count,

0 commit comments

Comments
 (0)