mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
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: Max Gurtovoy <maxg@mellanox.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
70479b71bc
commit
e84c2091a4
@ -494,13 +494,14 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
|
||||
int ret;
|
||||
|
||||
mutex_lock(&subsys->lock);
|
||||
ret = -EMFILE;
|
||||
if (subsys->nr_namespaces == NVMET_MAX_NAMESPACES)
|
||||
goto out_unlock;
|
||||
ret = 0;
|
||||
if (ns->enabled)
|
||||
goto out_unlock;
|
||||
|
||||
ret = -EMFILE;
|
||||
if (subsys->nr_namespaces == NVMET_MAX_NAMESPACES)
|
||||
goto out_unlock;
|
||||
|
||||
ret = nvmet_bdev_ns_enable(ns);
|
||||
if (ret == -ENOTBLK)
|
||||
ret = nvmet_file_ns_enable(ns);
|
||||
|
Loading…
Reference in New Issue
Block a user