Skip to content

Commit 6ae06ff

Browse files
Ashish Sangwantytso
authored andcommitted
ext4: optimize starting extent in ext4_ext_rm_leaf()
Both hole punch and truncate use ext4_ext_rm_leaf() for removing blocks. Currently we choose the last extent as the starting point for removing blocks: ex = EXT_LAST_EXTENT(eh); This is OK for truncate but for hole punch we can optimize the extent selection as the path is already initialized. We could use this information to select proper starting extent. The code change in this patch will not affect truncate as for truncate path[depth].p_ext will always be NULL. Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent 41a5b91 commit 6ae06ff

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/ext4/extents.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2504,7 +2504,9 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
25042504
return -EIO;
25052505
}
25062506
/* find where to start removing */
2507-
ex = EXT_LAST_EXTENT(eh);
2507+
ex = path[depth].p_ext;
2508+
if (!ex)
2509+
ex = EXT_LAST_EXTENT(eh);
25082510

25092511
ex_ee_block = le32_to_cpu(ex->ee_block);
25102512
ex_ee_len = ext4_ext_get_actual_len(ex);

0 commit comments

Comments
 (0)