On Mon, Jan 20, 2014 at 10:21:58PM -0800, Darrick J. Wong wrote: > 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@xxxxxxxxxx> Reviewed-by: Zheng Liu <wenqing.lz@xxxxxxxxxx> - Zheng > --- > lib/ext2fs/punch.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > > diff --git a/lib/ext2fs/punch.c b/lib/ext2fs/punch.c > index 25d7953..657cb53 100644 > --- a/lib/ext2fs/punch.c > +++ b/lib/ext2fs/punch.c > @@ -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); > > -- > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html