tests: wait for each start and stop nbd disk RPC
This workaround is needed to stop EBUSY errors from NBD ioctls(). This can be fixed in NBD bdev code but till that point lets merge this workaround. Change-Id: Ic1546963538beda4d4409cef93062103e2a23e34 Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/434040 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
b86e1be001
commit
bf9dbae56b
@ -4,19 +4,17 @@ function nbd_start_disks() {
|
||||
local rpc_server=$1
|
||||
local bdev_list=($2)
|
||||
local nbd_list=($3)
|
||||
local i
|
||||
|
||||
for (( i=0; i<${#nbd_list[@]}; i++ )); do
|
||||
$rootdir/scripts/rpc.py -s $rpc_server start_nbd_disk \
|
||||
${bdev_list[$i]} ${nbd_list[$i]}
|
||||
done
|
||||
# Wait for nbd devices ready
|
||||
for i in ${nbd_list[@]}; do
|
||||
waitfornbd ${i:5}
|
||||
$rootdir/scripts/rpc.py -s $rpc_server start_nbd_disk ${bdev_list[$i]} ${nbd_list[$i]}
|
||||
# Wait for nbd device ready
|
||||
waitfornbd $(basename ${nbd_list[$i]})
|
||||
done
|
||||
}
|
||||
|
||||
function waitfornbd_exit() {
|
||||
nbd_name=$1
|
||||
local nbd_name=$1
|
||||
|
||||
for ((i=1; i<=20; i++)); do
|
||||
if grep -q -w $nbd_name /proc/partitions; then
|
||||
@ -32,12 +30,11 @@ function waitfornbd_exit() {
|
||||
function nbd_stop_disks() {
|
||||
local rpc_server=$1
|
||||
local nbd_list=($2)
|
||||
local i
|
||||
|
||||
for i in ${nbd_list[@]}; do
|
||||
$rootdir/scripts/rpc.py -s $rpc_server stop_nbd_disk $i
|
||||
done
|
||||
for i in ${nbd_list[@]}; do
|
||||
waitfornbd_exit ${i:5}
|
||||
waitfornbd_exit $(basename $i)
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,9 @@ modprobe nbd
|
||||
timing_enter nbd_json_config_create_setup
|
||||
$rpc_py construct_malloc_bdev 128 512 --name Malloc0
|
||||
$rpc_py start_nbd_disk Malloc0 /dev/nbd0
|
||||
waitfornbd nbd0
|
||||
$rpc_py start_nbd_disk Nvme0n1 /dev/nbd1
|
||||
waitfornbd nbd1
|
||||
timing_exit nbd_json_config_create_setup
|
||||
|
||||
timing_enter nbd_json_config_test
|
||||
|
@ -337,7 +337,8 @@ function waitforlisten() {
|
||||
}
|
||||
|
||||
function waitfornbd() {
|
||||
nbd_name=$1
|
||||
local nbd_name=$1
|
||||
local i
|
||||
|
||||
for ((i=1; i<=20; i++)); do
|
||||
if grep -q -w $nbd_name /proc/partitions; then
|
||||
@ -527,7 +528,7 @@ function part_dev_by_gpt () {
|
||||
waitforlisten $nbd_pid $rpc_server
|
||||
|
||||
# Start bdev as a nbd device
|
||||
$rootdir/scripts/rpc.py -s "$rpc_server" start_nbd_disk $devname $nbd_path
|
||||
nbd_start_disks "$rpc_server" $devname $nbd_path
|
||||
|
||||
waitfornbd ${nbd_path:5}
|
||||
|
||||
@ -545,7 +546,7 @@ function part_dev_by_gpt () {
|
||||
dd if=/dev/zero of=$nbd_path bs=4096 count=8 oflag=direct
|
||||
fi
|
||||
|
||||
$rootdir/scripts/rpc.py -s "$rpc_server" stop_nbd_disk $nbd_path
|
||||
nbd_stop_disks "$rpc_server" $nbd_path
|
||||
|
||||
killprocess $nbd_pid
|
||||
rm -f ${conf}.gpt
|
||||
|
@ -1,8 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -xe
|
||||
|
||||
basedir=$(readlink -f $(dirname $0))
|
||||
. $basedir/../common/common.sh
|
||||
testdir=$(readlink -f $(dirname $0))
|
||||
rootdir=$(readlink -f $testdir/../../..)
|
||||
. $testdir/../common/common.sh
|
||||
. $rootdir/test/bdev/nbd_common.sh
|
||||
|
||||
rpc_py="python $SPDK_BUILD_DIR/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
|
||||
vm_no="0"
|
||||
|
||||
@ -65,11 +68,11 @@ timing_exit create_lvol
|
||||
|
||||
timing_enter convert_vm_image
|
||||
modprobe nbd
|
||||
trap '$rpc_py stop_nbd_disk /dev/nbd0; rmmod nbd; err_clean "${FUNCNAME}" "${LINENO}"' ERR
|
||||
$rpc_py start_nbd_disk $lvb_u /dev/nbd0
|
||||
trap 'nbd_stop_disks $(get_vhost_dir)/rpc.sock /dev/nbd0; rmmod nbd; err_clean "${FUNCNAME}" "${LINENO}"' ERR
|
||||
nbd_start_disks "$(get_vhost_dir)/rpc.sock" $lvb_u /dev/nbd0
|
||||
$QEMU_PREFIX/bin/qemu-img convert $os_image -O raw /dev/nbd0
|
||||
sync
|
||||
$rpc_py stop_nbd_disk /dev/nbd0
|
||||
nbd_stop_disks $(get_vhost_dir)/rpc.sock /dev/nbd0
|
||||
sleep 1
|
||||
rmmod nbd
|
||||
timing_exit convert_vm_image
|
||||
|
Loading…
Reference in New Issue
Block a user