Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d7f4562 authored by Mike Snitzer's avatar Mike Snitzer
Browse files

dm: fix __send_changing_extent_only() to send first bio and chain remainder



__send_changing_extent_only() must follow the same pattern that was
established with commit "dm: ensure bio submission follows a depth-first
tree walk".  That is: submit first bio up to split boundary and then
split the remainder to further submissions.

Suggested-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 0776aa0e
Loading
Loading
Loading
Loading
+30 −36
Original line number Diff line number Diff line
@@ -1348,19 +1348,13 @@ static bool is_split_required_for_discard(struct dm_target *ti)
	return ti->split_discard_bios;
}

static int __send_changing_extent_only(struct clone_info *ci,
static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *ti,
				       get_num_bios_fn get_num_bios,
				       is_split_required_fn is_split_required)
{
	struct dm_target *ti;
	unsigned len;
	unsigned num_bios;

	do {
		ti = dm_table_find_target(ci->map, ci->sector);
		if (!dm_target_is_valid(ti))
			return -EIO;

	/*
	 * Even though the device advertised support for this type of
	 * request, that does not mean every target supports it, and
@@ -1379,25 +1373,25 @@ static int __send_changing_extent_only(struct clone_info *ci,
	__send_duplicate_bios(ci, ti, num_bios, &len);

	ci->sector += len;
	} while (ci->sector_count -= len);
	ci->sector_count -= len;

	return 0;
}

static int __send_discard(struct clone_info *ci)
static int __send_discard(struct clone_info *ci, struct dm_target *ti)
{
	return __send_changing_extent_only(ci, get_num_discard_bios,
	return __send_changing_extent_only(ci, ti, get_num_discard_bios,
					   is_split_required_for_discard);
}

static int __send_write_same(struct clone_info *ci)
static int __send_write_same(struct clone_info *ci, struct dm_target *ti)
{
	return __send_changing_extent_only(ci, get_num_write_same_bios, NULL);
	return __send_changing_extent_only(ci, ti, get_num_write_same_bios, NULL);
}

static int __send_write_zeroes(struct clone_info *ci)
static int __send_write_zeroes(struct clone_info *ci, struct dm_target *ti)
{
	return __send_changing_extent_only(ci, get_num_write_zeroes_bios, NULL);
	return __send_changing_extent_only(ci, ti, get_num_write_zeroes_bios, NULL);
}

/*
@@ -1410,17 +1404,17 @@ static int __split_and_process_non_flush(struct clone_info *ci)
	unsigned len;
	int r;

	if (unlikely(bio_op(bio) == REQ_OP_DISCARD))
		return __send_discard(ci);
	else if (unlikely(bio_op(bio) == REQ_OP_WRITE_SAME))
		return __send_write_same(ci);
	else if (unlikely(bio_op(bio) == REQ_OP_WRITE_ZEROES))
		return __send_write_zeroes(ci);

	ti = dm_table_find_target(ci->map, ci->sector);
	if (!dm_target_is_valid(ti))
		return -EIO;

	if (unlikely(bio_op(bio) == REQ_OP_DISCARD))
		return __send_discard(ci, ti);
	else if (unlikely(bio_op(bio) == REQ_OP_WRITE_SAME))
		return __send_write_same(ci, ti);
	else if (unlikely(bio_op(bio) == REQ_OP_WRITE_ZEROES))
		return __send_write_zeroes(ci, ti);

	if (bio_op(bio) == REQ_OP_ZONE_REPORT)
		len = ci->sector_count;
	else