Commit 99fb6b7a authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Chandan Babu R

xfs: upgrade the extent counters in xfs_reflink_end_cow_extent later

Defer the extent counter size upgrade until we know we're going to
modify the extent mapping.  This also defers dirtying the transaction
and will allow us safely back out later in the function in later
changes.

Fixes: 4f86bb4b ("xfs: Conditionally upgrade existing inodes to use large extent counters")
Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
parent cc3c92e7
...@@ -732,14 +732,6 @@ xfs_reflink_end_cow_extent( ...@@ -732,14 +732,6 @@ xfs_reflink_end_cow_extent(
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
XFS_IEXT_REFLINK_END_COW_CNT);
if (error == -EFBIG)
error = xfs_iext_count_upgrade(tp, ip,
XFS_IEXT_REFLINK_END_COW_CNT);
if (error)
goto out_cancel;
/* /*
* In case of racing, overlapping AIO writes no COW extents might be * In case of racing, overlapping AIO writes no COW extents might be
* left by the time I/O completes for the loser of the race. In that * left by the time I/O completes for the loser of the race. In that
...@@ -768,6 +760,14 @@ xfs_reflink_end_cow_extent( ...@@ -768,6 +760,14 @@ xfs_reflink_end_cow_extent(
del = got; del = got;
xfs_trim_extent(&del, *offset_fsb, end_fsb - *offset_fsb); xfs_trim_extent(&del, *offset_fsb, end_fsb - *offset_fsb);
error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
XFS_IEXT_REFLINK_END_COW_CNT);
if (error == -EFBIG)
error = xfs_iext_count_upgrade(tp, ip,
XFS_IEXT_REFLINK_END_COW_CNT);
if (error)
goto out_cancel;
/* Grab the corresponding mapping in the data fork. */ /* Grab the corresponding mapping in the data fork. */
nmaps = 1; nmaps = 1;
error = xfs_bmapi_read(ip, del.br_startoff, del.br_blockcount, &data, error = xfs_bmapi_read(ip, del.br_startoff, del.br_blockcount, &data,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment