Skip to content

Commit

Permalink
nvme: acquire a new subsystem if no valid controllers assigned
Browse files Browse the repository at this point in the history
  • Loading branch information
ixhamza committed May 21, 2024
1 parent 13467ee commit f113d31
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/nvme/host/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,8 @@ static void nvme_put_subsystem(struct nvme_subsystem *subsys)
static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn)
{
struct nvme_subsystem *subsys;
struct nvme_ctrl *ctrl;
bool active_ctrls = false;

lockdep_assert_held(&nvme_subsystems_lock);

Expand All @@ -2721,6 +2723,16 @@ static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn)
list_for_each_entry(subsys, &nvme_subsystems, entry) {
if (strcmp(subsys->subnqn, subsysnqn))
continue;
if (!list_empty(&subsys->ctrls)) {
list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) {
if (!nvme_state_terminal(ctrl)) {
active_ctrls = true;
break;
}
}
}
if (!active_ctrls)
continue;
if (!kref_get_unless_zero(&subsys->ref))
continue;
return subsys;
Expand Down

0 comments on commit f113d31

Please sign in to comment.