Commit 53422e moved the new extent insertion in
ext2fs_extent_set_bmap() prior to the modification of the original
extent, but the insert function left the handle pointing to the new
extent. This left us modifying the -new- extent, instead of the
original one, and winding up with a corrupt extent tree something
like:
BLOCKS:
(0-1):588791-588792, (0):588791
We need to move back to the previous extent prior
to modification, if we inserted a new one.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
EXT2_EXTENT_INSERT_AFTER, &newextent);
if (retval)
goto done;
+ /* Now pointing at inserted extent; move back to prev */
+ retval = ext2fs_extent_goto(handle, logical - 1);
+ if (retval)
+ goto done;
}
extent.e_len--;
retval = ext2fs_extent_replace(handle, 0, &extent);