Skip to content

Commit

Permalink
block: replace IOV_MAX with BlockLimits.max_iov
Browse files Browse the repository at this point in the history
Request merging must not result in a huge request that exceeds the
maximum number of iovec elements.  Use BlockLimits.max_iov instead of
hardcoding IOV_MAX.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
stefanhaRH committed Dec 22, 2015
1 parent 648296e commit 222565f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion block/io.c
Expand Up @@ -1889,7 +1889,8 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs,
merge = 1;
}

if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) {
if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 >
bs->bl.max_iov) {
merge = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion hw/block/virtio-blk.c
Expand Up @@ -414,7 +414,7 @@ void virtio_blk_submit_multireq(BlockBackend *blk, MultiReqBuffer *mrb)
* 3. merge would exceed maximum transfer length of backend device
*/
if (sector_num + nb_sectors != req->sector_num ||
niov > IOV_MAX - req->qiov.niov ||
niov > blk_get_max_iov(blk) - req->qiov.niov ||
req->qiov.size / BDRV_SECTOR_SIZE > max_xfer_len ||
nb_sectors > max_xfer_len - req->qiov.size / BDRV_SECTOR_SIZE) {
submit_requests(blk, mrb, start, num_reqs, niov);
Expand Down

0 comments on commit 222565f

Please sign in to comment.