Commit 89859d31 authored by Jim Harris's avatar Jim Harris Committed by Daniel Verkamp
Browse files

iscsi: use temporary poller when PDUs cannot all be flushed



This removes PDU flushing from the main connection poller -
all PDU flushing is now done inline when the PDU is completed,
or from the context of the new flush poller.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I703cb451d4b548e7f75892e31a7927b511fb4f55

Reviewed-on: https://review.gerrithub.io/395543


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatar <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarZiye Yang <optimistyzy@gmail.com>
parent a1bbed81
Loading
Loading
Loading
Loading
+16 −17
Original line number Diff line number Diff line
@@ -693,6 +693,7 @@ void spdk_iscsi_conn_destruct(struct spdk_iscsi_conn *conn)
	spdk_clear_all_transfer_task(conn, NULL);
	spdk_sock_close(conn->sock);
	spdk_poller_unregister(&conn->logout_timer);
	spdk_poller_unregister(&conn->flush_poller);

	rc = spdk_iscsi_conn_free_tasks(conn);
	if (rc < 0) {
@@ -1218,13 +1219,19 @@ spdk_iscsi_conn_flush_pdus_internal(struct spdk_iscsi_conn *conn)
 * Returns -1 for an exceptional error indicating the TCP connection
 * should be closed.
 */
static int
spdk_iscsi_conn_flush_pdus(struct spdk_iscsi_conn *conn)
static void
spdk_iscsi_conn_flush_pdus(void *_conn)
{
	struct spdk_iscsi_conn *conn = _conn;
	int rc;

	if (conn->state == ISCSI_CONN_STATE_RUNNING) {
		rc = spdk_iscsi_conn_flush_pdus_internal(conn);
		if (rc == 0 && conn->flush_poller != NULL) {
			spdk_poller_unregister(&conn->flush_poller);
		} else if (rc == 1 && conn->flush_poller == NULL) {
			conn->flush_poller = spdk_poller_register(spdk_iscsi_conn_flush_pdus, conn, 50);
		}
	} else {
		/*
		 * If the connection state is not RUNNING, then
@@ -1237,16 +1244,6 @@ spdk_iscsi_conn_flush_pdus(struct spdk_iscsi_conn *conn)
		} while (rc == 1);
	}

	return rc;
}

void
spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
{
	int rc;

	TAILQ_INSERT_TAIL(&conn->write_pdu_list, pdu, tailq);
	rc = spdk_iscsi_conn_flush_pdus(conn);
	if (rc < 0 && conn->state < ISCSI_CONN_STATE_EXITING) {
		/*
		 * If the poller has already started destruction of the connection,
@@ -1257,6 +1254,13 @@ spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *p
	}
}

void
spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
{
	TAILQ_INSERT_TAIL(&conn->write_pdu_list, pdu, tailq);
	spdk_iscsi_conn_flush_pdus(conn);
}

#define GET_PDU_LOOP_COUNT	16

static int
@@ -1323,11 +1327,6 @@ spdk_iscsi_conn_execute(struct spdk_iscsi_conn *conn)
		conn_active = true;
	}

	if (spdk_iscsi_conn_flush_pdus(conn) < 0) {
		conn->state = ISCSI_CONN_STATE_EXITING;
		goto conn_exit;
	}

	spdk_iscsi_conn_handle_queued_datain_tasks(conn);

	if (conn_active) {
+1 −0
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ struct spdk_iscsi_conn {

	STAILQ_ENTRY(spdk_iscsi_conn) link;
	struct spdk_poller	*poller;
	struct spdk_poller	*flush_poller;
	TAILQ_HEAD(queued_r2t_tasks, spdk_iscsi_task)	queued_r2t_tasks;
	TAILQ_HEAD(active_r2t_tasks, spdk_iscsi_task)	active_r2t_tasks;
	TAILQ_HEAD(queued_datain_tasks, spdk_iscsi_task)	queued_datain_tasks;