2011-06-27 22:47:32

by Allison Henderson

[permalink] [raw]
Subject: [PATCH 0/2] EXT4: Punch Hole Opmtimizations

We realized late that we could optimize the punch hole code by skipping
ext4_ext_remove_space, and directly calling ext4_ext_rm_leaf. Since
punch hole is done through map blocks, the path to the extent is already
known, so we do not need to look it up again. The extra parameter that
was added in ext4_ext_remove_space is removed since we no longer need it.


Allison Henderson (2):
EXT4: Punch Hole Optimizations: Skip un-needed extent lookup
EXT4: Punch Hole Optimizations: Removed un-needed
ext4_ext_remove_space param

fs/ext4/extents.c | 30 ++++++++++++++++++++++++------
1 files changed, 24 insertions(+), 6 deletions(-)



2011-06-27 22:47:32

by Allison Henderson

[permalink] [raw]
Subject: [PATCH 2/2] EXT4: Punch Hole Optimizations: Removed un-needed ext4_ext_remove_space param

This patch removes the extra parameter in the ext4_ext_remove_space
routine which is no longer needed.

Signed-off-by: Allison Henderson <[email protected]>
---
v1->v2
Added patch 2/2 to remove uneeded parameter

v2->v3
Rebased to apply onto latest ext4 code

:100644 100644 dc5a077... 3579822... M fs/ext4/extents.c
fs/ext4/extents.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index dc5a077..3579822 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2534,8 +2534,7 @@ ext4_ext_more_to_rm(struct ext4_ext_path *path)
return 1;
}

-static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
- ext4_lblk_t end)
+static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start)
{
struct super_block *sb = inode->i_sb;
int depth = ext_depth(inode);
@@ -2575,7 +2574,7 @@ again:
if (i == depth) {
/* this is leaf block */
err = ext4_ext_rm_leaf(handle, inode, path,
- start, end);
+ start, EXT_MAX_BLOCKS - 1);
/* root level has p_bh == NULL, brelse() eats this */
brelse(path[i].p_bh);
path[i].p_bh = NULL;
@@ -3718,7 +3717,7 @@ void ext4_ext_truncate(struct inode *inode)

last_block = (inode->i_size + sb->s_blocksize - 1)
>> EXT4_BLOCK_SIZE_BITS(sb);
- err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1);
+ err = ext4_ext_remove_space(inode, last_block);

/* In a multi-transaction truncate, we only make the final
* transaction synchronous.
--
1.7.1


2011-06-27 22:47:32

by Allison Henderson

[permalink] [raw]
Subject: [PATCH 1/2] 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 <[email protected]>
---
v2->v3
Rebased to apply onto latest ext4 code

:100644 100644 f815cc8... dc5a077... M fs/ext4/extents.c
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 f815cc8..dc5a077 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3497,8 +3497,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;
}
--
1.7.1


2011-06-27 23:36:15

by Allison Henderson

[permalink] [raw]
Subject: Re: [PATCH 0/2] EXT4: Punch Hole Opmtimizations

Sorry, I just noticed I missed the version number on this set. This is
v3 of this patch set. I just switched to a different mailer to help
keep the threading correct for people, but please let me know if anyone
notices any other oddities about it. Thx!

Allison Henderson


2011-07-18 03:22:59

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH 1/2] EXT4: Punch Hole Optimizations: Skip un-needed extent lookup

On Mon, Jun 27, 2011 at 03:49:50PM -0700, Allison Henderson wrote:
> 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 <[email protected]>

Thanks, added to the ext4 tree.

- Ted

2011-07-18 03:23:13

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH 2/2] EXT4: Punch Hole Optimizations: Removed un-needed ext4_ext_remove_space param

On Mon, Jun 27, 2011 at 03:49:51PM -0700, Allison Henderson wrote:
> This patch removes the extra parameter in the ext4_ext_remove_space
> routine which is no longer needed.
>
> Signed-off-by: Allison Henderson <[email protected]>

Thanks, added to the ext4 tree.

- Ted