From ab0a3f8f33ce7edf815444fc1c772297dbdc560f Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 18 Feb 2021 21:18:09 +0000 Subject: [PATCH] nvmf: do not pause a namespace when resizing SPDK block devices can only be resized up when it is open. So there is no need to pause the associated namespace itself when resized - just pausing the subsystem is enough. Also modify the ns_hotplug_test to do null bdev resizing - this will help test this resize code path. Signed-off-by: Jim Harris Change-Id: I3cb7b9de0892c296f2abf2280bed434d18ebe6b5 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6467 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Aleksey Marchuk Reviewed-by: Reviewed-by: Shuhei Matsumoto --- lib/nvmf/subsystem.c | 5 ++++- test/nvmf/target/ns_hotplug_stress.sh | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/nvmf/subsystem.c b/lib/nvmf/subsystem.c index 8a3dd3b32..59a52dd09 100644 --- a/lib/nvmf/subsystem.c +++ b/lib/nvmf/subsystem.c @@ -1298,7 +1298,10 @@ nvmf_ns_resize(void *event_ctx) ns_ctx->nsid = ns->opts.nsid; ns_ctx->cb_fn = _nvmf_ns_resize; - rc = spdk_nvmf_subsystem_pause(ns->subsystem, ns_ctx->nsid, _nvmf_ns_resize, ns_ctx); + /* Specify 0 for the nsid here, because we do not need to pause the namespace. + * Namespaces can only be resized bigger, so there is no need to quiesce I/O. + */ + rc = spdk_nvmf_subsystem_pause(ns->subsystem, 0, _nvmf_ns_resize, ns_ctx); if (rc) { if (rc == -EBUSY) { /* Try again, this is not a permanent situation. */ diff --git a/test/nvmf/target/ns_hotplug_stress.sh b/test/nvmf/target/ns_hotplug_stress.sh index f39dbd952..d4e02e8d7 100755 --- a/test/nvmf/target/ns_hotplug_stress.sh +++ b/test/nvmf/target/ns_hotplug_stress.sh @@ -10,6 +10,8 @@ rpc_py="$rootdir/scripts/rpc.py" nvmftestinit nvmfappstart -m 0xE +null_size=1000 + $rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 -m 10 @@ -17,7 +19,7 @@ $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPOR $rpc_py bdev_malloc_create 32 512 -b Malloc0 $rpc_py bdev_delay_create -b Malloc0 -d Delay0 -r 1000000 -t 1000000 -w 1000000 -n 1000000 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Delay0 -$rpc_py bdev_null_create NULL1 1000 512 +$rpc_py bdev_null_create NULL1 $null_size 512 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 NULL1 # Note: use -Q option to rate limit the error messages that perf will spew due to the @@ -29,6 +31,10 @@ PERF_PID=$! while kill -0 $PERF_PID; do $rpc_py nvmf_subsystem_remove_ns nqn.2016-06.io.spdk:cnode1 1 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Delay0 + # Also test bdev/namespace resizing here, since it has a similar + # effect on subsystem/namespace handling in the nvmf target + null_size=$((null_size + 1)) + $rpc_py bdev_null_resize NULL1 $null_size done wait $PERF_PID