dm: change max_io_len() to use blk_max_size_offset()

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>
This commit is contained in:
Mike Snitzer 2020-09-18 20:22:30 -04:00
Родитель 882ec4e609
Коммит 5091cdec56
1 изменённых файлов: 8 добавлений и 12 удалений

Просмотреть файл

@ -1051,22 +1051,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) 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 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? * 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) { max_len = blk_max_size_offset(dm_table_get_md(ti->table)->queue,
offset = dm_target_offset(ti, sector); 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) if (len > max_len)
len = max_len; len = max_len;
}
return len; return len;
} }