Commit 344770b0 authored by Sagi Grimberg's avatar Sagi Grimberg

nvmet: delete controllers deletion upon subsystem release

No reason for them to be kept around if we are
deleting the subsystem, so instead of passively
wait for the host to disconnect, actively delete
the controllers.
Signed-off-by: default avatarSagi Grimberg <sagi@grimberg.me>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: default avatarMax Gurtovoy <maxg@mellanox.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent c81e55e0
...@@ -631,6 +631,7 @@ static void nvmet_subsys_release(struct config_item *item) ...@@ -631,6 +631,7 @@ static void nvmet_subsys_release(struct config_item *item)
{ {
struct nvmet_subsys *subsys = to_subsys(item); struct nvmet_subsys *subsys = to_subsys(item);
nvmet_subsys_del_ctrls(subsys);
nvmet_subsys_put(subsys); nvmet_subsys_put(subsys);
} }
......
...@@ -935,6 +935,16 @@ static void nvmet_subsys_free(struct kref *ref) ...@@ -935,6 +935,16 @@ static void nvmet_subsys_free(struct kref *ref)
kfree(subsys); kfree(subsys);
} }
void nvmet_subsys_del_ctrls(struct nvmet_subsys *subsys)
{
struct nvmet_ctrl *ctrl;
mutex_lock(&subsys->lock);
list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry)
ctrl->ops->delete_ctrl(ctrl);
mutex_unlock(&subsys->lock);
}
void nvmet_subsys_put(struct nvmet_subsys *subsys) void nvmet_subsys_put(struct nvmet_subsys *subsys)
{ {
kref_put(&subsys->ref, nvmet_subsys_free); kref_put(&subsys->ref, nvmet_subsys_free);
......
...@@ -282,6 +282,7 @@ void nvmet_ctrl_put(struct nvmet_ctrl *ctrl); ...@@ -282,6 +282,7 @@ void nvmet_ctrl_put(struct nvmet_ctrl *ctrl);
struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn, struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,
enum nvme_subsys_type type); enum nvme_subsys_type type);
void nvmet_subsys_put(struct nvmet_subsys *subsys); void nvmet_subsys_put(struct nvmet_subsys *subsys);
void nvmet_subsys_del_ctrls(struct nvmet_subsys *subsys);
struct nvmet_ns *nvmet_find_namespace(struct nvmet_ctrl *ctrl, __le32 nsid); struct nvmet_ns *nvmet_find_namespace(struct nvmet_ctrl *ctrl, __le32 nsid);
void nvmet_put_namespace(struct nvmet_ns *ns); void nvmet_put_namespace(struct nvmet_ns *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