Skip to content

Commit

Permalink
dm: make sure to obey max_io_len_target_boundary
Browse files Browse the repository at this point in the history
Commit 61697a6 ("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: 61697a6 ("dm: eliminate 'split_discard_bios' flag from DM target interface")
Cc: stable@vger.kernel.org # 5.1+
Signed-off-by: Michael Lass <bevan@bi-co.net>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
michaellass authored and snitm committed May 21, 2019
1 parent 8454fca commit 51b86f9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,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,
unsigned num_bios)
{
unsigned len = ci->sector_count;
unsigned len;

/*
* Even though the device advertised support for this type of
Expand All @@ -1480,6 +1480,8 @@ static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *
if (!num_bios)
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);

ci->sector += len;
Expand Down

0 comments on commit 51b86f9

Please sign in to comment.