From: <vl...@us...> - 2008-02-26 18:22:49
|
Revision: 296 http://scst.svn.sourceforge.net/scst/?rev=296&view=rev Author: vlnb Date: 2008-02-26 10:22:45 -0800 (Tue, 26 Feb 2008) Log Message: ----------- - Fixes for previous commit - Minor logging improvements Modified Paths: -------------- trunk/iscsi-scst/kernel/conn.c trunk/iscsi-scst/kernel/iscsi.c trunk/iscsi-scst/kernel/iscsi.h trunk/iscsi-scst/kernel/iscsi_dbg.h trunk/iscsi-scst/kernel/nthread.c trunk/iscsi-scst/kernel/session.c trunk/scst/src/dev_handlers/scst_user.c trunk/scst/src/scst_cdbprobe.h trunk/scst/src/scst_lib.c trunk/scst/src/scst_targ.c Modified: trunk/iscsi-scst/kernel/conn.c =================================================================== --- trunk/iscsi-scst/kernel/conn.c 2008-02-25 18:48:02 UTC (rev 295) +++ trunk/iscsi-scst/kernel/conn.c 2008-02-26 18:22:45 UTC (rev 296) @@ -329,6 +329,7 @@ sBUG_ON(atomic_read(&conn->conn_ref_cnt) != 0); sBUG_ON(!list_empty(&conn->cmd_list)); sBUG_ON(!list_empty(&conn->write_list)); + sBUG_ON(!list_empty(&conn->written_list)); list_del(&conn->conn_list_entry); Modified: trunk/iscsi-scst/kernel/iscsi.c =================================================================== --- trunk/iscsi-scst/kernel/iscsi.c 2008-02-25 18:48:02 UTC (rev 295) +++ trunk/iscsi-scst/kernel/iscsi.c 2008-02-26 18:22:45 UTC (rev 296) @@ -113,7 +113,7 @@ static inline void iscsi_fail_waiting_cmnd(struct iscsi_cmnd *cmnd) { - TRACE_DBG("Failing data waiting cmd %p", cmnd); + TRACE_MGMT_DBG("Failing data waiting cmd %p", cmnd); /* * There is no race with conn_abort(), since all functions @@ -182,7 +182,7 @@ if (unlikely(cmnd->on_write_list || cmnd->on_written_list)) { struct iscsi_scsi_cmd_hdr *req = cmnd_hdr(cmnd); - PRINT_ERROR("cmnd %p still on some list?, %x, %x, %x, %x, %x, %x, %x", + PRINT_CRIT_ERROR("cmnd %p still on some list?, %x, %x, %x, %x, %x, %x, %x", cmnd, req->opcode, req->scb[0], req->flags, req->itt, be32_to_cpu(req->data_length), req->cmd_sn, be32_to_cpu(cmnd->pdu.datasize)); @@ -190,7 +190,7 @@ if (unlikely(cmnd->parent_req)) { struct iscsi_scsi_cmd_hdr *req = cmnd_hdr(cmnd->parent_req); - PRINT_ERROR("%p %x %u", req, req->opcode, req->scb[0]); + PRINT_CRIT_ERROR("%p %x %u", req, req->opcode, req->scb[0]); } sBUG(); } @@ -254,7 +254,7 @@ scst_tgt_cmd_done(cmnd->scst_cmd); break; default: - PRINT_ERROR("Unexpected cmnd scst state %d", + PRINT_CRIT_ERROR("Unexpected cmnd scst state %d", cmnd->scst_state); sBUG(); break; @@ -290,6 +290,13 @@ "new value %d)", cmnd, sess, atomic_read(&sess->active_cmds)-1); atomic_dec(&sess->active_cmds); +#ifdef EXTRACHECKS + if (unlikely(atomic_read(&sess->active_cmds) < 0)) { + PRINT_CRIT_ERROR("active_cmds < 0 (%d)!!", + atomic_read(&sess->active_cmds)); + sBUG(); + } +#endif } cmnd_free(cmnd); @@ -310,7 +317,7 @@ TRACE_ENTRY(); - TRACE_DBG("%p", req); + TRACE_MGMT_DBG("%p", req); sBUG_ON(req == conn->read_cmnd); @@ -328,6 +335,7 @@ spin_unlock_bh(&conn->write_list_lock); list_for_each_entry_safe(rsp, t, &cmds_list, write_list_entry) { + TRACE_MGMT_DBG("Putting write rsp %p", rsp); list_del(&rsp->write_list_entry); cmnd_put(rsp); } @@ -361,6 +369,7 @@ * If both on_write_list and write_processing_started not set, * we can safely put() rsp. */ + TRACE_MGMT_DBG("Putting rsp %p", rsp); cmnd_put(rsp); goto again_rsp; } @@ -412,6 +421,13 @@ atomic_read(&sess->active_cmds)-1); atomic_dec(&sess->active_cmds); req->dec_active_cmnds = 0; +#ifdef EXTRACHECKS + if (unlikely(atomic_read(&sess->active_cmds) < 0)) { + PRINT_CRIT_ERROR("active_cmds < 0 (%d)!!", + atomic_read(&sess->active_cmds)); + sBUG(); + } +#endif } cmnd_put(req); @@ -533,7 +549,7 @@ LIST_HEAD(head); if (unlikely(rsp->on_write_list)) { - PRINT_ERROR("cmd already on write list (%x %x %x %x %u %u " + PRINT_CRIT_ERROR("cmd already on write list (%x %x %x %x %u %u " "%u %u %u %u %u %d %d", cmnd_itt(rsp), cmnd_ttt(rsp), cmnd_opcode(rsp), cmnd_scsicode(rsp), rsp->r2t_sn, @@ -1605,8 +1621,10 @@ cmnd_put(cmnd); err = 0; - } else + } else { + TRACE_MGMT_DBG("cmd RTT %x not found", req_hdr->rtt); err = ISCSI_RESPONSE_UNKNOWN_TASK; + } out: return err; @@ -1834,6 +1852,7 @@ ISCSI_RESPONSE_FUNCTION_UNSUPPORTED); break; default: + PRINT_ERROR("Unknown TM function %d", function); iscsi_send_task_mgmt_resp(req, ISCSI_RESPONSE_FUNCTION_REJECTED); break; @@ -2076,7 +2095,7 @@ case ISCSI_OP_LOGOUT_RSP: break; default: - PRINT_ERROR("unexpected cmnd op %x", cmnd_opcode(cmnd)); + PRINT_CRIT_ERROR("unexpected cmnd op %x", cmnd_opcode(cmnd)); sBUG(); break; } @@ -2497,7 +2516,7 @@ if (unlikely((req->bufflen != 0) && !(resp_flags & SCST_TSC_FLAG_STATUS))) { - PRINT_ERROR("%s", "Sending DATA without STATUS is unsupported"); + PRINT_CRIT_ERROR("%s", "Sending DATA without STATUS is unsupported"); scst_set_cmd_error(scst_cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); resp_flags = scst_cmd_get_tgt_resp_flags(scst_cmd); Modified: trunk/iscsi-scst/kernel/iscsi.h =================================================================== --- trunk/iscsi-scst/kernel/iscsi.h 2008-02-25 18:48:02 UTC (rev 295) +++ trunk/iscsi-scst/kernel/iscsi.h 2008-02-26 18:22:45 UTC (rev 296) @@ -235,7 +235,10 @@ struct iscsi_cmnd { struct iscsi_conn *conn; - /* Some flags protected by conn->write_list_lock */ + /* + * Some flags protected by conn->write_list_lock, but all modified only + * from single read thread or when there are no references to cmd. + */ unsigned int hashed:1; unsigned int should_close_conn:1; unsigned int pending:1; @@ -246,7 +249,6 @@ unsigned int force_cleanup_done:1; unsigned int dec_active_cmnds:1; unsigned int ddigest_checked:1; - unsigned int on_written_list:1; #ifdef EXTRACHECKS unsigned int on_rx_digest_list:1; unsigned int release_called:1; @@ -271,6 +273,8 @@ struct list_head write_list_entry; }; + /* Both modified only from single write thread */ + unsigned int on_written_list:1; unsigned long write_timeout; /* Modified: trunk/iscsi-scst/kernel/iscsi_dbg.h =================================================================== --- trunk/iscsi-scst/kernel/iscsi_dbg.h 2008-02-25 18:48:02 UTC (rev 295) +++ trunk/iscsi-scst/kernel/iscsi_dbg.h 2008-02-26 18:22:45 UTC (rev 296) @@ -35,7 +35,7 @@ #ifdef DEBUG #define ISCSI_DEFAULT_LOG_FLAGS (TRACE_FUNCTION | TRACE_LINE | TRACE_PID | \ TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MGMT_MINOR | TRACE_MGMT_DEBUG | \ - TRACE_MINOR | TRACE_SPECIAL | TRACE_CONN_OC) + TRACE_MINOR | TRACE_SPECIAL | TRACE_CONN_OC | TRACE_CONN_OC_DBG) #else #define ISCSI_DEFAULT_LOG_FLAGS (TRACE_OUT_OF_MEM | TRACE_MGMT | \ TRACE_MINOR | TRACE_SPECIAL) Modified: trunk/iscsi-scst/kernel/nthread.c =================================================================== --- trunk/iscsi-scst/kernel/nthread.c 2008-02-25 18:48:02 UTC (rev 295) +++ trunk/iscsi-scst/kernel/nthread.c 2008-02-26 18:22:45 UTC (rev 296) @@ -63,7 +63,7 @@ if ((conn->sock->sk->sk_state != TCP_CLOSE_WAIT) && (conn->sock->sk->sk_state != TCP_CLOSE)) { - TRACE_CONN_CLOSE_DBG("sk_state %d, skipping", + TRACE_CONN_CLOSE("sk_state %d, skipping", conn->sock->sk->sk_state); goto out; } @@ -407,7 +407,16 @@ conn->sock->sk->sk_write_space = conn->old_write_space; write_unlock_bh(&conn->sock->sk->sk_callback_lock); - while(conn->wr_state != ISCSI_CONN_WR_STATE_IDLE) { + while(1) { + bool t; + + spin_lock_bh(&iscsi_wr_lock); + t = (conn->wr_state == ISCSI_CONN_WR_STATE_IDLE); + spin_unlock_bh(&iscsi_wr_lock); + + if (t && (atomic_read(&conn->conn_ref_cnt) == 0)) + break; + TRACE_CONN_CLOSE("Waiting for wr thread (conn %p), wr_state %x", conn, conn->wr_state); msleep(50); @@ -418,6 +427,8 @@ wait_for_completion(&session->unreg_compl); + sBUG_ON(!session->shutting_down); + mutex_lock(&target->target_mutex); conn_free(conn); /* ToDo: this is incompatible with MC/S */ @@ -681,7 +692,7 @@ } break; default: - PRINT_ERROR("%d %x", conn->read_state, cmnd_opcode(cmnd)); + PRINT_CRIT_ERROR("%d %x", conn->read_state, cmnd_opcode(cmnd)); sBUG(); } @@ -692,7 +703,8 @@ goto out; if (unlikely(conn->read_size)) { - PRINT_ERROR("%d %x %d", res, cmnd_opcode(cmnd), conn->read_size); + PRINT_CRIT_ERROR("%d %x %d", res, cmnd_opcode(cmnd), + conn->read_size); sBUG(); } @@ -903,7 +915,7 @@ } if (!timer_pending(&conn->rsp_timer)) { - sBUG_ON(!ref_cmd->write_timeout); + sBUG_ON(!ref_cmd->on_written_list); spin_lock_bh(&conn->write_list_lock); if (likely(!timer_pending(&conn->rsp_timer))) { TRACE_DBG("Starting timer on %ld (conn %p)", @@ -989,7 +1001,7 @@ #ifdef NET_PAGE_CALLBACKS_DEFINED if (unlikely((sg_page(&sg[idx])->net_priv != NULL) && (sg_page(&sg[idx])->net_priv != ref_cmd))) { - PRINT_ERROR("net_priv isn't NULL and != ref_cmd " + PRINT_CRIT_ERROR("net_priv isn't NULL and != ref_cmd " "(write_cmnd %p, ref_cmd %p, sg %p, idx %d, " "net_priv %p)", write_cmnd, ref_cmd, sg, idx, sg_page(&sg[idx])->net_priv); @@ -1200,7 +1212,7 @@ res = tx_ddigest(cmnd, TX_END); break; default: - PRINT_ERROR("%d %d %x", res, conn->write_state, + PRINT_CRIT_ERROR("%d %d %x", res, conn->write_state, cmnd_opcode(cmnd)); sBUG(); } @@ -1212,7 +1224,7 @@ goto out; if (unlikely(conn->write_size)) { - PRINT_ERROR("%d %x %u", res, cmnd_opcode(cmnd), + PRINT_CRIT_ERROR("%d %x %u", res, cmnd_opcode(cmnd), conn->write_size); sBUG(); } Modified: trunk/iscsi-scst/kernel/session.c =================================================================== --- trunk/iscsi-scst/kernel/session.c 2008-02-25 18:48:02 UTC (rev 295) +++ trunk/iscsi-scst/kernel/session.c 2008-02-26 18:22:45 UTC (rev 296) @@ -134,7 +134,7 @@ sBUG_ON(!list_empty(&session->conn_list)); if (unlikely(atomic_read(&session->active_cmds) != 0)) { - PRINT_ERROR("active_cmds not 0 (%d)!!", + PRINT_CRIT_ERROR("active_cmds not 0 (%d)!!", atomic_read(&session->active_cmds)); sBUG(); } Modified: trunk/scst/src/dev_handlers/scst_user.c =================================================================== --- trunk/scst/src/dev_handlers/scst_user.c 2008-02-25 18:48:02 UTC (rev 295) +++ trunk/scst/src/dev_handlers/scst_user.c 2008-02-26 18:22:45 UTC (rev 296) @@ -1946,7 +1946,7 @@ } default: - PRINT_ERROR("Wrong ucmd state %x", state); + PRINT_CRIT_ERROR("Wrong ucmd state %x", state); sBUG(); break; } Modified: trunk/scst/src/scst_cdbprobe.h =================================================================== --- trunk/scst/src/scst_cdbprobe.h 2008-02-25 18:48:02 UTC (rev 295) +++ trunk/scst/src/scst_cdbprobe.h 2008-02-26 18:22:45 UTC (rev 296) @@ -118,7 +118,7 @@ {0x03, "MMMMMMMMMMMMMMMM", "REQUEST SENSE", SCST_DATA_READ, SCST_SMALL_TIMEOUT, 4, get_trans_len_1}, {0x04, "M O O ", "FORMAT UNIT", - SCST_DATA_NONE, SCST_LONG_TIMEOUT, 0, get_trans_len_none}, + SCST_DATA_WRITE, SCST_LONG_TIMEOUT|SCST_UNKNOWN_LENGTH, 0, get_trans_len_none}, {0x04, " O ", "FORMAT", SCST_DATA_NONE, FLAG_NONE, 0, get_trans_len_none}, {0x05, "VMVVVV V ", "READ BLOCK LIMITS", Modified: trunk/scst/src/scst_lib.c =================================================================== --- trunk/scst/src/scst_lib.c 2008-02-25 18:48:02 UTC (rev 295) +++ trunk/scst/src/scst_lib.c 2008-02-26 18:22:45 UTC (rev 296) @@ -260,7 +260,7 @@ #ifdef EXTRACHECKS if (!list_empty(&dev->dev_tgt_dev_list) || !list_empty(&dev->dev_acg_dev_list)) { - PRINT_ERROR("%s: dev_tgt_dev_list or dev_acg_dev_list " + PRINT_CRIT_ERROR("%s: dev_tgt_dev_list or dev_acg_dev_list " "is not empty!", __FUNCTION__); sBUG(); } Modified: trunk/scst/src/scst_targ.c =================================================================== --- trunk/scst/src/scst_targ.c 2008-02-25 18:48:02 UTC (rev 295) +++ trunk/scst/src/scst_targ.c 2008-02-26 18:22:45 UTC (rev 296) @@ -63,7 +63,7 @@ #ifdef EXTRACHECKS if (unlikely(sess->shut_phase != SCST_SESS_SPH_READY)) { - PRINT_ERROR("%s", "New cmd while shutting down the session"); + PRINT_CRIT_ERROR("%s", "New cmd while shutting down the session"); sBUG(); } #endif @@ -381,13 +381,15 @@ if (scst_cmd_is_expected_set(cmd)) { /* * Command data length can't be easily - * determined from the CDB. ToDo, that should - * be fixed. Until it's fixed, get it from - * the supplied expected value, but - * limit it to some reasonable value (15MB). + * determined from the CDB. ToDo, all such + * commands should be fixed. Until they are + * fixed, get it from the supplied expected + * value, but limit it to some reasonable + * value (15MB). */ cmd->bufflen = min(cmd->expected_transfer_len, 15*1024*1024); + cmd->op_flags &= ~SCST_UNKNOWN_LENGTH; } else cmd->bufflen = 0; } @@ -3136,8 +3138,8 @@ break; default: - PRINT_ERROR("cmd (%p) in state %d, but shouldn't be", - cmd, cmd->state); + PRINT_CRIT_ERROR("cmd (%p) in state %d, but shouldn't " + "be", cmd, cmd->state); sBUG(); res = SCST_CMD_STATE_RES_CONT_NEXT; break; @@ -3169,7 +3171,7 @@ /* not very valid commands */ case SCST_CMD_STATE_DEFAULT: case SCST_CMD_STATE_NEED_THREAD_CTX: - PRINT_ERROR("cmd %p is in state %d, not putting on " + PRINT_CRIT_ERROR("cmd %p is in state %d, not putting on " "useful list (left on scst cmd list)", cmd, cmd->state); spin_unlock_irq(&cmd->cmd_lists->cmd_list_lock); @@ -4575,7 +4577,7 @@ scst_sess_get(sess); if (unlikely(sess->shut_phase != SCST_SESS_SPH_READY)) { - PRINT_ERROR("New mgmt cmd while shutting down the session %p " + PRINT_CRIT_ERROR("New mgmt cmd while shutting down the session %p " "shut_phase %ld", sess, sess->shut_phase); sBUG(); } @@ -5024,7 +5026,7 @@ if (sess->init_phase == SCST_SESS_IPH_INITING) scst_init_session(sess); else { - PRINT_ERROR("session %p is in " + PRINT_CRIT_ERROR("session %p is in " "scst_sess_init_list, but in unknown " "init phase %x", sess, sess->init_phase); @@ -5051,7 +5053,7 @@ scst_free_session_callback(sess); break; default: - PRINT_ERROR("session %p is in " + PRINT_CRIT_ERROR("session %p is in " "scst_sess_shut_list, but in unknown " "shut phase %lx", sess, sess->shut_phase); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |