linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Allison Henderson <achender@linux.vnet.ibm.com>
To: linux-ext4@vger.kernel.org
Cc: Allison Henderson <achender@linux.vnet.ibm.com>
Subject: [PATCH 1/2] EXT4: Punch Hole Optimizations: Skip un-needed extent lookup
Date: Mon, 27 Jun 2011 15:49:50 -0700	[thread overview]
Message-ID: <1309214991-31141-2-git-send-email-achender@linux.vnet.ibm.com> (raw)
In-Reply-To: <1309214991-31141-1-git-send-email-achender@linux.vnet.ibm.com>

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>
---
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


  reply	other threads:[~2011-06-27 22:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-27 22:49 [PATCH 0/2] EXT4: Punch Hole Opmtimizations Allison Henderson
2011-06-27 22:49 ` Allison Henderson [this message]
2011-07-18  3:22   ` [PATCH 1/2] EXT4: Punch Hole Optimizations: Skip un-needed extent lookup Ted Ts'o
2011-06-27 22:49 ` [PATCH 2/2] EXT4: Punch Hole Optimizations: Removed un-needed ext4_ext_remove_space param Allison Henderson
2011-07-18  3:23   ` Ted Ts'o
2011-06-27 23:36 ` [PATCH 0/2] EXT4: Punch Hole Opmtimizations Allison Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1309214991-31141-2-git-send-email-achender@linux.vnet.ibm.com \
    --to=achender@linux.vnet.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).