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: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
b1c2b3f546
commit
ed61bf79fb
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user