Skip to content

Commit 3c9fa45

Browse files
committed
tree: only open controller device node if required
Opening the controller device will fail if the controller is resetting, so trying to open it during controller initialisation will fail, and the controller will not displayed correctly. So only try to open the controller device if required, allowing the initialisation to continue. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent 53ab58c commit 3c9fa45

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/nvme/tree.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,12 @@ static int nvme_ctrl_scan_path(struct nvme_ctrl *c, char *name)
630630

631631
int nvme_ctrl_get_fd(nvme_ctrl_t c)
632632
{
633+
if (c->fd < 0) {
634+
c->fd = nvme_open(c->name);
635+
if (c->fd < 0)
636+
nvme_msg(LOG_ERR, "Failed to open ctrl %s, errno %d\n",
637+
c->name, errno);
638+
}
633639
return c->fd;
634640
}
635641

@@ -1106,15 +1112,14 @@ static int nvme_configure_ctrl(nvme_ctrl_t c, const char *path,
11061112

11071113
d = opendir(path);
11081114
if (!d) {
1115+
nvme_msg(LOG_ERR, "Failed to open ctrl dir %s, error %d\n",
1116+
path, errno);
11091117
errno = ENODEV;
11101118
return -1;
11111119
}
11121120
closedir(d);
11131121

1114-
c->fd = nvme_open(name);
1115-
if (c->fd < 0)
1116-
return c->fd;
1117-
1122+
c->fd = -1;
11181123
c->name = strdup(name);
11191124
c->sysfs_dir = (char *)path;
11201125
c->firmware = nvme_get_ctrl_attr(c, "firmware_rev");

0 commit comments

Comments
 (0)