iscsi: Enforce to add/remove poll group on the core allocated to the connection

Currently all poll group operations are done on the core allocated
to the connection but spdk_env_get_current_core() is called in every
operation and they are not explicitly checked yet.

This patch adds check and uses conn->lcore to operate poll group.

Change-Id: Id3a882a51f4f2d7ed0074f9cd9a8ad5bd830234c
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/424743
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2018-09-06 10:38:18 +09:00 committed by Jim Harris
parent 92a5fb593c
commit f8d0f6d6cc

View File

@ -172,9 +172,13 @@ err:
static void
spdk_iscsi_poll_group_add_conn_sock(struct spdk_iscsi_conn *conn)
{
struct spdk_iscsi_poll_group *poll_group = &g_spdk_iscsi.poll_group[spdk_env_get_current_core()];
struct spdk_iscsi_poll_group *poll_group;
int rc;
assert(conn->lcore == spdk_env_get_current_core());
poll_group = &g_spdk_iscsi.poll_group[conn->lcore];
rc = spdk_sock_group_add_sock(poll_group->sock_group, conn->sock, spdk_iscsi_conn_sock_cb, conn);
if (rc < 0) {
SPDK_ERRLOG("Failed to add sock=%p of conn=%p\n", conn->sock, conn);
@ -184,9 +188,13 @@ spdk_iscsi_poll_group_add_conn_sock(struct spdk_iscsi_conn *conn)
static void
spdk_iscsi_poll_group_remove_conn_sock(struct spdk_iscsi_conn *conn)
{
struct spdk_iscsi_poll_group *poll_group = &g_spdk_iscsi.poll_group[spdk_env_get_current_core()];
struct spdk_iscsi_poll_group *poll_group;
int rc;
assert(conn->lcore == spdk_env_get_current_core());
poll_group = &g_spdk_iscsi.poll_group[conn->lcore];
rc = spdk_sock_group_remove_sock(poll_group->sock_group, conn->sock);
if (rc < 0) {
SPDK_ERRLOG("Failed to remove sock=%p of conn=%p\n", conn->sock, conn);
@ -196,7 +204,11 @@ spdk_iscsi_poll_group_remove_conn_sock(struct spdk_iscsi_conn *conn)
static void
spdk_iscsi_poll_group_add_conn(struct spdk_iscsi_conn *conn)
{
struct spdk_iscsi_poll_group *poll_group = &g_spdk_iscsi.poll_group[spdk_env_get_current_core()];
struct spdk_iscsi_poll_group *poll_group;
assert(conn->lcore == spdk_env_get_current_core());
poll_group = &g_spdk_iscsi.poll_group[conn->lcore];
conn->is_stopped = false;
STAILQ_INSERT_TAIL(&poll_group->connections, conn, link);
@ -206,7 +218,11 @@ spdk_iscsi_poll_group_add_conn(struct spdk_iscsi_conn *conn)
static void
spdk_iscsi_poll_group_remove_conn(struct spdk_iscsi_conn *conn)
{
struct spdk_iscsi_poll_group *poll_group = &g_spdk_iscsi.poll_group[spdk_env_get_current_core()];
struct spdk_iscsi_poll_group *poll_group;
assert(conn->lcore == spdk_env_get_current_core());
poll_group = &g_spdk_iscsi.poll_group[conn->lcore];
conn->is_stopped = true;
STAILQ_REMOVE(&poll_group->connections, conn, spdk_iscsi_conn, link);
@ -670,7 +686,9 @@ spdk_iscsi_conn_stop(struct spdk_iscsi_conn *conn)
spdk_iscsi_conn_close_luns(conn);
}
__sync_fetch_and_sub(&g_num_connections[spdk_env_get_current_core()], 1);
assert(conn->lcore == spdk_env_get_current_core());
__sync_fetch_and_sub(&g_num_connections[conn->lcore], 1);
spdk_iscsi_poll_group_remove_conn(conn);
}