Commit 871e122d authored by Michael Lass's avatar Michael Lass Committed by Greg Kroah-Hartman

dm: make sure to obey max_io_len_target_boundary

commit 51b86f9a upstream.

Commit 61697a6a ("dm: eliminate 'split_discard_bios' flag from DM
target interface") incorrectly removed code from
__send_changing_extent_only() that is required to impose a per-target IO
boundary on IO that exceeds max_io_len_target_boundary().  Otherwise
"special" IO (e.g. DISCARD, WRITE SAME, WRITE ZEROES) can write beyond
where allowed.

Fix this by restoring the max_io_len_target_boundary() limit in
__send_changing_extent_only()

Fixes: 61697a6a ("dm: eliminate 'split_discard_bios' flag from DM target interface")
Cc: stable@vger.kernel.org # 5.1+
Signed-off-by: default avatarMichael Lass <bevan@bi-co.net>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5bb2a758
...@@ -1467,7 +1467,7 @@ static unsigned get_num_write_zeroes_bios(struct dm_target *ti) ...@@ -1467,7 +1467,7 @@ static unsigned get_num_write_zeroes_bios(struct dm_target *ti)
static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *ti, static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *ti,
unsigned num_bios) unsigned num_bios)
{ {
unsigned len = ci->sector_count; unsigned len;
/* /*
* Even though the device advertised support for this type of * Even though the device advertised support for this type of
...@@ -1478,6 +1478,8 @@ static int __send_changing_extent_only(struct clone_info *ci, struct dm_target * ...@@ -1478,6 +1478,8 @@ static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *
if (!num_bios) if (!num_bios)
return -EOPNOTSUPP; return -EOPNOTSUPP;
len = min((sector_t)ci->sector_count, max_io_len_target_boundary(ci->sector, ti));
__send_duplicate_bios(ci, ti, num_bios, &len); __send_duplicate_bios(ci, ti, num_bios, &len);
ci->sector += len; ci->sector += len;
......
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