From: Ashish Sangwan Date: Tue, 18 Jun 2013 15:28:45 +0000 (-0400) Subject: ext4: optimize starting extent in ext4_ext_rm_leaf() X-Git-Tag: next-20130619~97^2~2 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7d3c788cf8367fb1f23cdb05aa99726e52657761;p=karo-tx-linux.git 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 Signed-off-by: Namjae Jeon Signed-off-by: "Theodore Ts'o" --- diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 937593e2f006..6935bbcc78e2 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -2504,7 +2504,9 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, return -EIO; } /* find where to start removing */ - ex = EXT_LAST_EXTENT(eh); + ex = path[depth].p_ext; + if (!ex) + ex = EXT_LAST_EXTENT(eh); ex_ee_block = le32_to_cpu(ex->ee_block); ex_ee_len = ext4_ext_get_actual_len(ex);