From 7614eafd64254f41b61684022fd5fea86ad435a9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 7 Nov 2015 00:00:42 +0000 Subject: [PATCH] iscsi-scst: Insert a blank line after declarations git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6616 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/config.c | 1 + iscsi-scst/kernel/conn.c | 2 ++ iscsi-scst/kernel/digest.c | 1 + iscsi-scst/kernel/iscsi.c | 9 +++++++++ iscsi-scst/kernel/iscsi.h | 1 + iscsi-scst/kernel/nthread.c | 14 ++++++++++++++ iscsi-scst/kernel/session.c | 2 ++ iscsi-scst/kernel/target.c | 2 ++ 8 files changed, 32 insertions(+) diff --git a/iscsi-scst/kernel/config.c b/iscsi-scst/kernel/config.c index f774ebcd3..2e39e2523 100644 --- a/iscsi-scst/kernel/config.c +++ b/iscsi-scst/kernel/config.c @@ -1297,6 +1297,7 @@ unsigned long iscsi_get_flow_ctrl_or_mgmt_dbg_log_flag(struct iscsi_cmnd *cmnd) flag = TRACE_MGMT_DEBUG; else { int status = scst_cmd_get_status(cmnd->scst_cmd); + if ((status == SAM_STAT_TASK_SET_FULL) || (status == SAM_STAT_BUSY)) flag = TRACE_FLOW_CONTROL; diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index 057747296..bbced03c2 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -525,6 +525,7 @@ static void conn_rsp_timer_fn(unsigned long arg) if (!list_empty(&conn->write_timeout_list)) { unsigned long timeout_time; + cmnd = list_first_entry(&conn->write_timeout_list, struct iscsi_cmnd, write_timeout_list_entry); @@ -834,6 +835,7 @@ void conn_free(struct iscsi_conn *conn) /* Just in case if new conn gets freed before the old one */ if (test_bit(ISCSI_CONN_REINSTATING, &conn->conn_aflags)) { struct iscsi_conn *c; + TRACE_MGMT_DBG("Freeing being reinstated conn %p", conn); list_for_each_entry(c, &session->conn_list, conn_list_entry) { diff --git a/iscsi-scst/kernel/digest.c b/iscsi-scst/kernel/digest.c index 5d682aab5..cbfff039e 100644 --- a/iscsi-scst/kernel/digest.c +++ b/iscsi-scst/kernel/digest.c @@ -76,6 +76,7 @@ static __be32 evaluate_crc32_from_sg(struct scatterlist *sg, int nbytes, while (nbytes > 0) { int d = min(nbytes, (int)(sg->length)); + crc = crc32c(crc, sg_virt(sg), d); nbytes -= d; sg++; diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index cca896e3f..b00deb720 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -138,6 +138,7 @@ static inline int cmnd_read_size(struct iscsi_cmnd *cmnd) if (ahdr != NULL) { uint8_t *p = (uint8_t *)ahdr; unsigned int size = 0; + do { int s; @@ -469,6 +470,7 @@ void cmnd_done(struct iscsi_cmnd *cmnd) { /* It can be for some aborted commands */ struct scst_cmd *scst_cmd = cmnd->scst_cmd; + TRACE_DBG("cmd %p AFTER_PREPROC", cmnd); cmnd->scst_state = ISCSI_CMD_STATE_RESTARTED; cmnd->scst_cmd = NULL; @@ -1087,6 +1089,7 @@ static void iscsi_tcp_send_data_rsp(struct iscsi_cmnd *req, u8 *sense, send_data_rsp(req, status, is_send_status); } else { struct iscsi_cmnd *rsp; + send_data_rsp(req, 0, 0); if (is_send_status) { rsp = create_status_rsp(req, status, sense, @@ -1221,6 +1224,7 @@ static int create_reject_rsp(struct iscsi_cmnd *req, int reason, bool get_data) if (req->scst_cmd == NULL) { /* BUSY status must be already set */ struct iscsi_scsi_rsp_hdr *rsp_hdr1; + rsp_hdr1 = (struct iscsi_scsi_rsp_hdr *)&req->main_rsp->pdu.bhs; sBUG_ON(rsp_hdr1->cmd_status == 0); /* @@ -1523,6 +1527,7 @@ int iscsi_preliminary_complete(struct iscsi_cmnd *req, #ifdef CONFIG_SCST_DEBUG { struct iscsi_hdr *req_hdr = &req->pdu.bhs; + TRACE_DBG_FLAG(iscsi_get_flow_ctrl_or_mgmt_dbg_log_flag(orig_req), "Prelim completed req %p, orig_req %p (FINAL %x, " "outstanding_r2t %d)", req, orig_req, @@ -2047,6 +2052,7 @@ static int scsi_cmnd_start(struct iscsi_cmnd *req) if ((req_hdr->flags & ISCSI_CMD_READ) && (req_hdr->flags & ISCSI_CMD_WRITE)) { int sz = cmnd_read_size(req); + if (unlikely(sz < 0)) { PRINT_ERROR("%s", "BIDI data transfer, but initiator " "not supplied Bidirectional Read Expected Data " @@ -2109,6 +2115,7 @@ static int scsi_cmnd_start(struct iscsi_cmnd *req) if (ahdr != NULL) { uint8_t *p = (uint8_t *)ahdr; unsigned int size = 0; + do { int s; @@ -2509,6 +2516,7 @@ static void iscsi_cmnd_abort_fn(struct work_struct *work) */ list_for_each_entry(conn, &session->conn_list, conn_list_entry) { struct iscsi_cmnd *c; + spin_lock_bh(&conn->cmd_list_lock); list_for_each_entry(c, &conn->cmd_list, cmd_list_entry) { if (c == cmnd) { @@ -3566,6 +3574,7 @@ static int iscsi_xmit_response(struct scst_cmd *scst_cmd) is_send_status); } else if (is_send_status) { struct iscsi_cmnd *rsp; + rsp = create_status_rsp(req, status, sense, sense_len); iscsi_cmnd_init_write(rsp, 0); } diff --git a/iscsi-scst/kernel/iscsi.h b/iscsi-scst/kernel/iscsi.h index 7a4ca36ab..986f5132c 100644 --- a/iscsi-scst/kernel/iscsi.h +++ b/iscsi-scst/kernel/iscsi.h @@ -693,6 +693,7 @@ static inline bool cmnd_get_check(struct iscsi_cmnd *cmnd) { int r = atomic_inc_return(&cmnd->ref_cnt); int res; + if (unlikely(r == 1)) { TRACE_DBG("cmnd %p is being destroyed", cmnd); atomic_dec(&cmnd->ref_cnt); diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index 00b9d4165..4adfc2ff5 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -100,6 +100,7 @@ again: for (i = 0; i < cmnd->sg_cnt; i++) { struct page *page = sg_page(&cmnd->sg[i]); + TRACE_CONN_CLOSE_DBG("page %p, net_priv %p, " "_count %d", page, page->net_priv, atomic_read(&page->_count)); @@ -282,8 +283,10 @@ static void trace_conn_close(struct iscsi_conn *conn) cmnd->sg); if (cmnd->sg != NULL) { int i; + for (i = 0; i < cmnd->sg_cnt; i++) { struct page *page = sg_page(&cmnd->sg[i]); + TRACE_CONN_CLOSE_DBG("page %p, " "net_priv %p, _count %d", page, page->net_priv, @@ -301,6 +304,7 @@ static void trace_conn_close(struct iscsi_conn *conn) atomic_read(&rsp->net_ref_cnt), rsp->sg); if (rsp->sg != cmnd->sg && rsp->sg) { int i; + for (i = 0; i < rsp->sg_cnt; i++) { TRACE_CONN_CLOSE_DBG(" page %p, " "net_priv %p, _count %d", @@ -459,6 +463,7 @@ static void close_conn(struct iscsi_conn *conn) spin_lock(&session->sn_lock); if (session->tm_rsp && session->tm_rsp->conn == conn) { struct iscsi_cmnd *tm_rsp = session->tm_rsp; + iscsi_drop_delayed_tm_rsp(tm_rsp); spin_unlock(&session->sn_lock); mutex_unlock(&target->target_mutex); @@ -795,6 +800,7 @@ static int iscsi_rx_check_ddigest(struct iscsi_conn *conn) res = digest_rx_data(cmnd); if (unlikely(res != 0)) { struct iscsi_cmnd *orig_req; + if (cmnd_opcode(cmnd) == ISCSI_OP_SCSI_DATA_OUT) orig_req = cmnd->cmd_req; else @@ -914,6 +920,7 @@ static int process_read_io(struct iscsi_conn *conn, int *closed) res = do_recv(conn); if (res == 0) { int psz = ((cmnd->pdu.datasize + 3) & -4) - cmnd->pdu.datasize; + if (psz != 0) { TRACE_DBG("padding %d bytes", psz); iscsi_conn_init_read(conn, @@ -1154,8 +1161,10 @@ static inline void __iscsi_put_page_callback(struct iscsi_cmnd *cmd) if (atomic_dec_and_test(&cmd->net_ref_cnt)) { int i, sg_cnt = cmd->sg_cnt; + for (i = 0; i < sg_cnt; i++) { struct page *page = sg_page(&cmd->sg[i]); + TRACE_NET_PAGE("Clearing page %p", page); if (page->net_priv == cmd) page->net_priv = NULL; @@ -1222,9 +1231,11 @@ void req_add_to_write_timeout_list(struct iscsi_cmnd *req) unsigned long req_tt = iscsi_get_timeout_time(req); struct iscsi_cmnd *r; bool inserted = false; + list_for_each_entry(r, &conn->write_timeout_list, write_timeout_list_entry) { unsigned long tt = iscsi_get_timeout_time(r); + if (time_after(tt, req_tt)) { TRACE_DBG("Add NOP IN req %p (tt %ld) before " "req %p (tt %ld)", req, req_tt, r, tt); @@ -1256,6 +1267,7 @@ void req_add_to_write_timeout_list(struct iscsi_cmnd *req) if (!timer_pending(&conn->rsp_timer)) { unsigned long timeout_time; + if (unlikely(conn->conn_tm_active || test_bit(ISCSI_CMD_ABORTED, &req->prelim_compl_flags))) { @@ -1276,6 +1288,7 @@ void req_add_to_write_timeout_list(struct iscsi_cmnd *req) &req->prelim_compl_flags))) { unsigned long timeout_time = jiffies + ISCSI_TM_DATA_WAIT_TIMEOUT + ISCSI_ADD_SCHED_TIME; + set_conn_tm_active = true; if (time_after(conn->rsp_timer.expires, timeout_time)) { TRACE_MGMT_DBG("Mod timer on %ld (conn %p)", @@ -1454,6 +1467,7 @@ retry: #if defined(CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION) { static DEFINE_SPINLOCK(net_priv_lock); + spin_lock(&net_priv_lock); if (unlikely(page->net_priv != NULL)) { if (page->net_priv != ref_cmd) { diff --git a/iscsi-scst/kernel/session.c b/iscsi-scst/kernel/session.c index 52dd682be..5b28d0fe4 100644 --- a/iscsi-scst/kernel/session.c +++ b/iscsi-scst/kernel/session.c @@ -199,6 +199,7 @@ int __add_session(struct iscsi_target *target, list_for_each_entry_reverse(sess, &target->session_list, session_list_entry) { union iscsi_sid s = *(union iscsi_sid *)&sess->sid; + s.id.tsih = 0; if ((sid.id64 == s.id64) && (strcmp(info->initiator_name, sess->initiator_name) == 0)) { @@ -332,6 +333,7 @@ int session_free(struct iscsi_session *session, bool del) if (session->sess_reinstating) { struct iscsi_session *s; + TRACE_MGMT_DBG("Freeing being reinstated sess %p", session); list_for_each_entry(s, &session->target->session_list, session_list_entry) { diff --git a/iscsi-scst/kernel/target.c b/iscsi-scst/kernel/target.c index 0677b7428..7a3e0a546 100644 --- a/iscsi-scst/kernel/target.c +++ b/iscsi-scst/kernel/target.c @@ -298,6 +298,7 @@ void target_del_session(struct iscsi_target *target, if (!list_empty(&session->conn_list)) { struct iscsi_conn *conn, *tc; + list_for_each_entry_safe(conn, tc, &session->conn_list, conn_list_entry) { TRACE_MGMT_DBG("Del session: closing conn %p", conn); @@ -616,6 +617,7 @@ ssize_t iscsi_sysfs_del_target(const char *target_name) /* We don't want to have tgt visible after the mutex unlock */ { struct iscsi_target *tgt; + mutex_lock(&target_mgmt_mutex); tgt = target_lookup_by_name(target_name); if (tgt == NULL) {