|
Tomas Bzatek |
cef1f1 |
From da8c28e5e220be4742442114252d136097056928 Mon Sep 17 00:00:00 2001
|
|
Tomas Bzatek |
cef1f1 |
From: Tomas Bzatek <tbzatek@redhat.com>
|
|
Tomas Bzatek |
cef1f1 |
Date: Thu, 12 Oct 2023 18:43:16 +0200
|
|
Tomas Bzatek |
cef1f1 |
Subject: [PATCH] fabrics: Allocate aligned payloads for id_ctrl and discovery
|
|
Tomas Bzatek |
cef1f1 |
log calls
|
|
Tomas Bzatek |
cef1f1 |
|
|
Tomas Bzatek |
cef1f1 |
Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
|
|
Tomas Bzatek |
cef1f1 |
---
|
|
Tomas Bzatek |
cef1f1 |
src/nvme/fabrics.c | 29 +++++++++++++++++++----------
|
|
Tomas Bzatek |
cef1f1 |
1 file changed, 19 insertions(+), 10 deletions(-)
|
|
Tomas Bzatek |
cef1f1 |
|
|
Tomas Bzatek |
cef1f1 |
diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c
|
|
Tomas Bzatek |
cef1f1 |
index 21fb2920..2e48ac86 100644
|
|
Tomas Bzatek |
cef1f1 |
--- a/src/nvme/fabrics.c
|
|
Tomas Bzatek |
cef1f1 |
+++ b/src/nvme/fabrics.c
|
|
Tomas Bzatek |
cef1f1 |
@@ -1073,7 +1073,7 @@ static struct nvmf_discovery_log *nvme_discovery_log(nvme_ctrl_t c,
|
|
Tomas Bzatek |
cef1f1 |
size = sizeof(struct nvmf_discovery_log);
|
|
Tomas Bzatek |
cef1f1 |
|
|
Tomas Bzatek |
cef1f1 |
free(log);
|
|
Tomas Bzatek |
cef1f1 |
- log = calloc(1, size);
|
|
Tomas Bzatek |
cef1f1 |
+ log = __nvme_alloc(size);
|
|
Tomas Bzatek |
cef1f1 |
if (!log) {
|
|
Tomas Bzatek |
cef1f1 |
nvme_msg(r, LOG_ERR,
|
|
Tomas Bzatek |
cef1f1 |
"could not allocate memory for discovery log header\n");
|
|
Tomas Bzatek |
cef1f1 |
@@ -1105,7 +1105,7 @@ static struct nvmf_discovery_log *nvme_discovery_log(nvme_ctrl_t c,
|
|
Tomas Bzatek |
cef1f1 |
sizeof(struct nvmf_disc_log_entry) * numrec;
|
|
Tomas Bzatek |
cef1f1 |
|
|
Tomas Bzatek |
cef1f1 |
free(log);
|
|
Tomas Bzatek |
cef1f1 |
- log = calloc(1, size);
|
|
Tomas Bzatek |
cef1f1 |
+ log = __nvme_alloc(size);
|
|
Tomas Bzatek |
cef1f1 |
if (!log) {
|
|
Tomas Bzatek |
cef1f1 |
nvme_msg(r, LOG_ERR,
|
|
Tomas Bzatek |
cef1f1 |
"could not alloc memory for discovery log page\n");
|
|
Tomas Bzatek |
cef1f1 |
@@ -1709,26 +1709,35 @@ static const char *dctype_str[] = {
|
|
Tomas Bzatek |
cef1f1 |
*/
|
|
Tomas Bzatek |
cef1f1 |
static int nvme_fetch_cntrltype_dctype_from_id(nvme_ctrl_t c)
|
|
Tomas Bzatek |
cef1f1 |
{
|
|
Tomas Bzatek |
cef1f1 |
- struct nvme_id_ctrl id = { 0 };
|
|
Tomas Bzatek |
cef1f1 |
+ struct nvme_id_ctrl *id;
|
|
Tomas Bzatek |
cef1f1 |
int ret;
|
|
Tomas Bzatek |
cef1f1 |
|
|
Tomas Bzatek |
cef1f1 |
- ret = nvme_ctrl_identify(c, &id;;
|
|
Tomas Bzatek |
cef1f1 |
- if (ret)
|
|
Tomas Bzatek |
cef1f1 |
+ id = __nvme_alloc(sizeof(*id));
|
|
Tomas Bzatek |
cef1f1 |
+ if (!id) {
|
|
Tomas Bzatek |
cef1f1 |
+ errno = ENOMEM;
|
|
Tomas Bzatek |
cef1f1 |
+ return -1;
|
|
Tomas Bzatek |
cef1f1 |
+ }
|
|
Tomas Bzatek |
cef1f1 |
+
|
|
Tomas Bzatek |
cef1f1 |
+ ret = nvme_ctrl_identify(c, id);
|
|
Tomas Bzatek |
cef1f1 |
+ if (ret) {
|
|
Tomas Bzatek |
cef1f1 |
+ free(id);
|
|
Tomas Bzatek |
cef1f1 |
return ret;
|
|
Tomas Bzatek |
cef1f1 |
+ }
|
|
Tomas Bzatek |
cef1f1 |
|
|
Tomas Bzatek |
cef1f1 |
if (!c->cntrltype) {
|
|
Tomas Bzatek |
cef1f1 |
- if (id.cntrltype > NVME_CTRL_CNTRLTYPE_ADMIN || !cntrltype_str[id.cntrltype])
|
|
Tomas Bzatek |
cef1f1 |
+ if (id->cntrltype > NVME_CTRL_CNTRLTYPE_ADMIN || !cntrltype_str[id->cntrltype])
|
|
Tomas Bzatek |
cef1f1 |
c->cntrltype = strdup("reserved");
|
|
Tomas Bzatek |
cef1f1 |
else
|
|
Tomas Bzatek |
cef1f1 |
- c->cntrltype = strdup(cntrltype_str[id.cntrltype]);
|
|
Tomas Bzatek |
cef1f1 |
+ c->cntrltype = strdup(cntrltype_str[id->cntrltype]);
|
|
Tomas Bzatek |
cef1f1 |
}
|
|
Tomas Bzatek |
cef1f1 |
|
|
Tomas Bzatek |
cef1f1 |
- if (!c->dctype) {
|
|
Tomas Bzatek |
cef1f1 |
- if (id.dctype > NVME_CTRL_DCTYPE_CDC || !dctype_str[id.dctype])
|
|
Tomas Bzatek |
cef1f1 |
+ if (!c->dctype) {
|
|
Tomas Bzatek |
cef1f1 |
+ if (id->dctype > NVME_CTRL_DCTYPE_CDC || !dctype_str[id->dctype])
|
|
Tomas Bzatek |
cef1f1 |
c->dctype = strdup("reserved");
|
|
Tomas Bzatek |
cef1f1 |
else
|
|
Tomas Bzatek |
cef1f1 |
- c->dctype = strdup(dctype_str[id.dctype]);
|
|
Tomas Bzatek |
cef1f1 |
+ c->dctype = strdup(dctype_str[id->dctype]);
|
|
Tomas Bzatek |
cef1f1 |
}
|
|
Tomas Bzatek |
cef1f1 |
+ free(id);
|
|
Tomas Bzatek |
cef1f1 |
return 0;
|
|
Tomas Bzatek |
cef1f1 |
}
|
|
Tomas Bzatek |
cef1f1 |
|