lib/iscsi: add 'state' and 'login_phase' to RPC 'iscsi_get_connections'

In some abnormal condition, iscsi connections can be exceptional,
add these two infomation for monitoring iscsi connections state.

Signed-off-by: Sochin Jiang <jiangxiaoqing.sochin@bytedance.com>
Change-Id: Ib43128302e8ea057d665e4d6294e28ec7e4f4194
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4613
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Sochin Jiang 2020-10-13 15:26:02 +08:00 committed by Tomasz Zawadzki
parent c4a95932a1
commit e9c815ad4c

View File

@ -61,6 +61,8 @@
memset(&(conn)->portal, 0, sizeof(*(conn)) - \ memset(&(conn)->portal, 0, sizeof(*(conn)) - \
offsetof(struct spdk_iscsi_conn, portal)); offsetof(struct spdk_iscsi_conn, portal));
#define SPDK_ISCSI_CONNECTION_STATUS(status, rnstr) case(status): return(rnstr)
static struct spdk_iscsi_conn *g_conns_array = NULL; static struct spdk_iscsi_conn *g_conns_array = NULL;
static TAILQ_HEAD(, spdk_iscsi_conn) g_free_conns = TAILQ_HEAD_INITIALIZER(g_free_conns); static TAILQ_HEAD(, spdk_iscsi_conn) g_free_conns = TAILQ_HEAD_INITIALIZER(g_free_conns);
@ -1617,6 +1619,29 @@ iscsi_conn_logout(struct spdk_iscsi_conn *conn)
conn->logout_timer = SPDK_POLLER_REGISTER(logout_timeout, conn, ISCSI_LOGOUT_TIMEOUT * 1000000); conn->logout_timer = SPDK_POLLER_REGISTER(logout_timeout, conn, ISCSI_LOGOUT_TIMEOUT * 1000000);
} }
static const char *
iscsi_conn_get_state(struct spdk_iscsi_conn *conn)
{
switch (conn->state) {
SPDK_ISCSI_CONNECTION_STATUS(ISCSI_CONN_STATE_INVALID, "invalid");
SPDK_ISCSI_CONNECTION_STATUS(ISCSI_CONN_STATE_RUNNING, "running");
SPDK_ISCSI_CONNECTION_STATUS(ISCSI_CONN_STATE_EXITING, "exiting");
SPDK_ISCSI_CONNECTION_STATUS(ISCSI_CONN_STATE_EXITED, "exited");
}
return "unknown";
}
static const char *
iscsi_conn_get_login_phase(struct spdk_iscsi_conn *conn)
{
switch (conn->login_phase) {
SPDK_ISCSI_CONNECTION_STATUS(ISCSI_SECURITY_NEGOTIATION_PHASE, "security_negotiation_phase");
SPDK_ISCSI_CONNECTION_STATUS(ISCSI_OPERATIONAL_NEGOTIATION_PHASE, "operational_negotiation_phase");
SPDK_ISCSI_CONNECTION_STATUS(ISCSI_FULL_FEATURE_PHASE, "full_feature_phase");
}
return "not_started";
}
SPDK_TRACE_REGISTER_FN(iscsi_conn_trace, "iscsi_conn", TRACE_GROUP_ISCSI) SPDK_TRACE_REGISTER_FN(iscsi_conn_trace, "iscsi_conn", TRACE_GROUP_ISCSI)
{ {
spdk_trace_register_owner(OWNER_ISCSI_CONN, 'c'); spdk_trace_register_owner(OWNER_ISCSI_CONN, 'c');
@ -1667,6 +1692,10 @@ iscsi_conn_info_json(struct spdk_json_write_ctx *w, struct spdk_iscsi_conn *conn
} }
spdk_json_write_named_int32(w, "tsih", tsih); spdk_json_write_named_int32(w, "tsih", tsih);
spdk_json_write_named_string(w, "state", iscsi_conn_get_state(conn));
spdk_json_write_named_string(w, "login_phase", iscsi_conn_get_login_phase(conn));
spdk_json_write_named_string(w, "initiator_addr", conn->initiator_addr); spdk_json_write_named_string(w, "initiator_addr", conn->initiator_addr);
spdk_json_write_named_string(w, "target_addr", conn->target_addr); spdk_json_write_named_string(w, "target_addr", conn->target_addr);