test/ublk: add parameter for num devices

test/ublk/ublk.sh 256

will now create 256 ublk devices, to try to test
the ctrlr_cmd queueing logic when the ctrl uring
runs out of sqes.

It's actually difficult to induce the condition,
since the kernel SQPOLL thread can usually keep
up with the SPDK process submitting the control
commands.  The best way to induce it is by
*not* stopping the disks at the end of a test
with a lot of disks, and letting ublk_destroy_target
stop all of them at once.  Even then, with the
ublk logging enabled, even that extra delay for
each commands opcode is enough to help the
SQPOLL thread to keep up.  Commenting out the
first UBLK_DEBUGLOG in ublk_ctrl_cmd() does help
it run out of sqes, at least in my setup.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I8f7a6ca29fd69613d44a89adc7e60563b274d155
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16458
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Jim Harris 2023-01-24 17:56:05 +00:00 committed by Tomasz Zawadzki
parent 93f09b1627
commit ee31bc9d19

View File

@ -8,11 +8,25 @@ rootdir=$(readlink -f "$testdir/../..")
source "$rootdir/test/common/autotest_common.sh" source "$rootdir/test/common/autotest_common.sh"
source "$rootdir/test/lvol/common.sh" source "$rootdir/test/lvol/common.sh"
MALLOC_SIZE_MB=128 if [[ -z $1 ]]; then
MALLOC_BS=4096 NUM_DEVS=4
NUM_QUEUE=4 NUM_QUEUE=4
QUEUE_DEPTH=512 QUEUE_DEPTH=512
MALLOC_SIZE_MB=128
# issue ublk_stop_disk cmds before ublk_destroy_target
STOP_DISKS=1
else
# Use smaller parameters when user specifies the number
# of devices, to guard against memory exhaustion.
NUM_DEVS=$1
NUM_QUEUE=1
QUEUE_DEPTH=16
MALLOC_SIZE_MB=2
fi
MALLOC_BS=4096
FILE_SIZE=$((MALLOC_SIZE_MB * 1024 * 1024)) FILE_SIZE=$((MALLOC_SIZE_MB * 1024 * 1024))
MAX_DEV_ID=$((NUM_DEVS - 1))
function test_create_ublk() { function test_create_ublk() {
# create a ublk target # create a ublk target
@ -47,7 +61,7 @@ function test_create_multi_ublk() {
# create a ublk target # create a ublk target
ublk_target=$(rpc_cmd ublk_create_target) ublk_target=$(rpc_cmd ublk_create_target)
for i in {0..3}; do for i in $(seq 0 $MAX_DEV_ID); do
# create a malloc bdev # create a malloc bdev
malloc_name=$(rpc_cmd bdev_malloc_create -b "Malloc${i}" $MALLOC_SIZE_MB $MALLOC_BS) malloc_name=$(rpc_cmd bdev_malloc_create -b "Malloc${i}" $MALLOC_SIZE_MB $MALLOC_BS)
# add ublk device # add ublk device
@ -55,7 +69,7 @@ function test_create_multi_ublk() {
done done
ublk_dev=$(rpc_cmd ublk_get_disks) ublk_dev=$(rpc_cmd ublk_get_disks)
for i in {0..3}; do for i in $(seq 0 $MAX_DEV_ID); do
# verify its parameters # verify its parameters
[[ "$(jq -r ".[${i}].ublk_device" <<< "$ublk_dev")" = "/dev/ublkb${i}" ]] [[ "$(jq -r ".[${i}].ublk_device" <<< "$ublk_dev")" = "/dev/ublkb${i}" ]]
[[ "$(jq -r ".[${i}].id" <<< "$ublk_dev")" = "${i}" ]] [[ "$(jq -r ".[${i}].id" <<< "$ublk_dev")" = "${i}" ]]
@ -64,13 +78,19 @@ function test_create_multi_ublk() {
[[ "$(jq -r ".[${i}].bdev_name" <<< "$ublk_dev")" = "Malloc${i}" ]] [[ "$(jq -r ".[${i}].bdev_name" <<< "$ublk_dev")" = "Malloc${i}" ]]
done done
# clean up # To help test the ctrl cmd queuing logic, we omit the ublk_stop_disk
for i in {0..3}; do # RPCs. Then the ublk_destroy_target RPC will stop all of the disks
# in very quick succession which exhausts the control io_uring SQEs
if [[ "$STOP_DISKS" = "1" ]]; then
for i in $(seq 0 $MAX_DEV_ID); do
rpc_cmd ublk_stop_disk "${i}" rpc_cmd ublk_stop_disk "${i}"
done done
rpc_cmd ublk_destroy_target fi
for i in {0..3}; do # Shutting down a lot of disks can take a long time, so extend the RPC timeout
"$rootdir/scripts/rpc.py" -t 120 ublk_destroy_target
for i in $(seq 0 $MAX_DEV_ID); do
rpc_cmd bdev_malloc_delete "Malloc${i}" rpc_cmd bdev_malloc_delete "Malloc${i}"
done done
check_leftover_devices check_leftover_devices