Commit ed61bf79 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Jim Harris
Browse files

nvmf: ensure there is room before claiming a bdev



Previously, if the maximum number of virtual namespaces had already been
reached, adding a bdev to a subsystem would claim it without actually
adding it to the ns_list array.

Change-Id: Iab68ad1a75748c0e88232240185695aac08d71d2
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent b1c2b3f5
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -465,12 +465,6 @@ spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bd
{
	int i = 0;

	if (!spdk_bdev_claim(bdev, NULL, NULL)) {
		SPDK_ERRLOG("Subsystem %s: bdev %s is already claimed\n",
			    subsystem->subnqn, bdev->name);
		return -1;
	}

	assert(subsystem->mode == NVMF_SUBSYSTEM_MODE_VIRTUAL);
	while (i < MAX_VIRTUAL_NAMESPACE && subsystem->dev.virt.ns_list[i]) {
		i++;
@@ -479,6 +473,13 @@ spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bd
		SPDK_ERRLOG("spdk_nvmf_subsystem_add_ns() failed\n");
		return -1;
	}

	if (!spdk_bdev_claim(bdev, NULL, NULL)) {
		SPDK_ERRLOG("Subsystem %s: bdev %s is already claimed\n",
			    subsystem->subnqn, bdev->name);
		return -1;
	}

	subsystem->dev.virt.ns_list[i] = bdev;
	subsystem->dev.virt.ns_count++;
	return 0;