Re: help tgt segfault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 17 Dec 2008 18:51:41 +0100
Tomasz Chmielewski <mangoo@xxxxxxxx> wrote:

> FUJITA Tomonori schrieb:
> 
> > Can you try one more time with this patch (including the previous
> > patch so please do git-reset --hard first).
> 
> Here you are:
> 
> Dec 17 18:46:27 megathecus tgtd: Target daemon logger with pid=21048 started!

Thanks a lot! This is very useful.

Can you try this again? Even if tgtd doesn't crash, please send the
log.

Thanks,

diff --git a/usr/iscsi/conn.c b/usr/iscsi/conn.c
index c205397..be22f75 100644
--- a/usr/iscsi/conn.c
+++ b/usr/iscsi/conn.c
@@ -82,15 +82,26 @@ void conn_exit(struct iscsi_connection *conn)
 void conn_close(struct iscsi_connection *conn)
 {
 	struct iscsi_task *task, *tmp;
+	int ret;
 
-	conn->tp->ep_close(conn);
+	if (conn->closed) {
+		eprintf("connection already closed %p %u\n", conn, conn->refcount);
+		return;
+	}
+
+	conn->closed = 1;
 
-	eprintf("connection closed %p %u\n", conn, conn->refcount);
+	ret = conn->tp->ep_close(conn);
+
+	eprintf("connection closed %p %u %d %d\n",
+		conn, conn->refcount, ret, errno);
 
 	/* may not have been in FFP yet */
 	if (!conn->session)
 		goto done;
 
+	eprintf("sesson %p %d\n", conn->session, conn->session->refcount);
+
 	/*
 	 * We just closed the ep so we are not going to send/recv anything.
 	 * Just free these up since they are not going to complete.
diff --git a/usr/iscsi/iscsi_tcp.c b/usr/iscsi/iscsi_tcp.c
index 2320b3e..e7bd48d 100644
--- a/usr/iscsi/iscsi_tcp.c
+++ b/usr/iscsi/iscsi_tcp.c
@@ -164,8 +164,8 @@ static void iscsi_tcp_event_handler(int fd, int events, void *data)
 		iscsi_tx_handler(conn);
 
 	if (conn->state == STATE_CLOSE) {
+		eprintf("connection closed %p\n", conn);
 		conn_close(conn);
-		dprintf("connection closed\n");
 	}
 }
 
@@ -300,6 +300,8 @@ static void iscsi_tcp_release(struct iscsi_connection *conn)
 {
 	struct iscsi_tcp_connection *tcp_conn = TCP_CONN(conn);
 
+	eprintf("free connection %p\n", conn);
+
 	conn_exit(conn);
 	free(tcp_conn);
 }
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index c22a6f6..2bab387 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -240,9 +240,11 @@ static void login_security_done(struct iscsi_connection *conn)
 			struct iscsi_connection *ent, *next;
 
 			/* do session reinstatement */
+			eprintf("session reinstatement, %p\n", session);
 
 			list_for_each_entry_safe(ent, next, &session->conn_list,
 						 clist) {
+				eprintf("reinstatement close, %p %u\n", ent, ent->state);
 				conn_close(ent);
 			}
 
@@ -1085,6 +1087,8 @@ static int iscsi_scsi_cmd_done(uint64_t nid, int result, struct scsi_cmd *scmd)
 	 * task got reassinged to another connection.
 	 */
 	if (task->conn->state == STATE_CLOSE) {
+		eprintf("connection already closed %p %u\n",
+			task->conn, task->conn->refcount);
 		iscsi_free_cmd_task(task);
 		return 0;
 	}
diff --git a/usr/iscsi/iscsid.h b/usr/iscsi/iscsid.h
index c03263a..4a8deb9 100644
--- a/usr/iscsi/iscsid.h
+++ b/usr/iscsi/iscsid.h
@@ -130,6 +130,10 @@ struct iscsi_task {
 
 struct iscsi_connection {
 	int state;
+
+	/* should be a new state */
+	int closed;
+
 	int rx_iostate;
 	int tx_iostate;
 	int refcount;
diff --git a/usr/iscsi/session.c b/usr/iscsi/session.c
index 028d538..935053c 100644
--- a/usr/iscsi/session.c
+++ b/usr/iscsi/session.c
@@ -158,6 +158,8 @@ static void session_destroy(struct iscsi_session *session)
 
 	list_del(&session->hlist);
 
+	eprintf("free sesson %p\n", session);
+
 	free(session->initiator);
 	free(session->info);
 	free(session);
diff --git a/usr/tgtd.c b/usr/tgtd.c
index 758e7d5..f29dab1 100644
--- a/usr/tgtd.c
+++ b/usr/tgtd.c
@@ -137,6 +137,7 @@ static struct event_data *tgt_event_lookup(int fd)
 void tgt_event_del(int fd)
 {
 	struct event_data *tev;
+	int ret;
 
 	tev = tgt_event_lookup(fd);
 	if (!tev) {
@@ -144,7 +145,10 @@ void tgt_event_del(int fd)
 		return;
 	}
 
-	epoll_ctl(ep_fd, EPOLL_CTL_DEL, fd, NULL);
+	ret = epoll_ctl(ep_fd, EPOLL_CTL_DEL, fd, NULL);
+	if (ret < 0)
+		eprintf("fail to remove epoll event %d %d\n", ret, errno);
+
 	list_del(&tev->e_list);
 	free(tev);
 }

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux