Merging upstream version 1.15.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
14665a711e
commit
d975eb29d0
116 changed files with 6031 additions and 2284 deletions
|
@ -155,23 +155,23 @@ static int scan_namespace(struct nvme_namespace *n)
|
|||
return ret;
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0)
|
||||
if (fd < 0) {
|
||||
ret = fd;
|
||||
goto free;
|
||||
|
||||
}
|
||||
if (!n->nsid) {
|
||||
n->nsid = nvme_get_nsid(fd);
|
||||
if (n->nsid < 0)
|
||||
ret = nvme_get_nsid(fd);
|
||||
if (ret < 0)
|
||||
goto close_fd;
|
||||
n->nsid = ret;
|
||||
}
|
||||
|
||||
ret = nvme_identify_ns(fd, n->nsid, 0, &n->ns);
|
||||
if (ret < 0)
|
||||
goto close_fd;
|
||||
close_fd:
|
||||
close(fd);
|
||||
free:
|
||||
free(path);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *get_nvme_ctrl_path_ana_state(char *path, int nsid)
|
||||
|
@ -319,10 +319,8 @@ static int scan_ctrl(struct nvme_ctrl *c, char *p, __u32 ns_instance)
|
|||
return ret;
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Failed to open %s\n", path);
|
||||
if (fd < 0)
|
||||
goto free;
|
||||
}
|
||||
|
||||
ret = nvme_identify_ctrl(fd, &c->id);
|
||||
if (ret < 0)
|
||||
|
@ -384,8 +382,12 @@ static int scan_subsystem(struct nvme_subsystem *s, __u32 ns_instance, int nsid)
|
|||
for (i = 0; i < s->nr_namespaces; i++) {
|
||||
n = &s->namespaces[i];
|
||||
n->name = strdup(ns[i]->d_name);
|
||||
n->ctrl = &s->ctrls[0];
|
||||
scan_namespace(n);
|
||||
for (j = 0; j < s->nr_ctrls; j++) {
|
||||
n->ctrl = &s->ctrls[j];
|
||||
if (!strcmp(n->ctrl->state, "live") &&
|
||||
!scan_namespace(n))
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
i = s->nr_namespaces;
|
||||
|
@ -666,6 +668,30 @@ char *nvme_char_from_block(char *dev)
|
|||
return path;
|
||||
}
|
||||
|
||||
int nvme_logical_block_size_from_ns_char(const char *dev)
|
||||
{
|
||||
int ret;
|
||||
int id, nsid;
|
||||
char *path = NULL;
|
||||
char *s;
|
||||
|
||||
ret = sscanf(dev, "ng%dn%d", &id, &nsid);
|
||||
if (ret != 2)
|
||||
return -EINVAL;
|
||||
|
||||
if (asprintf(&path, "/sys/block/nvme%dn%d/queue", id, nsid) < 0)
|
||||
path = NULL;
|
||||
|
||||
if (!path)
|
||||
return -EINVAL;
|
||||
|
||||
s = nvme_get_ctrl_attr(path, "logical_block_size");
|
||||
if (!s)
|
||||
return -EINVAL;
|
||||
|
||||
return atoi(s);
|
||||
}
|
||||
|
||||
void *mmap_registers(const char *dev)
|
||||
{
|
||||
int fd;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue