[Stgt-devel] [PATCH 11/18] iser connection init

Pete Wyckoff pw
Tue Sep 4 22:09:55 CEST 2007


After successful negotiation, call into the transport to allocate resources
or otherwise ready the switch to full feature mode.

Signed-off-by: Pete Wyckoff <pw at osc.edu>
---
 usr/iscsi/iscsi_tcp.c |    6 ++++++
 usr/iscsi/iscsid.c    |   19 ++++++++++++++++++-
 usr/iscsi/transport.h |    1 +
 3 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/usr/iscsi/iscsi_tcp.c b/usr/iscsi/iscsi_tcp.c
index 33cd6f8..566dd9e 100644
--- a/usr/iscsi/iscsi_tcp.c
+++ b/usr/iscsi/iscsi_tcp.c
@@ -210,6 +210,11 @@ static int iscsi_tcp_init(void)
 	return !nr_sock;
 }
 
+static int iscsi_tcp_conn_init(struct iscsi_connection *conn)
+{
+	return 0;
+}
+
 static size_t iscsi_tcp_read(struct iscsi_connection *conn, void *buf,
 			     size_t nbytes)
 {
@@ -312,6 +317,7 @@ struct iscsi_transport iscsi_tcp = {
 	.name			= "iscsi",
 	.rdma			= 0,
 	.ep_init		= iscsi_tcp_init,
+	.ep_conn_init		= iscsi_tcp_conn_init,
 	.ep_read		= iscsi_tcp_read,
 	.ep_write_begin		= iscsi_tcp_write_begin,
 	.ep_write_end		= iscsi_tcp_write_end,
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 02906e8..e3cb8e1 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -469,12 +469,26 @@ static void login_start(struct iscsi_connection *conn)
 
 static void login_finish(struct iscsi_connection *conn)
 {
+	struct iscsi_login_rsp *rsp = (struct iscsi_login_rsp *) &conn->rsp.bhs;
+	int ret;
+
 	switch (conn->session_type) {
 	case SESSION_NORMAL:
 		if (!conn->mxdsl_negotiated)
 			/* use spec default if he did not mention MRDSL */
 			conn->session_param[ISCSI_PARAM_MAX_XMIT_DLENGTH].val =
 				session_keys[ISCSI_PARAM_MAX_XMIT_DLENGTH].def;
+		/*
+		 * Allocate transport resources for this connection.
+		 */
+		ret = conn->tp->ep_conn_init(conn);
+		if (ret) {
+			rsp->flags = 0;
+			rsp->status_class = ISCSI_STATUS_CLS_TARGET_ERR;
+			rsp->status_detail = ISCSI_LOGIN_STATUS_NO_RESOURCES;
+			conn->state = STATE_EXIT;
+			break;
+		}
 		if (!conn->session)
 			session_create(conn);
 		memcpy(conn->isid, conn->session->isid, sizeof(conn->isid));
@@ -641,8 +655,11 @@ static void cmnd_exec_login(struct iscsi_connection *conn)
 			default:
 				goto init_err;
 			}
-			if (!stay && !nsg_disagree)
+			if (!stay && !nsg_disagree) {
 				login_finish(conn);
+				if (rsp->status_class)
+					return;
+			}
 			break;
 		default:
 			goto init_err;
diff --git a/usr/iscsi/transport.h b/usr/iscsi/transport.h
index c1e9dc1..3421371 100644
--- a/usr/iscsi/transport.h
+++ b/usr/iscsi/transport.h
@@ -10,6 +10,7 @@ struct iscsi_transport {
 	int rdma;
 
 	int (*ep_init) (void);
+	int (*ep_conn_init) (struct iscsi_connection *conn);
 	size_t (*ep_read) (struct iscsi_connection *conn, void *buf,
 			   size_t nbytes);
 	size_t (*ep_write_begin) (struct iscsi_connection *conn, void *buf,
-- 
1.5.2.5




More information about the stgt mailing list