From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBIif-0001dj-UO for qemu-devel@nongnu.org; Tue, 22 Dec 2015 03:54:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aBIic-0007ZU-Cr for qemu-devel@nongnu.org; Tue, 22 Dec 2015 03:54:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBIic-0007ZQ-7W for qemu-devel@nongnu.org; Tue, 22 Dec 2015 03:54:54 -0500 From: Stefan Hajnoczi Date: Tue, 22 Dec 2015 16:54:14 +0800 Message-Id: <1450774460-17259-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1450774460-17259-1-git-send-email-stefanha@redhat.com> References: <1450774460-17259-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 04/10] block: replace IOV_MAX with BlockLimits.max_iov List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi 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 --- block/io.c | 3 ++- hw/block/virtio-blk.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 42050a0..63e3678 100644 --- a/block/io.c +++ b/block/io.c @@ -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; } diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index f72d4b6..51f867b 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -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); -- 2.5.0