bdev/nvme: check discovery service trids during start
Check that we're not already connected to a discovery service that has the same address (or has a referall to) as the service we're trying to start. Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Change-Id: I84863fd959f62b30e9a348f69d10c7f1edffda7a Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12627 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: Shuhei Matsumoto <smatsumoto@nvidia.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
parent
33c14a1445
commit
ef675d38c1
@ -5170,10 +5170,23 @@ bdev_nvme_start_discovery(struct spdk_nvme_transport_id *trid,
|
|||||||
struct discovery_ctx *ctx;
|
struct discovery_ctx *ctx;
|
||||||
struct discovery_entry_ctx *discovery_entry_ctx;
|
struct discovery_entry_ctx *discovery_entry_ctx;
|
||||||
|
|
||||||
|
snprintf(trid->subnqn, sizeof(trid->subnqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
|
||||||
TAILQ_FOREACH(ctx, &g_discovery_ctxs, tailq) {
|
TAILQ_FOREACH(ctx, &g_discovery_ctxs, tailq) {
|
||||||
if (strcmp(ctx->name, base_name) == 0) {
|
if (strcmp(ctx->name, base_name) == 0) {
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctx->entry_ctx_in_use != NULL) {
|
||||||
|
if (!spdk_nvme_transport_id_compare(trid, &ctx->entry_ctx_in_use->trid)) {
|
||||||
|
return -EEXIST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TAILQ_FOREACH(discovery_entry_ctx, &ctx->discovery_entry_ctxs, tailq) {
|
||||||
|
if (!spdk_nvme_transport_id_compare(trid, &discovery_entry_ctx->trid)) {
|
||||||
|
return -EEXIST;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = calloc(1, sizeof(*ctx));
|
ctx = calloc(1, sizeof(*ctx));
|
||||||
@ -5200,7 +5213,6 @@ bdev_nvme_start_discovery(struct spdk_nvme_transport_id *trid,
|
|||||||
ctx->cb_ctx = cb_ctx;
|
ctx->cb_ctx = cb_ctx;
|
||||||
TAILQ_INIT(&ctx->nvm_entry_ctxs);
|
TAILQ_INIT(&ctx->nvm_entry_ctxs);
|
||||||
TAILQ_INIT(&ctx->discovery_entry_ctxs);
|
TAILQ_INIT(&ctx->discovery_entry_ctxs);
|
||||||
snprintf(trid->subnqn, sizeof(trid->subnqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
|
|
||||||
memcpy(&ctx->trid, trid, sizeof(*trid));
|
memcpy(&ctx->trid, trid, sizeof(*trid));
|
||||||
/* Even if user did not specify hostnqn, we can still strdup("\0"); */
|
/* Even if user did not specify hostnqn, we can still strdup("\0"); */
|
||||||
ctx->hostnqn = strdup(ctx->drv_opts.hostnqn);
|
ctx->hostnqn = strdup(ctx->drv_opts.hostnqn);
|
||||||
|
@ -145,6 +145,12 @@ NOT $rpc_py -s $HOST_SOCK bdev_nvme_start_discovery -b nvme -t $TEST_TRANSPORT \
|
|||||||
[[ $(get_discovery_ctrlrs) == "nvme" ]]
|
[[ $(get_discovery_ctrlrs) == "nvme" ]]
|
||||||
[[ $(get_bdev_list) == "nvme0n1 nvme0n2" ]]
|
[[ $(get_bdev_list) == "nvme0n1 nvme0n2" ]]
|
||||||
|
|
||||||
|
# Make sure that it's also impossible to start the discovery using the same trid
|
||||||
|
NOT $rpc_py -s $HOST_SOCK bdev_nvme_start_discovery -b nvme_second -t $TEST_TRANSPORT \
|
||||||
|
-a $NVMF_FIRST_TARGET_IP -s $DISCOVERY_PORT -f ipv4 -q $HOST_NQN -w
|
||||||
|
[[ $(get_discovery_ctrlrs) == "nvme" ]]
|
||||||
|
[[ $(get_bdev_list) == "nvme0n1 nvme0n2" ]]
|
||||||
|
|
||||||
trap - SIGINT SIGTERM EXIT
|
trap - SIGINT SIGTERM EXIT
|
||||||
|
|
||||||
kill $hostpid
|
kill $hostpid
|
||||||
|
Loading…
Reference in New Issue
Block a user