Commit e5b455a1 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Ben Walker
Browse files

bdev/nvme: forbid attaching two controllers with the same name



Right now a controller with a duplicated name will likely
fail to create any bdevs (as those can't have duplicated
names), but will still attach successfully. There will be
two controllers with the very same name and while this
doesn't seem to cause any data corruptions, it introduces
slightly non-intuitive behavior. After all, the controllers
are identified by their name and those should be unique.

This wasn't a major concern until we allowed creating
NVMe controllers without any namespaces.

Change-Id: I55dd67ef0b4e8a23f19269f9967109c4f54aec95
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/434316


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
parent b86804ed
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1206,6 +1206,11 @@ spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
		return -1;
	}

	if (nvme_ctrlr_get_by_name(base_name)) {
		SPDK_ERRLOG("A controller with the provided name (%s) already exists.\n", base_name);
		return -1;
	}

	probe_ctx = calloc(1, sizeof(*probe_ctx));
	if (probe_ctx == NULL) {
		SPDK_ERRLOG("Failed to allocate probe_ctx\n");