qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 04/10] block: replace IOV_MAX with BlockLimits.max_io


From: Stefan Hajnoczi
Subject: [Qemu-devel] [PULL 04/10] block: replace IOV_MAX with BlockLimits.max_iov
Date: Tue, 22 Dec 2015 16:54:14 +0800

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]