From cf680fe47e3eb40ea42bcf602349b191ae84d74c Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Sun, 5 May 2019 21:24:57 -0400 Subject: [PATCH] vhost_blk: set the maximum supported data segment based on bdev AIO backend requires aligned data buffers, and the maximum IOVs supported in bdev module is defined to 32, there are cases for Windows Guest which will send data segments more than 32, SPDK can't process such cases, so here we can set the 'seg_max' parameter based on bdev module capability. Also set the maximum segment size for those requests. Fix issue #625. Change-Id: I0ff61e55872af17115c0b6b28425e70cb8769790 Signed-off-by: Changpeng Liu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452378 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Darek Stojaczyk Reviewed-by: Ben Walker --- lib/vhost/vhost_blk.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/vhost/vhost_blk.c b/lib/vhost/vhost_blk.c index 5d4b40ec9..315409850 100644 --- a/lib/vhost/vhost_blk.c +++ b/lib/vhost/vhost_blk.c @@ -35,6 +35,7 @@ #include "spdk/env.h" #include "spdk/bdev.h" +#include "spdk/bdev_module.h" #include "spdk/conf.h" #include "spdk/thread.h" #include "spdk/likely.h" @@ -896,6 +897,14 @@ spdk_vhost_blk_get_config(struct spdk_vhost_dev *vdev, uint8_t *config, } else { blk_size = spdk_bdev_get_block_size(bdev); blkcnt = spdk_bdev_get_num_blocks(bdev); + if (spdk_bdev_get_buf_align(bdev) > 1) { + blkcfg.size_max = SPDK_BDEV_LARGE_BUF_MAX_SIZE; + blkcfg.seg_max = spdk_min(SPDK_VHOST_IOVS_MAX - 2 - 1, BDEV_IO_NUM_CHILD_IOV - 2 - 1); + } else { + blkcfg.size_max = 131072; + /* -2 for REQ and RESP and -1 for region boundary splitting */ + blkcfg.seg_max = SPDK_VHOST_IOVS_MAX - 2 - 1; + } } memset(&blkcfg, 0, sizeof(blkcfg)); @@ -904,9 +913,6 @@ spdk_vhost_blk_get_config(struct spdk_vhost_dev *vdev, uint8_t *config, blkcfg.min_io_size = 1; /* expressed in 512 Bytes sectors */ blkcfg.capacity = (blkcnt * blk_size) / 512; - blkcfg.size_max = 131072; - /* -2 for REQ and RESP and -1 for region boundary splitting */ - blkcfg.seg_max = SPDK_VHOST_IOVS_MAX - 2 - 1; /* QEMU can overwrite this value when started */ blkcfg.num_queues = SPDK_VHOST_MAX_VQUEUES;