lib/iscsi: Add nop_poller for iscsi polling group.
Change-Id: I7f0f64845a5b980632991e7b6d130e4be60ffa20 Signed-off-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-on: https://review.gerrithub.io/401749 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
7cf455c8e0
commit
1a907f11fd
@ -888,25 +888,33 @@ spdk_iscsi_get_pdu_length(struct spdk_iscsi_pdu *pdu, int header_digest,
|
||||
return total;
|
||||
}
|
||||
|
||||
static int
|
||||
void
|
||||
spdk_iscsi_conn_handle_nop(struct spdk_iscsi_conn *conn)
|
||||
{
|
||||
uint64_t tsc;
|
||||
|
||||
/**
|
||||
* This function will be executed by nop_poller of iSCSI polling group, so
|
||||
* we need to check the connection state first, then do the nop interval
|
||||
* expiration check work.
|
||||
*/
|
||||
if ((conn->state == ISCSI_CONN_STATE_EXITED) ||
|
||||
(conn->state == ISCSI_CONN_STATE_EXITING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check for nop interval expiration */
|
||||
tsc = spdk_get_ticks();
|
||||
if (conn->nop_outstanding) {
|
||||
if ((tsc - conn->last_nopin) > (conn->timeout * spdk_get_ticks_hz())) {
|
||||
SPDK_ERRLOG("Timed out waiting for NOP-Out response from initiator\n");
|
||||
SPDK_ERRLOG(" tsc=0x%lx, last_nopin=0x%lx\n", tsc, conn->last_nopin);
|
||||
return -1;
|
||||
conn->state = ISCSI_CONN_STATE_EXITING;
|
||||
}
|
||||
} else if (tsc - conn->last_nopin > conn->nopininterval) {
|
||||
conn->last_nopin = tsc;
|
||||
spdk_iscsi_send_nopin(conn);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1153,8 +1161,6 @@ spdk_iscsi_conn_sock_cb(void *arg, struct spdk_sock_group *group, struct spdk_so
|
||||
static int
|
||||
spdk_iscsi_conn_execute(struct spdk_iscsi_conn *conn)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (conn->state == ISCSI_CONN_STATE_EXITED) {
|
||||
return -1;
|
||||
}
|
||||
@ -1162,12 +1168,6 @@ spdk_iscsi_conn_execute(struct spdk_iscsi_conn *conn)
|
||||
if (conn->state == ISCSI_CONN_STATE_EXITING) {
|
||||
goto conn_exit;
|
||||
}
|
||||
/* Check for nop interval expiration */
|
||||
rc = spdk_iscsi_conn_handle_nop(conn);
|
||||
if (rc < 0) {
|
||||
conn->state = ISCSI_CONN_STATE_EXITING;
|
||||
goto conn_exit;
|
||||
}
|
||||
|
||||
spdk_iscsi_conn_handle_queued_datain_tasks(conn);
|
||||
|
||||
|
@ -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_destruct(struct spdk_iscsi_conn *conn);
|
||||
void spdk_iscsi_conn_handle_nop(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);
|
||||
|
@ -259,6 +259,7 @@ struct spdk_iscsi_sess {
|
||||
struct spdk_iscsi_poll_group {
|
||||
uint32_t core;
|
||||
struct spdk_poller *poller;
|
||||
struct spdk_poller *nop_poller;
|
||||
STAILQ_HEAD(connections, spdk_iscsi_conn) connections;
|
||||
struct spdk_sock_group *sock_group;
|
||||
};
|
||||
|
@ -850,6 +850,17 @@ spdk_iscsi_poll_group_poll(void *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_iscsi_poll_group_handle_nop(void *ctx)
|
||||
{
|
||||
struct spdk_iscsi_poll_group *group = ctx;
|
||||
struct spdk_iscsi_conn *conn, *tmp;
|
||||
|
||||
STAILQ_FOREACH_SAFE(conn, &group->connections, link, tmp) {
|
||||
spdk_iscsi_conn_handle_nop(conn);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
iscsi_create_poll_group_done(void *ctx)
|
||||
{
|
||||
@ -870,6 +881,8 @@ iscsi_create_poll_group(void *ctx)
|
||||
assert(pg->sock_group != NULL);
|
||||
|
||||
pg->poller = spdk_poller_register(spdk_iscsi_poll_group_poll, pg, 0);
|
||||
/* set the period to 1 sec */
|
||||
pg->nop_poller = spdk_poller_register(spdk_iscsi_poll_group_handle_nop, pg, 1000000);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -884,6 +897,7 @@ iscsi_unregister_poll_group(void *ctx)
|
||||
|
||||
spdk_sock_group_close(&pg->sock_group);
|
||||
spdk_poller_unregister(&pg->poller);
|
||||
spdk_poller_unregister(&pg->nop_poller);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user