/* On success, returns 1 if this snapshot is a handover destination, otherwise returns 0.  */
static int __validate_exception_handover(struct dm_snapshot *snap)
/* On success, returns 1 if this snapshot is a handover destination, otherwise returns 0.  */
static int __validate_exception_handover(struct dm_snapshot *snap)
{
	struct dm_snapshot *snap_src = NULL, *snap_dest = NULL;
	struct dm_snapshot *snap_merge = NULL;
	if ((__find_snapshots_sharing_cow(snap, &snap_src, &snap_dest,
					  &snap_merge) == 2) ||
	    snap_dest) {
		snap->ti->error = "Snapshot cow pairing for exception "
				  "table handover failed";
		return -EINVAL;
	}
	if (!snap_src)
		return 0;
	if (!dm_target_is_snapshot_merge(snap->ti))
		return 1;
	if (snap_merge) {
		snap->ti->error = "A snapshot is already merging.";
		return -EINVAL;
	}
	if (!snap_src->store->type->prepare_merge ||
	    !snap_src->store->type->commit_merge) {
		snap->ti->error = "Snapshot exception store does not "
				  "support snapshot-merge.";
		return -EINVAL;
	}
	return 1;
}