Commit da72c93f authored by Jim Harris's avatar Jim Harris
Browse files

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: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16458

 (master)

(cherry picked from commit ee31bc9d)
Change-Id: I8f7a6ca29fd69613d44a89adc7e60563b274d155
Signed-off-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16498


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent cb63fbcc
Loading
Loading
Loading
Loading
+31 −11
Original line number Diff line number Diff line
@@ -8,11 +8,25 @@ rootdir=$(readlink -f "$testdir/../..")
source "$rootdir/test/common/autotest_common.sh"
source "$rootdir/test/lvol/common.sh"

MALLOC_SIZE_MB=128
MALLOC_BS=4096
if [[ -z $1 ]]; then
	NUM_DEVS=4
	NUM_QUEUE=4
	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))
MAX_DEV_ID=$((NUM_DEVS - 1))

function test_create_ublk() {
	# create a ublk target
@@ -47,7 +61,7 @@ function test_create_multi_ublk() {
	# create a ublk 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
		malloc_name=$(rpc_cmd bdev_malloc_create -b "Malloc${i}" $MALLOC_SIZE_MB $MALLOC_BS)
		# add ublk device
@@ -55,7 +69,7 @@ function test_create_multi_ublk() {
	done

	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
		[[ "$(jq -r ".[${i}].ublk_device" <<< "$ublk_dev")" = "/dev/ublkb${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}" ]]
	done

	# clean up
	for i in {0..3}; do
	# To help test the ctrl cmd queuing logic, we omit the ublk_stop_disk
	# 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}"
		done
	rpc_cmd ublk_destroy_target
	fi

	# 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 {0..3}; do
	for i in $(seq 0 $MAX_DEV_ID); do
		rpc_cmd bdev_malloc_delete "Malloc${i}"
	done
	check_leftover_devices