* [dm-devel] [PATCH AUTOSEL 4.19 37/60] dm: change max_io_len() to use blk_max_size_offset()
[not found] <20201027000415.1026364-1-sashal@kernel.org>
@ 2020-10-27 0:03 ` Sasha Levin
0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2020-10-27 0:03 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Sasha Levin, dm-devel, Mike Snitzer
From: Mike Snitzer <snitzer@redhat.com>
[ Upstream commit 5091cdec56faeaefa79de4b6cb3c3c55e50d1ac3 ]
Using blk_max_size_offset() enables DM core's splitting to impose
ti->max_io_len (via q->limits.chunk_sectors) and also fallback to
respecting q->limits.max_sectors if chunk_sectors isn't set.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/md/dm.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 874bd542a7445..571d1cb2f6221 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -992,22 +992,18 @@ static sector_t max_io_len_target_boundary(sector_t sector, struct dm_target *ti
static sector_t max_io_len(sector_t sector, struct dm_target *ti)
{
sector_t len = max_io_len_target_boundary(sector, ti);
- sector_t offset, max_len;
+ sector_t max_len;
/*
* Does the target need to split even further?
+ * - q->limits.chunk_sectors reflects ti->max_io_len so
+ * blk_max_size_offset() provides required splitting.
+ * - blk_max_size_offset() also respects q->limits.max_sectors
*/
- if (ti->max_io_len) {
- offset = dm_target_offset(ti, sector);
- if (unlikely(ti->max_io_len & (ti->max_io_len - 1)))
- max_len = sector_div(offset, ti->max_io_len);
- else
- max_len = offset & (ti->max_io_len - 1);
- max_len = ti->max_io_len - max_len;
-
- if (len > max_len)
- len = max_len;
- }
+ max_len = blk_max_size_offset(dm_table_get_md(ti->table)->queue,
+ dm_target_offset(ti, sector));
+ if (len > max_len)
+ len = max_len;
return len;
}
--
2.25.1
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-27 0:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20201027000415.1026364-1-sashal@kernel.org>
2020-10-27 0:03 ` [dm-devel] [PATCH AUTOSEL 4.19 37/60] dm: change max_io_len() to use blk_max_size_offset() Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).