Fix delalloc-debug
[ext4-patch-queue.git] / optimize-starting-extent-in-ext4_ext_rm_leaf
blob18975ab05f7cb35cb601ef46f8ff15b63a5b0919
1 ext4: optimize starting extent in ext4_ext_rm_leaf()
3 From: Ashish Sangwan <a.sangwan@samsung.com>
5 Both hole punch and truncate use ext4_ext_rm_leaf() for removing
6 blocks.  Currently we choose the last extent as the starting
7 point for removing blocks:
9         ex = EXT_LAST_EXTENT(eh);
11 This is OK for truncate but for hole punch we can optimize the extent
12 selection as the path is already initialized.  We could use this
13 information to select proper starting extent.  The code change in this
14 patch will not affect truncate as for truncate path[depth].p_ext will
15 always be NULL.
17 Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
18 Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
19 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
20 ---
21  fs/ext4/extents.c |    4 +++-
22  1 files changed, 3 insertions(+), 1 deletions(-)
24 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
25 index 3676dae..7c1a5d3 100644
26 --- a/fs/ext4/extents.c
27 +++ b/fs/ext4/extents.c
28 @@ -2490,7 +2490,9 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
29                 return -EIO;
30         }
31         /* find where to start removing */
32 -       ex = EXT_LAST_EXTENT(eh);
33 +       ex = path[depth].p_ext;
34 +       if (!ex)
35 +               ex = EXT_LAST_EXTENT(eh);
37         ex_ee_block = le32_to_cpu(ex->ee_block);
38         ex_ee_len = ext4_ext_get_actual_len(ex);
39 -- 
40 1.7.2.3