bdev/nvme: don't allow duplicate discovery service names
Otherwise, we'll try to use the same name to create the bdevs. Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Change-Id: I38cfb9073f343a7bf3966754008065c7ab89e609 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12626 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
parent
90aba31ac3
commit
33c14a1445
@ -5170,6 +5170,12 @@ bdev_nvme_start_discovery(struct spdk_nvme_transport_id *trid,
|
||||
struct discovery_ctx *ctx;
|
||||
struct discovery_entry_ctx *discovery_entry_ctx;
|
||||
|
||||
TAILQ_FOREACH(ctx, &g_discovery_ctxs, tailq) {
|
||||
if (strcmp(ctx->name, base_name) == 0) {
|
||||
return -EEXIST;
|
||||
}
|
||||
}
|
||||
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
return -ENOMEM;
|
||||
|
@ -62,6 +62,10 @@ function get_subsystem_paths() {
|
||||
$rpc_py -s $HOST_SOCK bdev_nvme_get_controllers -n $1 | jq -r '.[].ctrlrs[].trid.trsvcid' | sort -n | xargs
|
||||
}
|
||||
|
||||
function get_discovery_ctrlrs() {
|
||||
$rpc_py -s $HOST_SOCK bdev_nvme_get_discovery_info | jq -r '.[].name' | sort | xargs
|
||||
}
|
||||
|
||||
# Note that tests need to call get_notification_count and then check $notification_count,
|
||||
# because if we use $(get_notification_count), the notify_id gets updated in the subshell.
|
||||
notify_id=0
|
||||
@ -133,6 +137,14 @@ sleep 1 # Wait a bit to make sure the discovery service has a chance to detect t
|
||||
get_notification_count
|
||||
[[ $notification_count == 2 ]]
|
||||
|
||||
# Make sure that it's not possible to start two discovery services with the same name
|
||||
$rpc_py -s $HOST_SOCK bdev_nvme_start_discovery -b nvme -t $TEST_TRANSPORT \
|
||||
-a $NVMF_FIRST_TARGET_IP -s $DISCOVERY_PORT -f ipv4 -q $HOST_NQN -w
|
||||
NOT $rpc_py -s $HOST_SOCK bdev_nvme_start_discovery -b nvme -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
|
||||
|
||||
kill $hostpid
|
||||
|
Loading…
Reference in New Issue
Block a user