iscsi: login poller per portal and portal cache
A few foundational change to support safe removal of portal. - global login poller -> login poller per portal - Caching portal data for active connection Change-Id: I62f4d90c9ac11a433ad47421b2b0c69bfc3c70b7 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/379930 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
4185f77862
commit
666dc8af4e
@ -45,13 +45,12 @@
|
|||||||
|
|
||||||
#define ACCEPT_TIMEOUT_US 1000 /* 1ms */
|
#define ACCEPT_TIMEOUT_US 1000 /* 1ms */
|
||||||
|
|
||||||
static struct spdk_poller *g_acceptor_poller;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spdk_iscsi_portal_accept(struct spdk_iscsi_portal *portal)
|
spdk_iscsi_portal_accept(void *arg)
|
||||||
{
|
{
|
||||||
|
struct spdk_iscsi_portal *portal = arg;
|
||||||
int rc, sock;
|
int rc, sock;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
|
||||||
if (portal->sock < 0) {
|
if (portal->sock < 0) {
|
||||||
return;
|
return;
|
||||||
@ -77,29 +76,15 @@ spdk_iscsi_portal_accept(struct spdk_iscsi_portal *portal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
spdk_acceptor(void *arg)
|
|
||||||
{
|
|
||||||
struct spdk_iscsi_globals *iscsi = arg;
|
|
||||||
struct spdk_iscsi_portal_grp *portal_group;
|
|
||||||
struct spdk_iscsi_portal *portal;
|
|
||||||
|
|
||||||
TAILQ_FOREACH(portal_group, &iscsi->pg_head, tailq) {
|
|
||||||
TAILQ_FOREACH(portal, &portal_group->head, per_pg_tailq) {
|
|
||||||
spdk_iscsi_portal_accept(portal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
spdk_iscsi_acceptor_start(void)
|
spdk_iscsi_acceptor_start(struct spdk_iscsi_portal *p)
|
||||||
{
|
{
|
||||||
spdk_poller_register(&g_acceptor_poller, spdk_acceptor, &g_spdk_iscsi, spdk_env_get_current_core(),
|
spdk_poller_register(&p->acceptor_poller, spdk_iscsi_portal_accept, p, spdk_env_get_current_core(),
|
||||||
ACCEPT_TIMEOUT_US);
|
ACCEPT_TIMEOUT_US);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spdk_iscsi_acceptor_stop(void)
|
spdk_iscsi_acceptor_stop(struct spdk_iscsi_portal *p)
|
||||||
{
|
{
|
||||||
spdk_poller_unregister(&g_acceptor_poller, NULL);
|
spdk_poller_unregister(&p->acceptor_poller, NULL);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,9 @@
|
|||||||
#ifndef SPDK_ACCEPTOR_H_
|
#ifndef SPDK_ACCEPTOR_H_
|
||||||
#define SPDK_ACCEPTOR_H_
|
#define SPDK_ACCEPTOR_H_
|
||||||
|
|
||||||
void spdk_iscsi_acceptor_start(void);
|
struct spdk_iscsi_portal;
|
||||||
void spdk_iscsi_acceptor_stop(void);
|
|
||||||
|
void spdk_iscsi_acceptor_start(struct spdk_iscsi_portal *p);
|
||||||
|
void spdk_iscsi_acceptor_stop(struct spdk_iscsi_portal *p);
|
||||||
|
|
||||||
#endif /* SPDK_ACCEPTOR_H_ */
|
#endif /* SPDK_ACCEPTOR_H_ */
|
||||||
|
@ -125,6 +125,8 @@ allocate_conn(void)
|
|||||||
static void
|
static void
|
||||||
free_conn(struct spdk_iscsi_conn *conn)
|
free_conn(struct spdk_iscsi_conn *conn)
|
||||||
{
|
{
|
||||||
|
free(conn->portal_host);
|
||||||
|
free(conn->portal_port);
|
||||||
conn->is_valid = 0;
|
conn->is_valid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,6 +435,10 @@ spdk_iscsi_conn_construct(struct spdk_iscsi_portal *portal,
|
|||||||
conn->MaxRecvDataSegmentLength = 8192; // RFC3720(12.12)
|
conn->MaxRecvDataSegmentLength = 8192; // RFC3720(12.12)
|
||||||
|
|
||||||
conn->portal = portal;
|
conn->portal = portal;
|
||||||
|
conn->pg_tag = portal->group->tag;
|
||||||
|
conn->portal_host = strdup(portal->host);
|
||||||
|
conn->portal_port = strdup(portal->port);
|
||||||
|
conn->portal_cpumask = portal->cpumask;
|
||||||
conn->sock = sock;
|
conn->sock = sock;
|
||||||
|
|
||||||
conn->state = ISCSI_CONN_STATE_INVALID;
|
conn->state = ISCSI_CONN_STATE_INVALID;
|
||||||
|
@ -76,10 +76,14 @@ struct spdk_iscsi_conn {
|
|||||||
* SPDK_ISCSI_CONNECTION_MEMSET() macro if changing which fields
|
* SPDK_ISCSI_CONNECTION_MEMSET() macro if changing which fields
|
||||||
* are initialized when allocated.
|
* are initialized when allocated.
|
||||||
*/
|
*/
|
||||||
struct spdk_iscsi_portal *portal;
|
struct spdk_iscsi_portal *portal;
|
||||||
|
int pg_tag;
|
||||||
|
char *portal_host;
|
||||||
|
char *portal_port;
|
||||||
|
uint64_t portal_cpumask;
|
||||||
uint32_t lcore;
|
uint32_t lcore;
|
||||||
int sock;
|
int sock;
|
||||||
struct spdk_iscsi_sess *sess;
|
struct spdk_iscsi_sess *sess;
|
||||||
|
|
||||||
enum iscsi_connection_state state;
|
enum iscsi_connection_state state;
|
||||||
int login_phase;
|
int login_phase;
|
||||||
|
@ -2527,14 +2527,14 @@ spdk_iscsi_op_logout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
|||||||
snprintf(buf, sizeof buf, "Logout(login failed) from %s (%s) on"
|
snprintf(buf, sizeof buf, "Logout(login failed) from %s (%s) on"
|
||||||
" (%s:%s,%d)\n",
|
" (%s:%s,%d)\n",
|
||||||
conn->initiator_name, conn->initiator_addr,
|
conn->initiator_name, conn->initiator_addr,
|
||||||
conn->portal->host, conn->portal->port, conn->portal->group->tag);
|
conn->portal_host, conn->portal_port, conn->pg_tag);
|
||||||
} else if (spdk_iscsi_param_eq_val(conn->sess->params, "SessionType", "Normal")) {
|
} else if (spdk_iscsi_param_eq_val(conn->sess->params, "SessionType", "Normal")) {
|
||||||
snprintf(buf, sizeof buf, "Logout from %s (%s) on %s tgt_node%d"
|
snprintf(buf, sizeof buf, "Logout from %s (%s) on %s tgt_node%d"
|
||||||
" (%s:%s,%d), ISID=%"PRIx64", TSIH=%u,"
|
" (%s:%s,%d), ISID=%"PRIx64", TSIH=%u,"
|
||||||
" CID=%u, HeaderDigest=%s, DataDigest=%s\n",
|
" CID=%u, HeaderDigest=%s, DataDigest=%s\n",
|
||||||
conn->initiator_name, conn->initiator_addr,
|
conn->initiator_name, conn->initiator_addr,
|
||||||
conn->target->name, conn->target->num,
|
conn->target->name, conn->target->num,
|
||||||
conn->portal->host, conn->portal->port, conn->portal->group->tag,
|
conn->portal_host, conn->portal_port, conn->pg_tag,
|
||||||
conn->sess->isid, conn->sess->tsih, conn->cid,
|
conn->sess->isid, conn->sess->tsih, conn->cid,
|
||||||
(spdk_iscsi_param_eq_val(conn->params, "HeaderDigest", "CRC32C")
|
(spdk_iscsi_param_eq_val(conn->params, "HeaderDigest", "CRC32C")
|
||||||
? "on" : "off"),
|
? "on" : "off"),
|
||||||
@ -2546,7 +2546,7 @@ spdk_iscsi_op_logout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
|||||||
" (%s:%s,%d), ISID=%"PRIx64", TSIH=%u,"
|
" (%s:%s,%d), ISID=%"PRIx64", TSIH=%u,"
|
||||||
" CID=%u, HeaderDigest=%s, DataDigest=%s\n",
|
" CID=%u, HeaderDigest=%s, DataDigest=%s\n",
|
||||||
conn->initiator_name, conn->initiator_addr,
|
conn->initiator_name, conn->initiator_addr,
|
||||||
conn->portal->host, conn->portal->port, conn->portal->group->tag,
|
conn->portal_host, conn->portal_port, conn->pg_tag,
|
||||||
conn->sess->isid, conn->sess->tsih, conn->cid,
|
conn->sess->isid, conn->sess->tsih, conn->cid,
|
||||||
(spdk_iscsi_param_eq_val(conn->params, "HeaderDigest", "CRC32C")
|
(spdk_iscsi_param_eq_val(conn->params, "HeaderDigest", "CRC32C")
|
||||||
? "on" : "off"),
|
? "on" : "off"),
|
||||||
@ -4688,7 +4688,6 @@ spdk_append_iscsi_sess(struct spdk_iscsi_conn *conn,
|
|||||||
void
|
void
|
||||||
spdk_iscsi_shutdown(void)
|
spdk_iscsi_shutdown(void)
|
||||||
{
|
{
|
||||||
spdk_iscsi_acceptor_stop();
|
|
||||||
spdk_iscsi_portal_grp_close_all();
|
spdk_iscsi_portal_grp_close_all();
|
||||||
spdk_shutdown_iscsi_conns();
|
spdk_shutdown_iscsi_conns();
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
#include "iscsi/iscsi.h"
|
#include "iscsi/iscsi.h"
|
||||||
#include "iscsi/init_grp.h"
|
#include "iscsi/init_grp.h"
|
||||||
#include "iscsi/portal_grp.h"
|
#include "iscsi/portal_grp.h"
|
||||||
#include "iscsi/acceptor.h"
|
|
||||||
#include "iscsi/conn.h"
|
#include "iscsi/conn.h"
|
||||||
#include "iscsi/task.h"
|
#include "iscsi/task.h"
|
||||||
|
|
||||||
@ -956,8 +955,6 @@ spdk_iscsi_setup(void *arg1, void *arg2)
|
|||||||
SPDK_ERRLOG("spdk_iscsi_portal_grp_open_all() failed\n");
|
SPDK_ERRLOG("spdk_iscsi_portal_grp_open_all() failed\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spdk_iscsi_acceptor_start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "iscsi/tgt_node.h"
|
#include "iscsi/tgt_node.h"
|
||||||
#include "iscsi/conn.h"
|
#include "iscsi/conn.h"
|
||||||
#include "iscsi/portal_grp.h"
|
#include "iscsi/portal_grp.h"
|
||||||
|
#include "iscsi/acceptor.h"
|
||||||
|
|
||||||
#define PORTNUMSTRLEN 32
|
#define PORTNUMSTRLEN 32
|
||||||
|
|
||||||
@ -88,6 +89,7 @@ spdk_iscsi_portal_create(const char *host, const char *port, uint64_t cpumask)
|
|||||||
p->cpumask = cpumask;
|
p->cpumask = cpumask;
|
||||||
p->sock = -1;
|
p->sock = -1;
|
||||||
p->group = NULL; /* set at a later time by caller */
|
p->group = NULL; /* set at a later time by caller */
|
||||||
|
p->acceptor_poller = NULL;
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&g_spdk_iscsi.portal_head, p, g_tailq);
|
TAILQ_INSERT_TAIL(&g_spdk_iscsi.portal_head, p, g_tailq);
|
||||||
|
|
||||||
@ -126,6 +128,8 @@ spdk_iscsi_portal_open(struct spdk_iscsi_portal *p)
|
|||||||
|
|
||||||
p->sock = sock;
|
p->sock = sock;
|
||||||
|
|
||||||
|
spdk_iscsi_acceptor_start(p);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,6 +139,7 @@ spdk_iscsi_portal_close(struct spdk_iscsi_portal *p)
|
|||||||
if (p->sock >= 0) {
|
if (p->sock >= 0) {
|
||||||
SPDK_DEBUGLOG(SPDK_TRACE_NET, "close portal (%s, %s)\n",
|
SPDK_DEBUGLOG(SPDK_TRACE_NET, "close portal (%s, %s)\n",
|
||||||
p->host, p->port);
|
p->host, p->port);
|
||||||
|
spdk_iscsi_acceptor_stop(p);
|
||||||
close(p->sock);
|
close(p->sock);
|
||||||
p->sock = -1;
|
p->sock = -1;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ struct spdk_iscsi_portal {
|
|||||||
char *port;
|
char *port;
|
||||||
int sock;
|
int sock;
|
||||||
uint64_t cpumask;
|
uint64_t cpumask;
|
||||||
|
struct spdk_poller *acceptor_poller;
|
||||||
TAILQ_ENTRY(spdk_iscsi_portal) per_pg_tailq;
|
TAILQ_ENTRY(spdk_iscsi_portal) per_pg_tailq;
|
||||||
TAILQ_ENTRY(spdk_iscsi_portal) g_tailq;
|
TAILQ_ENTRY(spdk_iscsi_portal) g_tailq;
|
||||||
};
|
};
|
||||||
|
@ -368,7 +368,7 @@ spdk_iscsi_send_tgts(struct spdk_iscsi_conn *conn, const char *iiqn,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
rc = spdk_iscsi_tgt_node_visible(target, iiqn,
|
rc = spdk_iscsi_tgt_node_visible(target, iiqn,
|
||||||
conn->portal->group->tag);
|
conn->pg_tag);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ spdk_iscsi_send_tgts(struct spdk_iscsi_conn *conn, const char *iiqn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spdk_iscsi_acceptor_stop(void)
|
spdk_iscsi_acceptor_stop(struct spdk_iscsi_portal *p)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user