diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index d0d6e23de..2c7aad110 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -1196,58 +1196,53 @@ spdk_iscsi_conn_full_feature_migrate(void *arg1, void *arg2) spdk_iscsi_poll_group_add_conn(conn, spdk_iscsi_conn_full_feature_do_work); } +void +spdk_iscsi_conn_migration(struct spdk_iscsi_conn *conn) +{ + int lcore; + struct spdk_event *event; + struct spdk_iscsi_tgt_node *target; + + lcore = spdk_iscsi_conn_allocate_reactor(conn->portal->cpumask); + if (conn->sess->session_type == SESSION_TYPE_NORMAL) { + target = conn->sess->target; + pthread_mutex_lock(&target->mutex); + target->num_active_conns++; + if (target->num_active_conns == 1) { + /** + * This is the only active connection for this target node. + * Save the lcore in the target node so it can be used for + * any other connections to this target node. + */ + target->lcore = lcore; + } else { + /** + * There are other active connections for this target node. + * Ignore the lcore specified by the allocator and use the + * the target node's lcore to ensure this connection runs on + * the same lcore as other connections for this target node. + */ + lcore = target->lcore; + } + pthread_mutex_unlock(&target->mutex); + } + + spdk_iscsi_poll_group_remove_conn_sock(conn); + spdk_iscsi_conn_stop(conn); + + __sync_fetch_and_add(&g_num_connections[lcore], 1); + event = spdk_event_allocate(lcore, spdk_iscsi_conn_full_feature_migrate, + conn, NULL); + spdk_event_call(event); +} + void spdk_iscsi_conn_login_do_work(void *arg) { struct spdk_iscsi_conn *conn = arg; - int lcore; - int rc; - struct spdk_event *event; /* iSCSI connection state check */ - rc = spdk_iscsi_conn_check_state(conn); - if (rc < 0) { - return; - } - - /* Check if this connection transitioned to full feature phase. If it - * did, migrate it to a dedicated reactor for the target node. - */ - if (conn->login_phase == ISCSI_FULL_FEATURE_PHASE) { - struct spdk_iscsi_tgt_node *target; - - lcore = spdk_iscsi_conn_allocate_reactor(conn->portal->cpumask); - if (conn->sess->session_type == SESSION_TYPE_NORMAL) { - target = conn->sess->target; - pthread_mutex_lock(&target->mutex); - target->num_active_conns++; - if (target->num_active_conns == 1) { - /** - * This is the only active connection for this target node. - * Save the lcore in the target node so it can be used for - * any other connections to this target node. - */ - target->lcore = lcore; - } else { - /** - * There are other active connections for this target node. - * Ignore the lcore specified by the allocator and use the - * the target node's lcore to ensure this connection runs on - * the same lcore as other connections for this target node. - */ - lcore = target->lcore; - } - pthread_mutex_unlock(&target->mutex); - } - - spdk_iscsi_poll_group_remove_conn_sock(conn); - spdk_iscsi_conn_stop(conn); - - __sync_fetch_and_add(&g_num_connections[lcore], 1); - event = spdk_event_allocate(lcore, spdk_iscsi_conn_full_feature_migrate, - conn, NULL); - spdk_event_call(event); - } + spdk_iscsi_conn_check_state(conn); } void diff --git a/lib/iscsi/conn.h b/lib/iscsi/conn.h index 7bea7d0c5..2d6e61bef 100644 --- a/lib/iscsi/conn.h +++ b/lib/iscsi/conn.h @@ -174,6 +174,7 @@ void spdk_shutdown_iscsi_conns(void); int spdk_iscsi_conn_construct(struct spdk_iscsi_portal *portal, struct spdk_sock *sock); void spdk_iscsi_conn_handle_nop(struct spdk_iscsi_conn *conn); +void spdk_iscsi_conn_migration(struct spdk_iscsi_conn *conn); void spdk_iscsi_conn_logout(struct spdk_iscsi_conn *conn); int spdk_iscsi_drop_conns(struct spdk_iscsi_conn *conn, const char *conn_match, int drop_all); diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 805d71b1f..23c62337c 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -2120,6 +2120,7 @@ spdk_iscsi_op_login_rsp_handle_t_bit(struct spdk_iscsi_conn *conn, } conn->full_feature = 1; + spdk_iscsi_conn_migration(conn); break; default: diff --git a/test/unit/lib/iscsi/iscsi.c/iscsi_ut.c b/test/unit/lib/iscsi/iscsi.c/iscsi_ut.c index 21f87d36e..686045130 100644 --- a/test/unit/lib/iscsi/iscsi.c/iscsi_ut.c +++ b/test/unit/lib/iscsi/iscsi.c/iscsi_ut.c @@ -86,6 +86,11 @@ spdk_iscsi_portal_grp_close_all(void) { } +void +spdk_iscsi_conn_migration(struct spdk_iscsi_conn *conn) +{ +} + void spdk_iscsi_conn_free_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) {