iscsi: Remove use of perror for malloc, strdup, and writev failure
All SPDK libraries should use the spdk/log.h family of functions for logging. Change-Id: I2b8ac30f2901b325784552f0016f1058ae2cd577 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/391687 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
a652471c99
commit
81673d0c25
@ -973,7 +973,8 @@ spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int bytes,
|
|||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
spdk_strerror_r(errno, errbuf, sizeof(errbuf));
|
spdk_strerror_r(errno, errbuf, sizeof(errbuf));
|
||||||
SPDK_ERRLOG("Socket read error(%d): %s\n", errno, errbuf);
|
SPDK_ERRLOG("spdk_sock_recv() failed (fd=%d), errno %d: %s\n",
|
||||||
|
conn->sock, errno, errbuf);
|
||||||
}
|
}
|
||||||
return SPDK_ISCSI_CONNECTION_FATAL;
|
return SPDK_ISCSI_CONNECTION_FATAL;
|
||||||
}
|
}
|
||||||
@ -1181,6 +1182,7 @@ spdk_iscsi_conn_flush_pdus_internal(struct spdk_iscsi_conn *conn)
|
|||||||
uint32_t writev_offset;
|
uint32_t writev_offset;
|
||||||
struct spdk_iscsi_pdu *pdu;
|
struct spdk_iscsi_pdu *pdu;
|
||||||
int pdu_length;
|
int pdu_length;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
pdu = TAILQ_FIRST(&conn->write_pdu_list);
|
pdu = TAILQ_FIRST(&conn->write_pdu_list);
|
||||||
|
|
||||||
@ -1229,7 +1231,9 @@ spdk_iscsi_conn_flush_pdus_internal(struct spdk_iscsi_conn *conn)
|
|||||||
if (errno == EWOULDBLOCK || errno == EAGAIN) {
|
if (errno == EWOULDBLOCK || errno == EAGAIN) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
perror("writev");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("spdk_sock_writev() failed (fd=%d), errno %d: %s\n",
|
||||||
|
conn->sock, errno, buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "spdk/stdinc.h"
|
#include "spdk/stdinc.h"
|
||||||
|
|
||||||
#include "spdk/conf.h"
|
#include "spdk/conf.h"
|
||||||
|
#include "spdk/string.h"
|
||||||
|
|
||||||
#include "spdk_internal/log.h"
|
#include "spdk_internal/log.h"
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ static struct spdk_iscsi_init_grp *
|
|||||||
spdk_iscsi_init_grp_create(int tag)
|
spdk_iscsi_init_grp_create(int tag)
|
||||||
{
|
{
|
||||||
struct spdk_iscsi_init_grp *ig;
|
struct spdk_iscsi_init_grp *ig;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
if (spdk_iscsi_init_grp_find_by_tag(tag)) {
|
if (spdk_iscsi_init_grp_find_by_tag(tag)) {
|
||||||
SPDK_ERRLOG("duplicate initiator group tag (%d)\n", tag);
|
SPDK_ERRLOG("duplicate initiator group tag (%d)\n", tag);
|
||||||
@ -53,7 +55,9 @@ spdk_iscsi_init_grp_create(int tag)
|
|||||||
|
|
||||||
ig = calloc(1, sizeof(*ig));
|
ig = calloc(1, sizeof(*ig));
|
||||||
if (ig == NULL) {
|
if (ig == NULL) {
|
||||||
SPDK_ERRLOG("initiator group malloc error (tag=%d)\n", tag);
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("calloc() failed for initiator group (tag=%d), errno %d: %s\n",
|
||||||
|
tag, errno, buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +85,7 @@ spdk_iscsi_init_grp_add_initiator(struct spdk_iscsi_init_grp *ig, char *name)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_initiator_name *iname;
|
struct spdk_iscsi_initiator_name *iname;
|
||||||
char *p;
|
char *p;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
if (ig->ninitiators >= MAX_INITIATOR) {
|
if (ig->ninitiators >= MAX_INITIATOR) {
|
||||||
SPDK_ERRLOG("> MAX_INITIATOR(=%d) is not allowed\n", MAX_INITIATOR);
|
SPDK_ERRLOG("> MAX_INITIATOR(=%d) is not allowed\n", MAX_INITIATOR);
|
||||||
@ -94,11 +99,17 @@ spdk_iscsi_init_grp_add_initiator(struct spdk_iscsi_init_grp *ig, char *name)
|
|||||||
|
|
||||||
iname = malloc(sizeof(*iname));
|
iname = malloc(sizeof(*iname));
|
||||||
if (iname == NULL) {
|
if (iname == NULL) {
|
||||||
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for initiator name str, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
iname->name = strdup(name);
|
iname->name = strdup(name);
|
||||||
if (iname->name == NULL) {
|
if (iname->name == NULL) {
|
||||||
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("strdup() failed for initiator name, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
free(iname);
|
free(iname);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
@ -187,6 +198,7 @@ spdk_iscsi_init_grp_add_netmask(struct spdk_iscsi_init_grp *ig, char *mask)
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_initiator_netmask *imask;
|
struct spdk_iscsi_initiator_netmask *imask;
|
||||||
char *p;
|
char *p;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
if (ig->nnetmasks >= MAX_NETMASK) {
|
if (ig->nnetmasks >= MAX_NETMASK) {
|
||||||
SPDK_ERRLOG("> MAX_NETMASK(=%d) is not allowed\n", MAX_NETMASK);
|
SPDK_ERRLOG("> MAX_NETMASK(=%d) is not allowed\n", MAX_NETMASK);
|
||||||
@ -200,11 +212,17 @@ spdk_iscsi_init_grp_add_netmask(struct spdk_iscsi_init_grp *ig, char *mask)
|
|||||||
|
|
||||||
imask = malloc(sizeof(*imask));
|
imask = malloc(sizeof(*imask));
|
||||||
if (imask == NULL) {
|
if (imask == NULL) {
|
||||||
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for inititator mask str, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
imask->mask = strdup(mask);
|
imask->mask = strdup(mask);
|
||||||
if (imask->mask == NULL) {
|
if (imask->mask == NULL) {
|
||||||
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("strdup() failed for initiator mask, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
free(imask);
|
free(imask);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
@ -286,6 +304,7 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
|
|||||||
int num_initiator_masks;
|
int num_initiator_masks;
|
||||||
char **initiators = NULL, **netmasks = NULL;
|
char **initiators = NULL, **netmasks = NULL;
|
||||||
int tag = spdk_conf_section_get_num(sp);
|
int tag = spdk_conf_section_get_num(sp);
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "add initiator group %d\n", tag);
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "add initiator group %d\n", tag);
|
||||||
|
|
||||||
@ -328,7 +347,9 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
|
|||||||
|
|
||||||
initiators = calloc(num_initiator_names, sizeof(char *));
|
initiators = calloc(num_initiator_names, sizeof(char *));
|
||||||
if (!initiators) {
|
if (!initiators) {
|
||||||
perror("initiators");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("calloc() failed for temp initiator name array, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
for (i = 0; i < num_initiator_names; i++) {
|
for (i = 0; i < num_initiator_names; i++) {
|
||||||
@ -341,14 +362,18 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
|
|||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "InitiatorName %s\n", val);
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "InitiatorName %s\n", val);
|
||||||
initiators[i] = strdup(val);
|
initiators[i] = strdup(val);
|
||||||
if (!initiators[i]) {
|
if (!initiators[i]) {
|
||||||
perror("initiator name copy");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("strdup() failed for temp initiator name, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
netmasks = calloc(num_initiator_masks, sizeof(char *));
|
netmasks = calloc(num_initiator_masks, sizeof(char *));
|
||||||
if (!netmasks) {
|
if (!netmasks) {
|
||||||
perror("netmasks");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for portal group (tag=%d), errno %d: %s\n",
|
||||||
|
tag, errno, buf);
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -362,7 +387,9 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
|
|||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Netmask %s\n", val);
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Netmask %s\n", val);
|
||||||
netmasks[i] = strdup(val);
|
netmasks[i] = strdup(val);
|
||||||
if (!netmasks[i]) {
|
if (!netmasks[i]) {
|
||||||
perror("initiator netmask copy");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("strdup() failed for temp initiator mask, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -774,6 +774,7 @@ spdk_iscsi_get_authinfo(struct spdk_iscsi_conn *conn, const char *authuser)
|
|||||||
char *authfile = NULL;
|
char *authfile = NULL;
|
||||||
int ag_tag;
|
int ag_tag;
|
||||||
int rc;
|
int rc;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
if (conn->sess->target != NULL) {
|
if (conn->sess->target != NULL) {
|
||||||
ag_tag = conn->sess->target->auth_group;
|
ag_tag = conn->sess->target->auth_group;
|
||||||
@ -791,7 +792,9 @@ spdk_iscsi_get_authinfo(struct spdk_iscsi_conn *conn, const char *authuser)
|
|||||||
authfile = strdup(g_spdk_iscsi.authfile);
|
authfile = strdup(g_spdk_iscsi.authfile);
|
||||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
||||||
if (!authfile) {
|
if (!authfile) {
|
||||||
perror("authfile");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("strdup() failed from %s to authfile, errno %d: %s\n",
|
||||||
|
g_spdk_iscsi.authfile, errno, buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -819,6 +822,7 @@ spdk_iscsi_auth_params(struct spdk_iscsi_conn *conn,
|
|||||||
const char *challenge;
|
const char *challenge;
|
||||||
int total;
|
int total;
|
||||||
int rc;
|
int rc;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
if (conn == NULL || params == NULL || method == NULL) {
|
if (conn == NULL || params == NULL || method == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -843,7 +847,9 @@ spdk_iscsi_auth_params(struct spdk_iscsi_conn *conn,
|
|||||||
/* for temporary store */
|
/* for temporary store */
|
||||||
in_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
in_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
||||||
if (!in_val) {
|
if (!in_val) {
|
||||||
perror("in_val");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for temporary store, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1043,6 +1049,7 @@ spdk_iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
|
|||||||
int total_ahs_len;
|
int total_ahs_len;
|
||||||
int data_len;
|
int data_len;
|
||||||
int alloc_len;
|
int alloc_len;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
total_ahs_len = pdu->bhs.total_ahs_len;
|
total_ahs_len = pdu->bhs.total_ahs_len;
|
||||||
data_len = 0;
|
data_len = 0;
|
||||||
@ -1054,7 +1061,9 @@ spdk_iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
|
|||||||
|
|
||||||
data = malloc(alloc_len);
|
data = malloc(alloc_len);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
perror("data");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for data segment, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1830,6 +1839,7 @@ spdk_iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
|
|||||||
struct iscsi_bhs_login_req *reqh;
|
struct iscsi_bhs_login_req *reqh;
|
||||||
struct iscsi_bhs_login_rsp *rsph;
|
struct iscsi_bhs_login_rsp *rsph;
|
||||||
int rc;
|
int rc;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
|
rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
|
||||||
rsph->opcode = ISCSI_OP_LOGIN_RSP;
|
rsph->opcode = ISCSI_OP_LOGIN_RSP;
|
||||||
@ -1846,7 +1856,9 @@ spdk_iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
|
|||||||
|
|
||||||
rsp_pdu->data = malloc(*alloc_len);
|
rsp_pdu->data = malloc(*alloc_len);
|
||||||
if (!rsp_pdu->data) {
|
if (!rsp_pdu->data) {
|
||||||
perror("data");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for data segment, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2265,6 +2277,7 @@ spdk_iscsi_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
|||||||
int rc;
|
int rc;
|
||||||
struct iscsi_bhs_text_req *reqh;
|
struct iscsi_bhs_text_req *reqh;
|
||||||
struct iscsi_bhs_text_resp *rsph;
|
struct iscsi_bhs_text_resp *rsph;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
data_len = 0;
|
data_len = 0;
|
||||||
alloc_len = conn->MaxRecvDataSegmentLength;
|
alloc_len = conn->MaxRecvDataSegmentLength;
|
||||||
@ -2328,7 +2341,8 @@ spdk_iscsi_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
|||||||
|
|
||||||
data = malloc(alloc_len);
|
data = malloc(alloc_len);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
perror("data");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for data segment, errno %d: %s\n", errno, buf);
|
||||||
spdk_iscsi_param_free(params);
|
spdk_iscsi_param_free(params);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
@ -3436,6 +3450,7 @@ spdk_iscsi_op_nopout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
|||||||
uint32_t CmdSN;
|
uint32_t CmdSN;
|
||||||
int I_bit;
|
int I_bit;
|
||||||
int data_len;
|
int data_len;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
if (conn->sess->session_type == SESSION_TYPE_DISCOVERY) {
|
if (conn->sess->session_type == SESSION_TYPE_DISCOVERY) {
|
||||||
SPDK_ERRLOG("ISCSI_OP_NOPOUT not allowed in discovery session\n");
|
SPDK_ERRLOG("ISCSI_OP_NOPOUT not allowed in discovery session\n");
|
||||||
@ -3493,7 +3508,9 @@ spdk_iscsi_op_nopout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
|||||||
|
|
||||||
data = malloc(data_len);
|
data = malloc(data_len);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
perror("could not allocate ping buffer");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for ping data, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
return SPDK_ISCSI_CONNECTION_FATAL;
|
return SPDK_ISCSI_CONNECTION_FATAL;
|
||||||
}
|
}
|
||||||
memset(data, 0, data_len);
|
memset(data, 0, data_len);
|
||||||
@ -4532,6 +4549,7 @@ spdk_create_iscsi_sess(struct spdk_iscsi_conn *conn,
|
|||||||
{
|
{
|
||||||
struct spdk_iscsi_sess *sess;
|
struct spdk_iscsi_sess *sess;
|
||||||
int rc;
|
int rc;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
sess = spdk_mempool_get(g_spdk_iscsi.session_pool);
|
sess = spdk_mempool_get(g_spdk_iscsi.session_pool);
|
||||||
if (!sess) {
|
if (!sess) {
|
||||||
@ -4570,7 +4588,9 @@ spdk_create_iscsi_sess(struct spdk_iscsi_conn *conn,
|
|||||||
|
|
||||||
sess->conns = malloc(sizeof(*sess->conns) * sess->MaxConnections);
|
sess->conns = malloc(sizeof(*sess->conns) * sess->MaxConnections);
|
||||||
if (!sess->conns) {
|
if (!sess->conns) {
|
||||||
perror("conns");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for connection array, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include "spdk/stdinc.h"
|
#include "spdk/stdinc.h"
|
||||||
#include "spdk/env.h"
|
#include "spdk/env.h"
|
||||||
|
#include "spdk/string.h"
|
||||||
|
|
||||||
#include "iscsi/iscsi.h"
|
#include "iscsi/iscsi.h"
|
||||||
#include "iscsi/init_grp.h"
|
#include "iscsi/init_grp.h"
|
||||||
@ -741,6 +742,7 @@ spdk_iscsi_app_read_parameters(void)
|
|||||||
{
|
{
|
||||||
struct spdk_conf_section *sp;
|
struct spdk_conf_section *sp;
|
||||||
int rc;
|
int rc;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
g_spdk_iscsi.MaxSessions = DEFAULT_MAX_SESSIONS;
|
g_spdk_iscsi.MaxSessions = DEFAULT_MAX_SESSIONS;
|
||||||
g_spdk_iscsi.MaxConnectionsPerSession = DEFAULT_MAX_CONNECTIONS_PER_SESSION;
|
g_spdk_iscsi.MaxConnectionsPerSession = DEFAULT_MAX_CONNECTIONS_PER_SESSION;
|
||||||
@ -777,7 +779,9 @@ spdk_iscsi_app_read_parameters(void)
|
|||||||
|
|
||||||
g_spdk_iscsi.session = spdk_dma_zmalloc(sizeof(void *) * g_spdk_iscsi.MaxSessions, 0, NULL);
|
g_spdk_iscsi.session = spdk_dma_zmalloc(sizeof(void *) * g_spdk_iscsi.MaxSessions, 0, NULL);
|
||||||
if (!g_spdk_iscsi.session) {
|
if (!g_spdk_iscsi.session) {
|
||||||
SPDK_ERRLOG("could not allocate session array\n");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("spdk_dma_zmalloc() failed for session array, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +131,7 @@ spdk_iscsi_param_add(struct iscsi_param **params, const char *key,
|
|||||||
const char *val, const char *list, int type)
|
const char *val, const char *list, int type)
|
||||||
{
|
{
|
||||||
struct iscsi_param *param, *last_param;
|
struct iscsi_param *param, *last_param;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "add %s=%s, list=[%s], type=%d\n",
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "add %s=%s, list=[%s], type=%d\n",
|
||||||
key, val, list, type);
|
key, val, list, type);
|
||||||
@ -145,7 +146,8 @@ spdk_iscsi_param_add(struct iscsi_param **params, const char *key,
|
|||||||
|
|
||||||
param = malloc(sizeof * param);
|
param = malloc(sizeof * param);
|
||||||
if (!param) {
|
if (!param) {
|
||||||
perror("param");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for parameter, errno %d: %s\n", errno, buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,6 +225,7 @@ spdk_iscsi_parse_param(struct iscsi_param **params, const uint8_t *data)
|
|||||||
const uint8_t *key_end, *val;
|
const uint8_t *key_end, *val;
|
||||||
int key_len, val_len;
|
int key_len, val_len;
|
||||||
int max_len;
|
int max_len;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
key_end = strchr(data, '=');
|
key_end = strchr(data, '=');
|
||||||
if (!key_end) {
|
if (!key_end) {
|
||||||
@ -245,7 +248,8 @@ spdk_iscsi_parse_param(struct iscsi_param **params, const uint8_t *data)
|
|||||||
|
|
||||||
key_copy = malloc(key_len + 1);
|
key_copy = malloc(key_len + 1);
|
||||||
if (!key_copy) {
|
if (!key_copy) {
|
||||||
perror("key_copy");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for key_copy, errno %d: %s\n", errno, buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,10 +524,12 @@ spdk_iscsi_special_param_construction(struct spdk_iscsi_conn *conn,
|
|||||||
uint32_t FirstBurstLength;
|
uint32_t FirstBurstLength;
|
||||||
uint32_t MaxBurstLength;
|
uint32_t MaxBurstLength;
|
||||||
char *val;
|
char *val;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
||||||
if (!val) {
|
if (!val) {
|
||||||
perror("val");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for temporary buffer, errno %d: %s\n", errno, buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -885,6 +891,8 @@ spdk_iscsi_negotiate_params(struct spdk_iscsi_conn *conn,
|
|||||||
uint32_t MaxBurstLength;
|
uint32_t MaxBurstLength;
|
||||||
bool FirstBurstLength_flag = false;
|
bool FirstBurstLength_flag = false;
|
||||||
int type;
|
int type;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
total = data_len;
|
total = data_len;
|
||||||
if (alloc_len < 1) {
|
if (alloc_len < 1) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -921,20 +929,23 @@ spdk_iscsi_negotiate_params(struct spdk_iscsi_conn *conn,
|
|||||||
/* for temporary store */
|
/* for temporary store */
|
||||||
valid_list = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
valid_list = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
||||||
if (!valid_list) {
|
if (!valid_list) {
|
||||||
perror("valid_list");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for valid_list, errno %d: %s\n", errno, buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
in_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
||||||
if (!in_val) {
|
if (!in_val) {
|
||||||
perror("in_val");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for in_val, errno %d: %s\n", errno, buf);
|
||||||
free(valid_list);
|
free(valid_list);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
cur_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
|
||||||
if (!cur_val) {
|
if (!cur_val) {
|
||||||
perror("cur_val");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for cur_val, errno %d: %s\n", errno, buf);
|
||||||
free(valid_list);
|
free(valid_list);
|
||||||
free(in_val);
|
free(in_val);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "spdk/conf.h"
|
#include "spdk/conf.h"
|
||||||
#include "spdk/net.h"
|
#include "spdk/net.h"
|
||||||
#include "spdk/event.h"
|
#include "spdk/event.h"
|
||||||
|
#include "spdk/string.h"
|
||||||
|
|
||||||
#include "spdk_internal/log.h"
|
#include "spdk_internal/log.h"
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ struct spdk_iscsi_portal *
|
|||||||
spdk_iscsi_portal_create(const char *host, const char *port, uint64_t cpumask)
|
spdk_iscsi_portal_create(const char *host, const char *port, uint64_t cpumask)
|
||||||
{
|
{
|
||||||
struct spdk_iscsi_portal *p = NULL;
|
struct spdk_iscsi_portal *p = NULL;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
assert(host != NULL);
|
assert(host != NULL);
|
||||||
assert(port != NULL);
|
assert(port != NULL);
|
||||||
@ -81,7 +83,9 @@ spdk_iscsi_portal_create(const char *host, const char *port, uint64_t cpumask)
|
|||||||
|
|
||||||
p = malloc(sizeof(*p));
|
p = malloc(sizeof(*p));
|
||||||
if (!p) {
|
if (!p) {
|
||||||
SPDK_ERRLOG("portal malloc error (%s, %s)\n", host, port);
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for portal (%s, %s), errno %d: %s\n",
|
||||||
|
host, port, errno, buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,9 +172,9 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
|
|||||||
char *host = NULL, *port = NULL;
|
char *host = NULL, *port = NULL;
|
||||||
const char *cpumask_str;
|
const char *cpumask_str;
|
||||||
uint64_t cpumask = 0;
|
uint64_t cpumask = 0;
|
||||||
|
|
||||||
int n, len, rc = -1;
|
int n, len, rc = -1;
|
||||||
const char *p, *q;
|
const char *p, *q;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
if (portalstring == NULL) {
|
if (portalstring == NULL) {
|
||||||
SPDK_ERRLOG("portal error\n");
|
SPDK_ERRLOG("portal error\n");
|
||||||
@ -189,7 +193,9 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
|
|||||||
if (!dry_run) {
|
if (!dry_run) {
|
||||||
host = malloc(n + 1);
|
host = malloc(n + 1);
|
||||||
if (!host) {
|
if (!host) {
|
||||||
perror("host");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for host, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
memcpy(host, portalstring, n);
|
memcpy(host, portalstring, n);
|
||||||
@ -199,7 +205,9 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
|
|||||||
if (!dry_run) {
|
if (!dry_run) {
|
||||||
port = malloc(PORTNUMSTRLEN);
|
port = malloc(PORTNUMSTRLEN);
|
||||||
if (!port) {
|
if (!port) {
|
||||||
perror("port");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for port, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
snprintf(port, PORTNUMSTRLEN, "%d", DEFAULT_PORT);
|
snprintf(port, PORTNUMSTRLEN, "%d", DEFAULT_PORT);
|
||||||
@ -218,7 +226,9 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
|
|||||||
|
|
||||||
port = malloc(len + 1);
|
port = malloc(len + 1);
|
||||||
if (!port) {
|
if (!port) {
|
||||||
perror("port");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for port, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
memset(port, 0, len + 1);
|
memset(port, 0, len + 1);
|
||||||
@ -235,7 +245,9 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
|
|||||||
if (!dry_run) {
|
if (!dry_run) {
|
||||||
host = malloc(n + 1);
|
host = malloc(n + 1);
|
||||||
if (!host) {
|
if (!host) {
|
||||||
perror("host");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for host, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
memcpy(host, portalstring, n);
|
memcpy(host, portalstring, n);
|
||||||
@ -245,7 +257,9 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
|
|||||||
if (!dry_run) {
|
if (!dry_run) {
|
||||||
port = malloc(PORTNUMSTRLEN);
|
port = malloc(PORTNUMSTRLEN);
|
||||||
if (!port) {
|
if (!port) {
|
||||||
perror("port");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for port, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
snprintf(port, PORTNUMSTRLEN, "%d", DEFAULT_PORT);
|
snprintf(port, PORTNUMSTRLEN, "%d", DEFAULT_PORT);
|
||||||
@ -269,7 +283,9 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
|
|||||||
len = q - p - 1;
|
len = q - p - 1;
|
||||||
port = malloc(len + 1);
|
port = malloc(len + 1);
|
||||||
if (!port) {
|
if (!port) {
|
||||||
perror("port");
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for port, errno %d: %s\n",
|
||||||
|
errno, buf);
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
memset(port, 0, len + 1);
|
memset(port, 0, len + 1);
|
||||||
@ -305,8 +321,12 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
|
|||||||
|
|
||||||
rc = 0;
|
rc = 0;
|
||||||
error_out:
|
error_out:
|
||||||
free(host);
|
if (host) {
|
||||||
free(port);
|
free(host);
|
||||||
|
}
|
||||||
|
if (port) {
|
||||||
|
free(port);
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -314,10 +334,13 @@ error_out:
|
|||||||
struct spdk_iscsi_portal_grp *
|
struct spdk_iscsi_portal_grp *
|
||||||
spdk_iscsi_portal_grp_create(int tag)
|
spdk_iscsi_portal_grp_create(int tag)
|
||||||
{
|
{
|
||||||
|
char buf[64];
|
||||||
struct spdk_iscsi_portal_grp *pg = malloc(sizeof(*pg));
|
struct spdk_iscsi_portal_grp *pg = malloc(sizeof(*pg));
|
||||||
|
|
||||||
if (!pg) {
|
if (!pg) {
|
||||||
SPDK_ERRLOG("portal group malloc error (%d)\n", tag);
|
spdk_strerror_r(errno, buf, sizeof(buf));
|
||||||
|
SPDK_ERRLOG("malloc() failed for portal group (tag=%d), errno %d: %s\n",
|
||||||
|
tag, errno, buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user