Skip to content

Commit

Permalink
ext4: fix extent merging in ext4_ext_shift_path_extents()
Browse files Browse the repository at this point in the history
There is a bug in ext4_ext_shift_path_extents() where if we actually
manage to merge a extent we would skip shifting the next extent. This
will result in in one extent in the extent tree not being properly
shifted.

This is causing failure in various xfstests tests using fsx or fsstress
with collapse range support. It will also cause file system corruption
which looks something like:

 e2fsck 1.42.9 (4-Feb-2014)
 Pass 1: Checking inodes, blocks, and sizes
 Inode 20 has out of order extents
        (invalid logical block 3, physical block 492938, len 2)
 Clear? yes
 ...

when running e2fsck.

It's also very easily reproducible just by running fsx without any
parameters. I can usually hit the problem within a minute.

Fix it by increasing ex_start only if we're not merging the extent.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Namjae Jeon <namjae.jeon@samsung.com>
  • Loading branch information
Lukas Czerner authored and Theodore Ts'o committed Apr 18, 2014
1 parent ef24f6c commit 6dd834e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -5245,13 +5245,14 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift,

while (ex_start <= ex_last) {
le32_add_cpu(&ex_start->ee_block, -shift);
if (ex_start >
EXT_FIRST_EXTENT(path[depth].p_hdr)) {
if (ext4_ext_try_to_merge_right(inode,
path, ex_start - 1))
ex_last--;
}
ex_start++;
/* Try to merge to the left. */
if ((ex_start >
EXT_FIRST_EXTENT(path[depth].p_hdr)) &&
ext4_ext_try_to_merge_right(inode,
path, ex_start - 1))
ex_last--;
else
ex_start++;
}
err = ext4_ext_dirty(handle, inode, path + depth);
if (err)
Expand Down

0 comments on commit 6dd834e

Please sign in to comment.