lib/iscsi: Extract spdk_iscsi_conn_migration
Put it in the iscsi.c Change-Id: Ifb2843fb7c78f9ca948eac60704547b8b0635bf0 Signed-off-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-on: https://review.gerrithub.io/402484 Tested-by: SPDK Automated Test System <sys_sgsw@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:
parent
d4d03a5ecf
commit
b86af2c8d2
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user