mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
block: introduce BDRV_REQUEST_MAX_SECTORS
we check and adjust request sizes at several places with sometimes inconsistent checks or default values: INT_MAX INT_MAX >> BDRV_SECTOR_BITS UINT_MAX >> BDRV_SECTOR_BITS SIZE_MAX >> BDRV_SECTOR_BITS This patches introdocues a macro for the maximal allowed sectors per request and uses it at several places. Signed-off-by: Peter Lieven <pl@kamp.de> Reviewed-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
1ce52846d3
commit
75af1f34cd
3 changed files with 14 additions and 14 deletions
|
@ -381,7 +381,7 @@ void virtio_blk_submit_multireq(BlockBackend *blk, MultiReqBuffer *mrb)
|
|||
}
|
||||
|
||||
max_xfer_len = blk_get_max_transfer_length(mrb->reqs[0]->dev->blk);
|
||||
max_xfer_len = MIN_NON_ZERO(max_xfer_len, INT_MAX);
|
||||
max_xfer_len = MIN_NON_ZERO(max_xfer_len, BDRV_REQUEST_MAX_SECTORS);
|
||||
|
||||
qsort(mrb->reqs, mrb->num_reqs, sizeof(*mrb->reqs),
|
||||
&multireq_compare);
|
||||
|
@ -447,7 +447,7 @@ static bool virtio_blk_sect_range_ok(VirtIOBlock *dev,
|
|||
uint64_t nb_sectors = size >> BDRV_SECTOR_BITS;
|
||||
uint64_t total_sectors;
|
||||
|
||||
if (nb_sectors > INT_MAX) {
|
||||
if (nb_sectors > BDRV_REQUEST_MAX_SECTORS) {
|
||||
return false;
|
||||
}
|
||||
if (sector & dev->sector_mask) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue