From 2882b9895a42d05fcacc5dc4b16b5ac337312e5c Mon Sep 17 00:00:00 2001 From: GangCao Date: Wed, 5 Jun 2019 16:04:42 -0400 Subject: [PATCH] iscsi: return the proper error to append the connection Instead of just return "-1", the proper error detail will be returned and reported out. Change-Id: Ief900494081ddc9ae6329ee7a56723d9cb5efe13 Signed-off-by: GangCao Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456937 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu --- lib/iscsi/iscsi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index ecc726923..f42d21fba 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -96,8 +96,8 @@ static int iscsi_send_r2t_recovery(struct spdk_iscsi_conn *conn, static int create_iscsi_sess(struct spdk_iscsi_conn *conn, struct spdk_iscsi_tgt_node *target, enum session_type session_type); -static int append_iscsi_sess(struct spdk_iscsi_conn *conn, - const char *initiator_port_name, uint16_t tsih, uint16_t cid); +static uint8_t append_iscsi_sess(struct spdk_iscsi_conn *conn, + const char *initiator_port_name, uint16_t tsih, uint16_t cid); static void remove_acked_pdu(struct spdk_iscsi_conn *conn, uint32_t ExpStatSN); @@ -1376,14 +1376,14 @@ iscsi_op_login_check_session(struct spdk_iscsi_conn *conn, /* multiple connections */ rc = append_iscsi_sess(conn, initiator_port_name, from_be16(&rsph->tsih), cid); - if (rc < 0) { + if (rc != 0) { SPDK_ERRLOG("isid=%"PRIx64", tsih=%u, cid=%u:" "spdk_append_iscsi_sess() failed\n", iscsi_get_isid(rsph->isid), from_be16(&rsph->tsih), cid); /* Can't include in session */ rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; - rsph->status_detail = ISCSI_LOGIN_CONN_ADD_FAIL; + rsph->status_detail = rc; return SPDK_ISCSI_LOGIN_ERROR_RESPONSE; } } else if (!g_spdk_iscsi.AllowDuplicateIsid) { @@ -4862,7 +4862,7 @@ get_iscsi_sess_by_tsih(uint16_t tsih) return session; } -static int +static uint8_t append_iscsi_sess(struct spdk_iscsi_conn *conn, const char *initiator_port_name, uint16_t tsih, uint16_t cid) { @@ -4874,7 +4874,7 @@ append_iscsi_sess(struct spdk_iscsi_conn *conn, sess = get_iscsi_sess_by_tsih(tsih); if (sess == NULL) { SPDK_ERRLOG("spdk_get_iscsi_sess_by_tsih failed\n"); - return -1; + return ISCSI_LOGIN_CONN_ADD_FAIL; } if ((conn->portal->group->tag != sess->tag) || (strcasecmp(initiator_port_name, spdk_scsi_port_get_name(sess->initiator_port)) != 0) || @@ -4882,14 +4882,14 @@ append_iscsi_sess(struct spdk_iscsi_conn *conn, /* no match */ SPDK_ERRLOG("no MCS session for init port name=%s, tsih=%d, cid=%d\n", initiator_port_name, tsih, cid); - return -1; + return ISCSI_LOGIN_CONN_ADD_FAIL; } if (sess->connections >= sess->MaxConnections) { /* no slot for connection */ SPDK_ERRLOG("too many connections for init port name=%s, tsih=%d, cid=%d\n", initiator_port_name, tsih, cid); - return -1; + return ISCSI_LOGIN_TOO_MANY_CONNECTIONS; } SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Connections (tsih %d): %d\n", sess->tsih, sess->connections);