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 22, 2024
1 parent 13467ee commit b8eb550
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/nvme/host/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2719,8 +2719,21 @@ static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn)
return NULL;

list_for_each_entry(subsys, &nvme_subsystems, entry) {
bool valid_ctrl = false;
struct nvme_ctrl *ctrl;

if (strcmp(subsys->subnqn, subsysnqn))
continue;
if (list_empty(&subsys->ctrls))
continue;
list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) {
if (!nvme_state_terminal(ctrl)) {
valid_ctrl = true;
break;
}
}
if (!valid_ctrl)
continue;
if (!kref_get_unless_zero(&subsys->ref))
continue;
return subsys;
Expand Down

0 comments on commit b8eb550

Please sign in to comment.