bdev/nvme: In bdev_nvme_attach_controllers, if adding a path the subnqn

must match.

Change-Id: I4e19ab8668268b273580d2b23ec30eafe21001ef
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9342
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ben Walker 2021-08-30 13:42:52 -07:00 committed by Tomasz Zawadzki
parent 8dfefec509
commit 4fb3fea387
2 changed files with 24 additions and 0 deletions

View File

@ -390,6 +390,16 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
/* This controller already exists. Verify the parameters match sufficiently. */
opts = spdk_nvme_ctrlr_get_opts(ctrlr->ctrlr);
if (strncmp(trid.subnqn,
spdk_nvme_ctrlr_get_transport_id(ctrlr->ctrlr)->subnqn,
SPDK_NVMF_NQN_MAX_LEN) != 0) {
/* Different SUBNQN is not allowed when specifying the same controller name. */
spdk_jsonrpc_send_error_response_fmt(request, -EINVAL,
"A controller named %s already exists, but uses a different subnqn (%s)\n",
ctx->req.name, spdk_nvme_ctrlr_get_transport_id(ctrlr->ctrlr)->subnqn);
goto cleanup;
}
if (strncmp(ctx->req.opts.hostnqn, opts->hostnqn, SPDK_NVMF_NQN_MAX_LEN) != 0) {
/* Different HOSTNQN is not allowed when specifying the same controller name. */
spdk_jsonrpc_send_error_response_fmt(request, -EINVAL,

View File

@ -24,12 +24,21 @@ nvmftestinit
nvmfappstart -m 0xF
$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192
$rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc0
$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001
$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc0
$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_SECOND_PORT
$rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc1
$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode2 -a -s SPDK00000000000002
$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode2 Malloc1
$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode2 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode2 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_SECOND_PORT
$rootdir/test/bdev/bdevperf/bdevperf -z -r $bdevperf_rpc_sock -q 128 -o 4096 -w write -t 1 -f &> $testdir/try.txt &
bdevperf_pid=$!
@ -51,6 +60,10 @@ NOT $rpc_py -s $bdevperf_rpc_sock bdev_nvme_attach_controller -b NVMe0 -t $TEST_
-s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode1 -i $NVMF_FIRST_TARGET_IP -c $NVMF_HOST_FIRST_PORT \
-q nqn.2021-09-7.io.spdk:00001
# try to attach with same controller name but different subnqn. Should fail.
NOT $rpc_py -s $bdevperf_rpc_sock bdev_nvme_attach_controller -b NVMe0 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \
-s $NVMF_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode2 -i $NVMF_FIRST_TARGET_IP -c $NVMF_HOST_FIRST_PORT
# Add a second path without specifying the host information. Should pass.
$rpc_py -s $bdevperf_rpc_sock bdev_nvme_attach_controller -b NVMe0 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \
-s $NVMF_SECOND_PORT -f ipv4 -n nqn.2016-06.io.spdk:cnode1
@ -76,6 +89,7 @@ $rpc_py -s $bdevperf_rpc_sock bdev_nvme_detach_controller NVMe1
killprocess $bdevperf_pid
$rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1
$rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode2
trap - SIGINT SIGTERM EXIT