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

xfs: fix xfs_rmap_has_other_keys usage of ECANCELED



In e7ee96df, we converted all ITER_ABORT users to use ECANCELED
instead, but we forgot to teach xfs_rmap_has_other_keys not to return
that magic value to callers.  Fix it now by using ECANCELED both to
abort the iteration and to signal that we found another reverse mapping.
This enables us to drop the separate boolean flag.

Fixes: e7ee96df ("xfs: remove all *_ITER_ABORT values")
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 496b9bcd
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -2694,7 +2694,6 @@ struct xfs_rmap_key_state {
	uint64_t			owner;
	uint64_t			offset;
	unsigned int			flags;
	bool				has_rmap;
};

/* For each rmap given, figure out if it doesn't match the key we want. */
@@ -2709,7 +2708,6 @@ xfs_rmap_has_other_keys_helper(
	if (rks->owner == rec->rm_owner && rks->offset == rec->rm_offset &&
	    ((rks->flags & rec->rm_flags) & XFS_RMAP_KEY_FLAGS) == rks->flags)
		return 0;
	rks->has_rmap = true;
	return -ECANCELED;
}

@@ -2731,7 +2729,7 @@ xfs_rmap_has_other_keys(
	int				error;

	xfs_owner_info_unpack(oinfo, &rks.owner, &rks.offset, &rks.flags);
	rks.has_rmap = false;
	*has_rmap = false;

	low.rm_startblock = bno;
	memset(&high, 0xFF, sizeof(high));
@@ -2739,13 +2737,14 @@ xfs_rmap_has_other_keys(

	error = xfs_rmap_query_range(cur, &low, &high,
			xfs_rmap_has_other_keys_helper, &rks);
	if (error < 0)
		return error;

	*has_rmap = rks.has_rmap;
	if (error == -ECANCELED) {
		*has_rmap = true;
		return 0;
	}

	return error;
}

const struct xfs_owner_info XFS_RMAP_OINFO_SKIP_UPDATE = {
	.oi_owner = XFS_RMAP_OWN_NULL,
};