When setting a logical block which is before the first extent in the
extent tree, make sure the new extent goes in front, at the very
beginning of the extent tree. This fixes a bug where previously the
new extent would be inserted out of order in this case.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
((int) extent.e_len < max_len-1)) {
extent.e_len++;
retval = ext2fs_extent_replace(handle, 0, &extent);
- } else
+ } else if (logical < extent.e_lblk)
+ retval = ext2fs_extent_insert(handle, 0, &newextent);
+ else
retval = ext2fs_extent_insert(handle,
EXT2_EXTENT_INSERT_AFTER, &newextent);
if (retval)