iscsi: Refine name and nesting structure of connection removal
Following change will make iSCSI connection management easier to read. Before: - _spdk_iscsi_conn_free(conn) is called by _spdk_iscsi_conn_check_shutdown(conn) or _spdk_iscsi_conn_destruct(conn). - spdk_iscsi_conn_remove_conn(conn) is called by _spdk_iscsi_conn_free(conn). - spdk_iscsi_conn_free(conn) is called by spdk_iscsi_remove_conn(conn). After - spdk_iscsi_conn_free(conn) is called by _spdk_iscsi_conn_check_shutdown(conn) or _spdk_iscsi_conn_destruct(conn). - _spdk_iscsi_conn_free(conn) is called by spdk_iscsi_conn_free(conn). This refinement is done by the following: - Call _func() by func(). func() is parent of _func(). - Inline spdk_iscsi_conn_remove_conn(conn) into _spdk_iscsi_conn_free(conn). Change-Id: Ia510df1f2921224fcfc51dad7bb85a1ac6197698 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/436230 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
d22d136bfc
commit
dbad9e1e60
@ -411,7 +411,8 @@ static int spdk_iscsi_conn_free_tasks(struct spdk_iscsi_conn *conn)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void spdk_iscsi_conn_free(struct spdk_iscsi_conn *conn)
|
static void
|
||||||
|
_spdk_iscsi_conn_free(struct spdk_iscsi_conn *conn)
|
||||||
{
|
{
|
||||||
if (conn == NULL) {
|
if (conn == NULL) {
|
||||||
return;
|
return;
|
||||||
@ -428,18 +429,40 @@ static void spdk_iscsi_conn_free(struct spdk_iscsi_conn *conn)
|
|||||||
free_conn(conn);
|
free_conn(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void spdk_iscsi_remove_conn(struct spdk_iscsi_conn *conn)
|
static void
|
||||||
|
spdk_iscsi_conn_cleanup_backend(struct spdk_iscsi_conn *conn)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
struct spdk_iscsi_tgt_node *target;
|
||||||
|
|
||||||
|
if (conn->sess->connections > 1) {
|
||||||
|
/* connection specific cleanup */
|
||||||
|
} else if (!g_spdk_iscsi.AllowDuplicateIsid) {
|
||||||
|
/* clean up all tasks to all LUNs for session */
|
||||||
|
target = conn->sess->target;
|
||||||
|
if (target != NULL) {
|
||||||
|
rc = spdk_iscsi_tgt_node_cleanup_luns(conn, target);
|
||||||
|
if (rc < 0) {
|
||||||
|
SPDK_ERRLOG("target abort failed\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
spdk_iscsi_conn_free(struct spdk_iscsi_conn *conn)
|
||||||
{
|
{
|
||||||
struct spdk_iscsi_sess *sess;
|
struct spdk_iscsi_sess *sess;
|
||||||
int idx;
|
int idx;
|
||||||
uint32_t i, j;
|
uint32_t i, j;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&g_conns_mutex);
|
||||||
|
|
||||||
idx = -1;
|
idx = -1;
|
||||||
sess = conn->sess;
|
sess = conn->sess;
|
||||||
conn->sess = NULL;
|
conn->sess = NULL;
|
||||||
if (sess == NULL) {
|
if (sess == NULL) {
|
||||||
spdk_iscsi_conn_free(conn);
|
goto end;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sess->connections; i++) {
|
for (i = 0; i < sess->connections; i++) {
|
||||||
@ -474,35 +497,10 @@ static void spdk_iscsi_remove_conn(struct spdk_iscsi_conn *conn)
|
|||||||
spdk_free_sess(sess);
|
spdk_free_sess(sess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "cleanup free conn\n");
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "cleanup free conn\n");
|
||||||
spdk_iscsi_conn_free(conn);
|
_spdk_iscsi_conn_free(conn);
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
spdk_iscsi_conn_cleanup_backend(struct spdk_iscsi_conn *conn)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
struct spdk_iscsi_tgt_node *target;
|
|
||||||
|
|
||||||
if (conn->sess->connections > 1) {
|
|
||||||
/* connection specific cleanup */
|
|
||||||
} else if (!g_spdk_iscsi.AllowDuplicateIsid) {
|
|
||||||
/* clean up all tasks to all LUNs for session */
|
|
||||||
target = conn->sess->target;
|
|
||||||
if (target != NULL) {
|
|
||||||
rc = spdk_iscsi_tgt_node_cleanup_luns(conn, target);
|
|
||||||
if (rc < 0) {
|
|
||||||
SPDK_ERRLOG("target abort failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_spdk_iscsi_conn_free(struct spdk_iscsi_conn *conn)
|
|
||||||
{
|
|
||||||
pthread_mutex_lock(&g_conns_mutex);
|
|
||||||
spdk_iscsi_remove_conn(conn);
|
|
||||||
pthread_mutex_unlock(&g_conns_mutex);
|
pthread_mutex_unlock(&g_conns_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,7 +518,7 @@ _spdk_iscsi_conn_check_shutdown(void *arg)
|
|||||||
spdk_poller_unregister(&conn->shutdown_timer);
|
spdk_poller_unregister(&conn->shutdown_timer);
|
||||||
|
|
||||||
spdk_iscsi_conn_stop(conn);
|
spdk_iscsi_conn_stop(conn);
|
||||||
_spdk_iscsi_conn_free(conn);
|
spdk_iscsi_conn_free(conn);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -542,7 +540,7 @@ _spdk_iscsi_conn_destruct(struct spdk_iscsi_conn *conn)
|
|||||||
conn->shutdown_timer = spdk_poller_register(_spdk_iscsi_conn_check_shutdown, conn, 1000);
|
conn->shutdown_timer = spdk_poller_register(_spdk_iscsi_conn_check_shutdown, conn, 1000);
|
||||||
} else {
|
} else {
|
||||||
spdk_iscsi_conn_stop(conn);
|
spdk_iscsi_conn_stop(conn);
|
||||||
_spdk_iscsi_conn_free(conn);
|
spdk_iscsi_conn_free(conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user