[Stgt-devel] Open connections

FUJITA Tomonori fujita.tomonori
Wed Mar 19 02:07:44 CET 2008


On Mon, 17 Mar 2008 15:31:42 +0100 (CET)
"Niels de Carpentier" <stgt at decarpentier.com> wrote:

> > On Sun, 16 Mar 2008 00:25:20 +0100 (CET)
> > "Niels de Carpentier" <stgt at decarpentier.com> wrote:
> >
> >> I did some more checking of the connection issue, and the problem is
> >> that
> >> the return code of it_destroy_nexus is not checked. In this case it will
> >> return EBUSY, and the connection is never actually removed.
> >
> > The EBUSY should not happen, session_put should handle it.
> >
> > Can you send me a tcpdump log of the whole booting process (use
> > `tcpdump -w boot.cap -s 1600`)?
> >
> Ok, I'll send you the tcpdump (It will be very large though). If it's any
> help, it always returns EBUSY at i = 15.
> 
> The reconnect issue seems to be related to some commented out code in
> login_security_done:
> 
>                 if (!req->tsih) {
>                         /* do session reinstatement */
>                         /* We need to close all connections in this
> session */
> /*                      session_conns_close(conn->tid, sid); */
> /*                      session = NULL; */
> 
> If I uncomment the session = NULL, things will work ok. (Of course this
> doesn't handle any cleanups, but indicates where the problem is)

Yeah, one of the problems is that tgt doesn't implement session
reinstatement properly.

Can you try the following patch?

Thanks,

diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 490a743..bc8a1d5 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -237,10 +237,16 @@ static void login_security_done(struct iscsi_connection *conn)
 	session = session_find_name(conn->tid, conn->initiator, req->isid);
 	if (session) {
 		if (!req->tsih) {
+			struct iscsi_connection *ent, *next;
+
 			/* do session reinstatement */
-			/* We need to close all connections in this session */
-/* 			session_conns_close(conn->tid, sid); */
-/* 			session = NULL; */
+
+			list_for_each_entry_safe(ent, next, &session->conn_list,
+						 clist) {
+				conn_close(ent);
+			}
+
+			session = NULL;
 		} else if (req->tsih != session->tsih) {
 			/* fail the login */
 			rsp->status_class = ISCSI_STATUS_CLS_INITIATOR_ERR;
@@ -250,8 +256,10 @@ static void login_security_done(struct iscsi_connection *conn)
 		} else if (conn_find(session, conn->cid)) {
 			/* do connection reinstatement */
 		}
+
 		/* add a new connection to the session */
-		conn_add_to_session(conn, session);
+		if (session)
+			conn_add_to_session(conn, session);
 	} else {
 		if (req->tsih) {
 			/* fail the login */



More information about the stgt mailing list