mirror of https://github.com/vitalif/e2fsprogs
libext2fs: iterate past lower extents during punch
When we're iterating extents during a punch operation, the loop exits if the punch region is entirely to the right of the extent we're looking at. This can happen if the punch region starts in the middle of a hole and covers mapped extents. When this happens, we want to skip to the next extent, because it might be punchable. Also, if we've totally passed the punch range, stop. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Zheng Liu <wenqing.lz@taobao.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>maint-test
parent
84593c2ac6
commit
80dec4cb31
|
@ -288,8 +288,12 @@ static errcode_t ext2fs_punch_extent(ext2_filsys fs, ext2_ino_t ino,
|
|||
(unsigned long long) end,
|
||||
(unsigned long long) next);
|
||||
if (start <= extent.e_lblk) {
|
||||
/*
|
||||
* Have we iterated past the end of the punch region?
|
||||
* If so, we can stop.
|
||||
*/
|
||||
if (end < extent.e_lblk)
|
||||
goto next_extent;
|
||||
break;
|
||||
dbg_printf("Case #%d\n", 1);
|
||||
/* Start of deleted region before extent;
|
||||
adjust beginning of extent */
|
||||
|
@ -303,8 +307,13 @@ static errcode_t ext2fs_punch_extent(ext2_filsys fs, ext2_ino_t ino,
|
|||
extent.e_lblk += free_count;
|
||||
extent.e_pblk += free_count;
|
||||
} else if (end >= next-1) {
|
||||
/*
|
||||
* Is the punch region beyond this extent? This can
|
||||
* happen if start is already inside a hole. Try to
|
||||
* advance to the next extent if this is the case.
|
||||
*/
|
||||
if (start >= next)
|
||||
break;
|
||||
goto next_extent;
|
||||
/* End of deleted region after extent;
|
||||
adjust end of extent */
|
||||
dbg_printf("Case #%d\n", 2);
|
||||
|
|
Loading…
Reference in New Issue