From: Robin Dong <hao.bigrat@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: Robin Dong <sanbai@taobao.com>
Subject: [PATCH] ext4: add action of moving index in ext4_ext_rm_idx for Punch Hole
Date: Tue, 26 Jul 2011 15:34:59 +0800 [thread overview]
Message-ID: <1311665699-22023-1-git-send-email-hao.bigrat@gmail.com> (raw)
From: Robin Dong <sanbai@taobao.com>
The old function ext4_ext_rm_idx is used only for truncate case because
it just remove last index in extent-index-block. When punching hole,
it usually needed to remove "middle" index, therefore we must move indexes
which after it forward.
(I create a file with 1 depth extent tree and punch hole in the middle of it,
the last index in index-block strangly gone, so I find out this bug)
Signed-off-by: Robin Dong <sanbai@taobao.com>
---
fs/ext4/extents.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 4d73e11..a25bbdc 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2101,8 +2101,6 @@ ext4_ext_in_cache(struct inode *inode, ext4_lblk_t block,
/*
* ext4_ext_rm_idx:
* removes index from the index block.
- * It's used in truncate case only, thus all requests are for
- * last index in the block only.
*/
static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
struct ext4_ext_path *path)
@@ -2120,6 +2118,13 @@ static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
err = ext4_ext_get_access(handle, inode, path);
if (err)
return err;
+
+ if (path->p_idx != EXT_LAST_INDEX(path->p_hdr)) {
+ int len = EXT_LAST_INDEX(path->p_hdr) - path->p_idx;
+ len *= sizeof(struct ext4_extent_idx);
+ memmove(path->p_idx, path->p_idx + 1, len);
+ }
+
le16_add_cpu(&path->p_hdr->eh_entries, -1);
err = ext4_ext_dirty(handle, inode, path);
if (err)
--
1.7.3.2
next reply other threads:[~2011-07-26 7:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-26 7:34 Robin Dong [this message]
2011-07-28 1:33 ` [PATCH] ext4: add action of moving index in ext4_ext_rm_idx for Punch Hole Ted Ts'o
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=1311665699-22023-1-git-send-email-hao.bigrat@gmail.com \
--to=hao.bigrat@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sanbai@taobao.com \
/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).