[stgt] [BUG] Tgt-1.0.8 exited unexpectedly

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Sun Nov 21 07:49:26 CET 2010


On Wed, 27 Oct 2010 07:10:50 +0900 (JST)
Hirokazu Takahashi <taka at valinux.co.jp> wrote:

> It finally crashed when I hit "tgtadm  --lld iscsi --op show  --mode=target."
> You can find the core and logs here when it crashed:
>   http://people.valinux.co.jp/~taka/tgtd/

Can you try the following patch against the latest git?

Please send me a log when it crashes.

Thanks,

diff --git a/usr/bs.c b/usr/bs.c
index d72d090..3fdcd1d 100644
--- a/usr/bs.c
+++ b/usr/bs.c
@@ -179,6 +179,14 @@ static void bs_sig_request_done(int fd, int events, void *data)
 	}
 }
 
+void bs_wait_one_completion(void)
+{
+	if (sig_fd < 0)
+		bs_thread_request_done(0, 0, NULL);
+	else
+		bs_sig_request_done(sig_fd, 0, NULL);
+}
+
 static void *bs_thread_worker_fn(void *arg)
 {
 	struct bs_thread_info *info = arg;
diff --git a/usr/bs_thread.h b/usr/bs_thread.h
index d460032..14456a7 100644
--- a/usr/bs_thread.h
+++ b/usr/bs_thread.h
@@ -29,3 +29,4 @@ extern int bs_thread_open(struct bs_thread_info *info, request_func_t *rfn,
 extern void bs_thread_close(struct bs_thread_info *info);
 extern int bs_thread_cmd_submit(struct scsi_cmd *cmd);
 
+extern void bs_wait_one_completion(void);
diff --git a/usr/iscsi/conn.c b/usr/iscsi/conn.c
index a3af6a4..aecc926 100644
--- a/usr/iscsi/conn.c
+++ b/usr/iscsi/conn.c
@@ -115,14 +115,14 @@ void conn_close(struct iscsi_connection *conn)
 		if (task->conn != conn)
 			continue;
 
-		eprintf("Forcing release of pending task %p %" PRIx64 "\n",
-			task, task->tag);
+		eprintf("Forcing release of pending task %p %" PRIx64 " %u\n",
+			task, task->tag, conn->refcount);
 		list_del(&task->c_list);
 		iscsi_free_task(task);
 	}
 
 	if (conn->tx_task) {
-		dprintf("Add current tx task to the tx list for removal "
+		eprintf("Add current tx task to the tx list for removal "
 			"%p %" PRIx64 "\n",
 			conn->tx_task, conn->tx_task->tag);
 		list_add(&conn->tx_task->c_list, &conn->tx_clist);
@@ -134,8 +134,8 @@ void conn_close(struct iscsi_connection *conn)
 
 		op = task->req.opcode & ISCSI_OPCODE_MASK;
 
-		eprintf("Forcing release of tx task %p %" PRIx64 " %x\n",
-			task, task->tag, op);
+		eprintf("Forcing release of tx task %p %" PRIx64 " %x %u\n",
+			task, task->tag, op, conn->refcount);
 		switch (op) {
 		case ISCSI_OP_SCSI_CMD:
 			/*
@@ -155,14 +155,14 @@ void conn_close(struct iscsi_connection *conn)
 			iscsi_free_task(task);
 			break;
 		default:
-			eprintf("%x\n", op);
+			eprintf("unknow op %x\n", op);
 			break;
 		}
 	}
 
 	if (conn->rx_task) {
-		eprintf("Forcing release of rx task %p %" PRIx64 "\n",
-			conn->rx_task, conn->rx_task->tag);
+		eprintf("Forcing release of rx task %p %" PRIx64 " %u\n",
+			conn->rx_task, conn->rx_task->tag, conn->refcount);
 		iscsi_free_task(conn->rx_task);
 	}
 	conn->rx_task = NULL;
@@ -173,10 +173,20 @@ void conn_close(struct iscsi_connection *conn)
 		 * This task is in SCSI. We need to wait for I/O
 		 * completion.
 		 */
+		eprintf("release task %p %" PRIx64 " flag %lx, %u\n",
+			task, task->tag, task->flags, conn->refcount);
+
 		if (task_in_scsi(task))
 			continue;
 		iscsi_free_task(task);
 	}
+
+	eprintf("%p %u\n", conn, conn->refcount);
+
+	while (conn->refcount != 1) {
+		bs_wait_one_completion();
+		eprintf("%p %u\n", conn, conn->refcount);
+	}
 done:
 	conn_put(conn);
 }
diff --git a/usr/iscsi/iscsi_tcp.c b/usr/iscsi/iscsi_tcp.c
index 8fc145f..4936946 100644
--- a/usr/iscsi/iscsi_tcp.c
+++ b/usr/iscsi/iscsi_tcp.c
@@ -164,7 +164,7 @@ static void iscsi_tcp_event_handler(int fd, int events, void *data)
 		iscsi_tx_handler(conn);
 
 	if (conn->state == STATE_CLOSE) {
-		dprintf("connection closed %p\n", conn);
+		eprintf("connection closed %p\n", conn);
 		conn_close(conn);
 	}
 }
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 3a79d93..65aea4c 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -1186,6 +1186,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("finish a task on a closed conn, %p %u\n",
+			task, task->conn->refcount);
 		iscsi_free_cmd_task(task);
 		return 0;
 	}
@@ -1375,6 +1377,8 @@ static int iscsi_tm_execute(struct iscsi_task *task)
 	struct iscsi_tm *req = (struct iscsi_tm *) &task->req;
 	int fn = 0, err = 0;
 
+	eprintf("%x\n", req->flags & ISCSI_FLAG_TM_FUNC_MASK);
+
 	switch (req->flags & ISCSI_FLAG_TM_FUNC_MASK) {
 	case ISCSI_TM_FUNC_ABORT_TASK:
 		fn = ABORT_TASK;
@@ -1403,6 +1407,8 @@ static int iscsi_tm_execute(struct iscsi_task *task)
 			req->flags & ISCSI_FLAG_TM_FUNC_MASK);
 	}
 
+	err = ISCSI_TMF_RSP_NOT_SUPPORTED;
+
 	if (err)
 		task->result = err;
 	else {
diff --git a/usr/util.h b/usr/util.h
index 24a5eb7..ad956dd 100644
--- a/usr/util.h
+++ b/usr/util.h
@@ -132,23 +132,24 @@ static inline int __sync_file_range(int fd, __off64_t offset, __off64_t bytes)
 
 static inline int __signalfd(int fd, const sigset_t *mask, int flags)
 {
-	int fd2, ret;
+	/* int fd2, ret; */
+	int fd2;
 
 	fd2 = syscall(__NR_signalfd, fd, mask, _NSIG / 8);
 	if (fd2 < 0)
 		return fd2;
 
-	ret = fcntl(fd2, F_GETFL);
-	if (ret < 0) {
-		close(fd2);
-		return -1;
-	}
-
-	ret = fcntl(fd2, F_SETFL, ret | O_NONBLOCK);
-	if (ret < 0) {
-		close(fd2);
-		return -1;
-	}
+	/* ret = fcntl(fd2, F_GETFL); */
+	/* if (ret < 0) { */
+	/* 	close(fd2); */
+	/* 	return -1; */
+	/* } */
+
+	/* ret = fcntl(fd2, F_SETFL, ret | O_NONBLOCK); */
+	/* if (ret < 0) { */
+	/* 	close(fd2); */
+	/* 	return -1; */
+	/* } */
 
 	return fd2;
 }

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



More information about the stgt mailing list