Commit aa5d0ba0 authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: only reserve quota blocks for bmbt changes if we're changing the data fork



Now that we've reworked xfs_reflink_remap_extent to remap only one
extent per transaction, we actually know if the extent being removed is
an allocated mapping.  This means that we now know ahead of time if
we're going to be touching the data fork.

Since we only need blocks for a bmbt split if we're going to update the
data fork, we only need to get quota reservation if we know we're going
to touch the data fork.

Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 00fd1d56
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -1047,7 +1047,11 @@ xfs_reflink_remap_extent(
	 * Compute quota reservation if we think the quota block counter for
	 * this file could increase.
	 *
	 * We start by reserving enough blocks to handle a bmbt split.
	 * Adding a written extent to the extent map can cause a bmbt split,
	 * and removing a mapped extent from the extent can cause a bmbt split.
	 * The two operations cannot both cause a split since they operate on
	 * the same index in the bmap btree, so we only need a reservation for
	 * one bmbt split if either thing is happening.
	 *
	 * If we are mapping a written extent into the file, we need to have
	 * enough quota block count reservation to handle the blocks in that
@@ -1060,14 +1064,17 @@ xfs_reflink_remap_extent(
	 * before we started.  That should have removed all the delalloc
	 * reservations, but we code defensively.
	 */
	qdelta = 0;
	qres = qdelta = 0;
	if (smap_real || dmap_written)
		qres = XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK);
	if (dmap_written)
		qres += dmap->br_blockcount;
	if (qres > 0) {
		error = xfs_trans_reserve_quota_nblks(tp, ip, qres, 0,
				XFS_QMOPT_RES_REGBLKS);
		if (error)
			goto out_cancel;
	}

	if (smap_real) {
		/*