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/1] ext4: Remove empty index blocks when punching holes
Date: Wed, 29 Feb 2012 00:37:28 -0700 [thread overview]
Message-ID: <1330501048-14109-1-git-send-email-achender@linux.vnet.ibm.com> (raw)
When punching holes, it is possible that all the entries of an
index block may be removed. These empty index blocks need to
be removed once punch hole completes. This patch adds some extra
logic to the punch hole code to remove empty index blocks.
Signed-off-by: Allison Henderson <achender@linux.vnet.ibm.com>
---
:100644 100644 ad39627... 6bb2f55... M fs/ext4/extents.c
fs/ext4/extents.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index ad39627..6bb2f55 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3709,7 +3709,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
struct ext4_extent newex, *ex, *ex2;
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
ext4_fsblk_t newblock = 0;
- int free_on_err = 0, err = 0, depth, ret;
+ int free_on_err = 0, err = 0, depth, ret, i;
unsigned int allocated = 0, offset = 0;
unsigned int allocated_clusters = 0, reserved_clusters = 0;
unsigned int punched_out = 0;
@@ -3880,6 +3880,21 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
err = ext4_ext_rm_leaf(handle, inode, path,
&partial_cluster, map->m_lblk,
map->m_lblk + punched_out);
+ if (err)
+ goto out2;
+
+ /*
+ * Walk back up the path and remove
+ * empty index blocks
+ */
+ for (i = depth - 1; i > 0; i--) {
+ if (path[i].p_hdr->eh_entries == 0) {
+ err = ext4_ext_rm_idx(handle, inode,
+ path + i);
+ if (err)
+ goto out2;
+ }
+ }
if (!err && path->p_hdr->eh_entries == 0) {
/*
--
1.7.1
next reply other threads:[~2012-02-29 7:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-29 7:37 Allison Henderson [this message]
2012-02-29 7:44 ` [PATCH 1/1] ext4: Remove empty index blocks when punching holes Lukas Czerner
2012-02-29 8:15 ` Allison Henderson
2012-02-29 8:18 ` Lukas Czerner
2012-03-05 23:54 ` Ted Ts'o
2012-03-06 7:11 ` Lukas Czerner
2012-03-06 16:44 ` Ted Ts'o
[not found] ` <4F565962.1020604@linux.vnet.ibm.com>
2012-03-06 18:42 ` Allison Henderson
2012-03-07 7:05 ` Lukas Czerner
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=1330501048-14109-1-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).