test/vhost: Partition the VM drive more gracefully

Check at which sector location it's safe to start the test partition.
Also, make sure that the VM drive matches the size which is used for
creating the lvol.

Also, reorder pt sync with sleep - we should make sure that partprobe
is called after block subsystem was properly updated. Extend the sleep
time just to be more on a safe side.

Change-Id: I789c8842fb8d136bb1eec1f7793019b18297c864
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5035
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
This commit is contained in:
Michal Berger 2020-11-06 13:04:34 +01:00 committed by Tomasz Zawadzki
parent feb6830021
commit 0f89273f81

View File

@ -74,8 +74,9 @@ if [[ $nvme_bdev_bs != 512 ]]; then
false
fi
lvb_size=20000 # MB
lvs_u=$($rpc_py bdev_lvol_create_lvstore Nvme0n1 lvs0)
lvb_u=$($rpc_py bdev_lvol_create -u $lvs_u lvb0 20000)
lvb_u=$($rpc_py bdev_lvol_create -u $lvs_u lvb0 "$lvb_size")
timing_exit create_lvol
timing_enter convert_vm_image
@ -100,8 +101,19 @@ vm_run $vm_no
vm_wait_for_boot 300 $vm_no
timing_exit setup_vm
start_part_sector=0 drive_size=0
while IFS=":" read -r id start end _; do
start=${start%s} end=${end%s}
[[ -b $id ]] && drive_size=$start
[[ $id =~ ^[0-9]+$ ]] && start_part_sector=$((end + 1))
done < <(vm_exec "$vm_no" "parted /dev/sda -ms unit s print")
# If we didn't get a start sector for the partition then probably something is amiss. Also,
# check if size of the drive matches size used for creating lvb and if not, fail.
((start_part_sector > 0)) && (((drive_size * 512) >> 20 == lvb_size))
timing_enter run_vm_cmd
vm_exec $vm_no "parted -s /dev/sda mkpart primary 10GB 100%; partprobe; sleep 0.1;"
vm_exec $vm_no "parted -s /dev/sda mkpart primary ${start_part_sector}s 100%; sleep 1; partprobe"
vm_exec $vm_no "mkfs.ext4 -F /dev/sda2; mkdir -p /mnt/sda2test; mount /dev/sda2 /mnt/sda2test;"
vm_exec $vm_no "fio --name=integrity --bsrange=4k-512k --iodepth=128 --numjobs=1 --direct=1 \
--thread=1 --group_reporting=1 --rw=randrw --rwmixread=70 --filename=/mnt/sda2test/test_file \