Segfault occurs during connect to the subsystem when a namespace is added with a nsid smaller than the nsid previously added

Change-Id: I74c7b32e1713d683e5d80818724ed3b19f3dac64
Signed-off-by: suman chakraborty <suman.chakraborty@wdc.com>
Reviewed-on: https://review.gerrithub.io/405373
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
suman chakraborty 2018-03-21 11:46:23 +05:30 committed by Daniel Verkamp
parent af7cbd44b0
commit bc9423e229
2 changed files with 42 additions and 1 deletions

View File

@ -455,7 +455,13 @@ poll_group_update_subsystem(struct spdk_nvmf_poll_group *group,
old_num_channels = sgroup->num_channels;
if (new_num_channels == old_num_channels) {
/* Nothing to do */
/* Initialize new channels */
for (i = 0; i < new_num_channels; i++) {
ns = subsystem->ns[i];
if ((ns != NULL) && (sgroup->channels[i] == NULL)) {
sgroup->channels[i] = spdk_bdev_get_io_channel(ns->desc);
}
}
} else if (old_num_channels == 0) {
/* First allocation */
sgroup->channels = calloc(new_num_channels, sizeof(sgroup->channels[0]));

View File

@ -68,6 +68,41 @@ nvme connect -t rdma -n nqn.2016-06.io.spdk:cnode1 -q nqn.2016-06.io.spdk:host1
nvme disconnect -n nqn.2016-06.io.spdk:cnode1
$rpc_py delete_nvmf_subsystem nqn.2016-06.io.spdk:cnode1
# do frequent add delete of namespaces with different nsid.
for i in `seq 1 $times`
do
j=0
for bdev in $bdevs; do
let j=j+1
$rpc_py construct_nvmf_subsystem nqn.2016-06.io.spdk:cnode$j '' '' -s SPDK00000000000001
$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode$j $bdev -n 10
$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode$j $bdev -n 5
$rpc_py nvmf_subsystem_allow_any_host nqn.2016-06.io.spdk:cnode$j
nvme connect -t rdma -n nqn.2016-06.io.spdk:cnode$j -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
done
n=$j
for j in `seq 1 $n`
do
nvme disconnect -n nqn.2016-06.io.spdk:cnode$j
done
j=0
for bdev in $bdevs; do
let j=j+1
$rpc_py nvmf_subsystem_remove_ns nqn.2016-06.io.spdk:cnode$j 10
$rpc_py nvmf_subsystem_remove_ns nqn.2016-06.io.spdk:cnode$j 5
done
n=$j
for j in `seq 1 $n`
do
$rpc_py delete_nvmf_subsystem nqn.2016-06.io.spdk:cnode$j
done
done
nvmfcleanup
trap "killprocess $pid; exit 1" SIGINT SIGTERM EXIT