qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] virtio-blk: seg_max do not subtract 2 if host has VIRTIO_RING_F_INDIRECT_DESC feature
@ 2020-11-20  5:03 zhaoxin\RockCuioc
  0 siblings, 0 replies; only message in thread
From: zhaoxin\RockCuioc @ 2020-11-20  5:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: RockCui, CobeChen, flyfan

v1 -> v2:
    fix codestyle checked by checkpatch.pl

This patch modify virtio-blk seg_max when host has VIRTIO_RING_F_INDIRECT_DESC feature, when read/write virtio-blk disk in direct mode, 
this patch can make the bio reach 512k but not 504k if the user buffer physical segments are all discontinuous,when use ceph the size of 504k 
will affect performance.This patch should be used in guest kernel version>=4.14, kernel after this version virtio driver does not judge 
total_sg and vring num if the host supports indirect descriptor tables.  

Signed-off-by: zhaoxin\RockCuioc <RockCui-oc@zhaoxin.com>
---
 hw/block/virtio-blk.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index bac2d6f..40bbbd7 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -932,7 +932,11 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
     blk_get_geometry(s->blk, &capacity);
     memset(&blkcfg, 0, sizeof(blkcfg));
     virtio_stq_p(vdev, &blkcfg.capacity, capacity);
-    virtio_stl_p(vdev, &blkcfg.seg_max,
+    if virtio_host_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC)
+        virtio_stl_p(vdev, &blkcfg.seg_max,
+                 s->conf.seg_max_adjust ? s->conf.queue_size : 128);
+    else
+        virtio_stl_p(vdev, &blkcfg.seg_max,
                  s->conf.seg_max_adjust ? s->conf.queue_size - 2 : 128 - 2);
     virtio_stw_p(vdev, &blkcfg.geometry.cylinders, conf->cyls);
     virtio_stl_p(vdev, &blkcfg.blk_size, blk_size);
-- 
2.10.1.windows.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-20  5:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-20  5:03 [PATCH v2] virtio-blk: seg_max do not subtract 2 if host has VIRTIO_RING_F_INDIRECT_DESC feature zhaoxin\RockCuioc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).