From 8216e70a1485e0acb8b2d23f29ff20269942b53b Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 2 Aug 2022 17:58:36 +0000 Subject: [PATCH] Revert "test/vhost/initiator: Don't use spdk_tgt to generate json config" This reverts commit 0c30154eb5d8584dcdf13c91b3f86bfcf9c3a44f. Make a change in the revert to pre-allocate 1GB of memory for the spdk_tgt initiator process, which is required for the virtio initiator. Fixes issue #2596. Signed-off-by: Jim Harris Change-Id: Id594fa1ccb2daf535b1aaaef0a397bda2ec98579 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13828 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Dong Yi Reviewed-by: Ben Walker --- test/vhost/initiator/blockdev.sh | 69 +++++++++++++------------------- 1 file changed, 27 insertions(+), 42 deletions(-) diff --git a/test/vhost/initiator/blockdev.sh b/test/vhost/initiator/blockdev.sh index e11c1a3c5..9f4181318 100755 --- a/test/vhost/initiator/blockdev.sh +++ b/test/vhost/initiator/blockdev.sh @@ -10,47 +10,11 @@ function run_spdk_fio() { } function err_cleanup() { + rm -f $testdir/bdev.json killprocess $vhost_pid -} - -function gen_vhost_conf() { - local traddr dev_type vg_count name conf setup - - setup+=("naa.Nvme0n1_scsi0.0 scsi 8 VirtioScsi0") - setup+=("naa.Nvme0n1_blk0.0 blk 8 VirtioBlk3") - setup+=("naa.Nvme0n1_blk1.0 blk 8 VirtioBlk4") - setup+=("naa.Malloc0.0 scsi 8 VirtioScsi1") - setup+=("naa.Malloc1.0 scsi 8 VirtioScsi2") - - while read -r traddr dev_type vg_count name; do - conf+=("$( - cat <<- VHOST - { - "method": "bdev_virtio_attach_controller", - "params": { - "name": "$name", - "dev_type": "$dev_type", - "trtype": "user", - "traddr": "$traddr", - "vq_count": $vg_count, - "vq_size": 512 - } - } - VHOST - )") - done < <(printf '%s\n' "${setup[@]}") - - local IFS="," - cat <<- VHOST - { - "subsystems": [ { - "subsystem": "bdev", - "config": [ - ${conf[*]} - ] - } ] - } - VHOST + if [[ -n "$dummy_spdk_pid" ]] && kill -0 $dummy_spdk_pid &> /dev/null; then + killprocess $dummy_spdk_pid + fi } # start vhost and configure it @@ -88,16 +52,37 @@ rpc_cmd vhost_create_scsi_controller naa.Malloc1.0 --cpumask 0xc rpc_cmd vhost_scsi_controller_add_target naa.Malloc1.0 0 Malloc1 [[ "$(rpc_cmd vhost_get_controllers -n naa.Malloc1.0 | jq -r '.[].cpumask')" == "0xc" ]] +# start a dummy app, create vhost bdevs in it, then dump the config for FIO +# Pre-allocate 1GB of memory for the application - virtio-user initiator requires it. See issue #2596. +$SPDK_BIN_DIR/spdk_tgt -r /tmp/spdk2.sock -g -s 1024 & +dummy_spdk_pid=$! +waitforlisten $dummy_spdk_pid /tmp/spdk2.sock +rpc_cmd -s /tmp/spdk2.sock bdev_virtio_attach_controller --trtype user --traddr 'naa.Nvme0n1_scsi0.0' -d scsi --vq-count 8 'VirtioScsi0' +rpc_cmd -s /tmp/spdk2.sock bdev_virtio_attach_controller --trtype user --traddr 'naa.Nvme0n1_blk0.0' -d blk --vq-count 8 'VirtioBlk3' +rpc_cmd -s /tmp/spdk2.sock bdev_virtio_attach_controller --trtype user --traddr 'naa.Nvme0n1_blk1.0' -d blk --vq-count 8 'VirtioBlk4' + +rpc_cmd -s /tmp/spdk2.sock bdev_virtio_attach_controller --trtype user --traddr 'naa.Malloc0.0' -d scsi --vq-count 8 'VirtioScsi1' +rpc_cmd -s /tmp/spdk2.sock bdev_virtio_attach_controller --trtype user --traddr 'naa.Malloc1.0' -d scsi --vq-count 8 'VirtioScsi2' + +cat <<- CONF > $testdir/bdev.json + {"subsystems":[ + $(rpc_cmd -s /tmp/spdk2.sock save_subsystem_config -n bdev) + ]} +CONF +killprocess $dummy_spdk_pid + +# run FIO with previously acquired spdk config files timing_enter run_spdk_fio -run_spdk_fio $testdir/bdev.fio --filename=* --section=job_randwrite --spdk_json_conf=<(gen_vhost_conf) +run_spdk_fio $testdir/bdev.fio --filename=* --section=job_randwrite --spdk_json_conf=$testdir/bdev.json timing_exit run_spdk_fio timing_enter run_spdk_fio_unmap -run_spdk_fio $testdir/bdev.fio --filename="VirtioScsi1t0:VirtioScsi2t0" --spdk_json_conf=<(gen_vhost_conf) +run_spdk_fio $testdir/bdev.fio --filename="VirtioScsi1t0:VirtioScsi2t0" --spdk_json_conf=$testdir/bdev.json timing_exit run_spdk_fio_unmap rpc_cmd bdev_nvme_detach_controller Nvme0 trap - SIGINT SIGTERM EXIT +rm -f $testdir/bdev.json killprocess $vhost_pid