diff options
author | Allison Henderson <achender@linux.vnet.ibm.com> | 2011-07-17 23:17:02 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-07-17 23:17:02 -0400 |
commit | f7d0d3797fac6cad24ad9f86dd9baf65c586b434 (patch) | |
tree | 73ae5f70c194399f9c8273d6681e7534400ffdc0 /fs/ext4/extents.c | |
parent | 3eb08658431abd65c0fe6855d1860859c2d416f7 (diff) | |
download | linux-f7d0d3797fac6cad24ad9f86dd9baf65c586b434.tar.bz2 |
ext4: punch hole optimizations: skip un-needed extent lookup
This patch optimizes the punch hole operation by skipping the
tree walking code that is used by truncate. Since punch hole
is done through map blocks, the path to the extent is already
known in this function, so we do not need to look it up again.
Signed-off-by: Allison Henderson <achender@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index f1c538e5055c..06b30b61205f 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3461,8 +3461,27 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, ext4_ext_mark_uninitialized(ex); - err = ext4_ext_remove_space(inode, map->m_lblk, - map->m_lblk + punched_out); + ext4_ext_invalidate_cache(inode); + + err = ext4_ext_rm_leaf(handle, inode, path, + map->m_lblk, map->m_lblk + punched_out); + + if (!err && path->p_hdr->eh_entries == 0) { + /* + * Punch hole freed all of this sub tree, + * so we need to correct eh_depth + */ + err = ext4_ext_get_access(handle, inode, path); + if (err == 0) { + ext_inode_hdr(inode)->eh_depth = 0; + ext_inode_hdr(inode)->eh_max = + cpu_to_le16(ext4_ext_space_root( + inode, 0)); + + err = ext4_ext_dirty( + handle, inode, path); + } + } goto out2; } |