Commit fc35f1ae authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

iscsi: inline spdk_iscsi_conn_allocate_reactor



This function was only called from a single place, so just
move the code there.

Change-Id: I78c05ef41ca0d5684385e80cb75d699453c90792
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453018


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 1224a5a0
Loading
Loading
Loading
Loading
+27 −31
Original line number Diff line number Diff line
@@ -70,8 +70,6 @@ static pthread_mutex_t g_conns_mutex = PTHREAD_MUTEX_INITIALIZER;

static struct spdk_poller *g_shutdown_timer = NULL;

static uint32_t iscsi_conn_allocate_reactor(const struct spdk_cpuset *cpumask);

static void iscsi_conn_full_feature_migrate(void *arg1, void *arg2);
static void iscsi_conn_stop(struct spdk_iscsi_conn *conn);
static void iscsi_conn_sock_cb(void *arg, struct spdk_sock_group *group,
@@ -1420,14 +1418,38 @@ iscsi_conn_full_feature_migrate(void *arg1, void *arg2)
	iscsi_poll_group_add_conn(conn);
}

static uint32_t g_next_core = SPDK_ENV_LCORE_ID_ANY;

void
spdk_iscsi_conn_schedule(struct spdk_iscsi_conn *conn)
{
	int				lcore;
	struct spdk_event		*event;
	struct spdk_iscsi_tgt_node	*target;
	uint32_t			i;
	uint32_t			lcore;

	lcore = SPDK_ENV_LCORE_ID_ANY;

	for (i = 0; i < spdk_env_get_core_count(); i++) {
		if (g_next_core > spdk_env_get_last_core()) {
			g_next_core = spdk_env_get_first_core();
		}

		lcore = g_next_core;
		g_next_core = spdk_env_get_next_core(g_next_core);

		if (!spdk_cpuset_get_cpu(conn->portal->cpumask, lcore)) {
			continue;
		}

		break;
	}

	if (lcore >= spdk_env_get_core_count()) {
		SPDK_ERRLOG("Unable to schedule connection on allowed CPU core. Scheduling on first core instead.\n");
		lcore = spdk_env_get_first_core();
	}

	lcore = iscsi_conn_allocate_reactor(conn->portal->cpumask);
	if (conn->sess->session_type == SESSION_TYPE_NORMAL) {
		target = conn->sess->target;
		pthread_mutex_lock(&target->mutex);
@@ -1459,32 +1481,6 @@ spdk_iscsi_conn_schedule(struct spdk_iscsi_conn *conn)
	spdk_event_call(event);
}

static uint32_t g_next_core = SPDK_ENV_LCORE_ID_ANY;

static uint32_t
iscsi_conn_allocate_reactor(const struct spdk_cpuset *cpumask)
{
	uint32_t i, core;

	for (i = 0; i < spdk_env_get_core_count(); i++) {
		if (g_next_core > spdk_env_get_last_core()) {
			g_next_core = spdk_env_get_first_core();
		}

		core = g_next_core;
		g_next_core = spdk_env_get_next_core(g_next_core);

		if (!spdk_cpuset_get_cpu(cpumask, core)) {
			continue;
		}

		return core;
	}

	SPDK_ERRLOG("Unable to schedule connection on allowed CPU core. Scheduling on first core instead.\n");
	return spdk_env_get_first_core();
}

static int
logout_timeout(void *arg)
{