diff options
author | Robin Dong <sanbai@taobao.com> | 2011-07-27 21:29:33 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-07-27 21:29:33 -0400 |
commit | 0e1147b001793593624e80b3c0a1790822b6baca (patch) | |
tree | b43cf0a3f8cb4733386867c4b06d92eb0025f04a /fs/ext4/extents.c | |
parent | 668f4dc5593327fadc95b33189c375f7178ef88e (diff) |
ext4: add action of moving index in ext4_ext_rm_idx for Punch Hole
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>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | 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 4d73e11ae883..a25bbdc7d493 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, | |||
2101 | /* | 2101 | /* |
2102 | * ext4_ext_rm_idx: | 2102 | * ext4_ext_rm_idx: |
2103 | * removes index from the index block. | 2103 | * removes index from the index block. |
2104 | * It's used in truncate case only, thus all requests are for | ||
2105 | * last index in the block only. | ||
2106 | */ | 2104 | */ |
2107 | static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode, | 2105 | static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode, |
2108 | struct ext4_ext_path *path) | 2106 | struct ext4_ext_path *path) |
@@ -2120,6 +2118,13 @@ static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode, | |||
2120 | err = ext4_ext_get_access(handle, inode, path); | 2118 | err = ext4_ext_get_access(handle, inode, path); |
2121 | if (err) | 2119 | if (err) |
2122 | return err; | 2120 | return err; |
2121 | |||
2122 | if (path->p_idx != EXT_LAST_INDEX(path->p_hdr)) { | ||
2123 | int len = EXT_LAST_INDEX(path->p_hdr) - path->p_idx; | ||
2124 | len *= sizeof(struct ext4_extent_idx); | ||
2125 | memmove(path->p_idx, path->p_idx + 1, len); | ||
2126 | } | ||
2127 | |||
2123 | le16_add_cpu(&path->p_hdr->eh_entries, -1); | 2128 | le16_add_cpu(&path->p_hdr->eh_entries, -1); |
2124 | err = ext4_ext_dirty(handle, inode, path); | 2129 | err = ext4_ext_dirty(handle, inode, path); |
2125 | if (err) | 2130 | if (err) |