Commit e84c2091 authored by Max Gurtovoy's avatar Max Gurtovoy Committed by Christoph Hellwig

nvmet: never fail double namespace enablement

In case we create N namespaces while N < NVMET_MAX_NAMESPACES, we can
perform "echo 1 > <nsid>/enable" as much as we want. In case N ==
NVMET_MAX_NAMESPACES we fail. Make sure we have the same flow for any N.
Signed-off-by: default avatarMax Gurtovoy <maxg@mellanox.com>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 70479b71
...@@ -494,13 +494,14 @@ int nvmet_ns_enable(struct nvmet_ns *ns) ...@@ -494,13 +494,14 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
int ret; int ret;
mutex_lock(&subsys->lock); mutex_lock(&subsys->lock);
ret = -EMFILE;
if (subsys->nr_namespaces == NVMET_MAX_NAMESPACES)
goto out_unlock;
ret = 0; ret = 0;
if (ns->enabled) if (ns->enabled)
goto out_unlock; goto out_unlock;
ret = -EMFILE;
if (subsys->nr_namespaces == NVMET_MAX_NAMESPACES)
goto out_unlock;
ret = nvmet_bdev_ns_enable(ns); ret = nvmet_bdev_ns_enable(ns);
if (ret == -ENOTBLK) if (ret == -ENOTBLK)
ret = nvmet_file_ns_enable(ns); ret = nvmet_file_ns_enable(ns);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment