Skip to content

Commit

Permalink
xfs: Check for extent overflow when remapping an extent
Browse files Browse the repository at this point in the history
Remapping an extent involves unmapping the existing extent and mapping
in the new extent. When unmapping, an extent containing the entire unmap
range can be split into two extents,
i.e. | Old extent | hole | Old extent |
Hence extent count increases by 1.

Mapping in the new extent into the destination file can increase the
extent count by 1.

Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
  • Loading branch information
Chandan Babu R authored and Darrick J. Wong committed Jan 23, 2021
1 parent 5f1d5bb commit ee898d7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fs/xfs/xfs_reflink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,7 @@ xfs_reflink_remap_extent(
unsigned int resblks;
bool smap_real;
bool dmap_written = xfs_bmap_is_written_extent(dmap);
int iext_delta = 0;
int nimaps;
int error;

Expand Down Expand Up @@ -1099,6 +1100,16 @@ xfs_reflink_remap_extent(
goto out_cancel;
}

if (smap_real)
++iext_delta;

if (dmap_written)
++iext_delta;

error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK, iext_delta);
if (error)
goto out_cancel;

if (smap_real) {
/*
* If the extent we're unmapping is backed by storage (written
Expand Down

0 comments on commit ee898d7

Please sign in to comment.