Message ID | 20201019064048.6591-9-chandanrlinux@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Bail out if transaction can cause extent count to overflow | expand |
On 10/18/20 11:40 PM, Chandan Babu R wrote: > 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. > Following the previous discussion threads, I do think that's easier to look at. I know it's more LOC, but less jumping around to understand what it means :-) Reviewed-by: Allison Henderson <allison.henderson@oracle.com> > Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com> > --- > fs/xfs/xfs_reflink.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c > index 4f0198f636ad..856fe755a5e9 100644 > --- a/fs/xfs/xfs_reflink.c > +++ b/fs/xfs/xfs_reflink.c > @@ -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; > > @@ -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 >
On Mon, Oct 19, 2020 at 12:10:42PM +0530, Chandan Babu R wrote: > 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. > > Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com> Looks fine, Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> --D > --- > fs/xfs/xfs_reflink.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c > index 4f0198f636ad..856fe755a5e9 100644 > --- a/fs/xfs/xfs_reflink.c > +++ b/fs/xfs/xfs_reflink.c > @@ -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; > > @@ -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 > -- > 2.28.0 >
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 4f0198f636ad..856fe755a5e9 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -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; @@ -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
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. Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com> --- fs/xfs/xfs_reflink.c | 11 +++++++++++ 1 file changed, 11 insertions(+)