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;