From 713410951bfe1cd74adce74db5676b8bcdff078e Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 25 Feb 2010 13:37:56 +0000 Subject: [PATCH] Minor fixes and cleanups git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1520 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/conn.c | 3 +++ iscsi-scst/kernel/iscsi.c | 9 +++++++-- iscsi-scst/kernel/iscsi.h | 5 +++-- iscsi-scst/kernel/nthread.c | 7 +++++++ scst/src/scst_main.c | 15 ++++++++++----- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index 8a5eefe26..65e3e6352 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -442,6 +442,7 @@ out: return; } +/* Must be called from rd thread only */ void iscsi_check_tm_data_wait_timeouts(struct iscsi_conn *conn, bool force) { struct iscsi_cmnd *cmnd; @@ -455,6 +456,8 @@ void iscsi_check_tm_data_wait_timeouts(struct iscsi_conn *conn, bool force) "j %ld (TIMEOUT %d, force %d)", j, ISCSI_TM_DATA_WAIT_SCHED_TIMEOUT, force); + iscsi_extracheck_is_rd_thread(conn); + again: spin_lock_bh(&iscsi_rd_lock); spin_lock(&conn->write_list_lock); diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index 68ec27801..15f617dc3 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -88,8 +88,15 @@ static void req_del_from_write_timeout_list(struct iscsi_cmnd *req) req, conn); spin_lock_bh(&conn->write_list_lock); + + /* Recheck, since it can be changed behind us */ + if (unlikely(!req->on_write_timeout_list)) + goto out_unlock; + list_del(&req->write_timeout_list_entry); req->on_write_timeout_list = 0; + +out_unlock: spin_unlock_bh(&conn->write_list_lock); out: @@ -151,8 +158,6 @@ void iscsi_restart_cmnd(struct iscsi_cmnd *cmnd) EXTRACHECKS_BUG_ON(cmnd->r2t_len_to_receive != 0); EXTRACHECKS_BUG_ON(cmnd->r2t_len_to_send != 0); - iscsi_extracheck_is_rd_thread(cmnd->conn); - req_del_from_write_timeout_list(cmnd); /* diff --git a/iscsi-scst/kernel/iscsi.h b/iscsi-scst/kernel/iscsi.h index 66fcc1c5c..00970cae8 100644 --- a/iscsi-scst/kernel/iscsi.h +++ b/iscsi-scst/kernel/iscsi.h @@ -189,6 +189,7 @@ struct iscsi_conn { /* List of data pdus being sent, protected by write_list_lock */ struct list_head write_timeout_list; + /* Protected by write_list_lock */ struct timer_list rsp_timer; /* All 2 protected by iscsi_wr_lock */ @@ -319,7 +320,7 @@ struct iscsi_cmnd { struct iscsi_conn *conn; /* - * Some flags protected by conn->write_list_lock, but all modified only + * Some flags used under conn->write_list_lock, but all modified only * from single read thread or when there are no references to cmd. */ unsigned int hashed:1; @@ -378,7 +379,7 @@ struct iscsi_cmnd { struct list_head write_timeout_list_entry; }; - /* Both modified only from single write thread */ + /* Both protected by conn->write_list_lock */ unsigned int on_write_timeout_list:1; unsigned long write_start; diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index 6bb9a384e..a00d32248 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -1155,8 +1155,15 @@ void req_add_to_write_timeout_list(struct iscsi_cmnd *req) spin_lock_bh(&conn->write_list_lock); + /* Recheck, since it can be changed behind us */ + if (unlikely(req->on_write_timeout_list)) { + spin_unlock_bh(&conn->write_list_lock); + goto out; + } + req->on_write_timeout_list = 1; req->write_start = jiffies; + list_add_tail(&req->write_timeout_list_entry, &conn->write_timeout_list); diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 62aa6e798..e5ad825c9 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -449,8 +449,10 @@ struct scst_tgt *scst_register(struct scst_tgt_template *vtt, mutex_unlock(&scst_mutex); scst_resume_activity(); - PRINT_INFO("Target %s (%p) for template %s registered successfully", - target_name, tgt, vtt->name); + PRINT_INFO("Target %s for template %s registered successfully", + tgt->tgt_name, vtt->name); + + TRACE_DBG("tgt %p", tgt); out: TRACE_EXIT(); @@ -484,7 +486,8 @@ out_free_tgt_err: out_err: PRINT_ERROR("Failed to register target %s for template %s (error %d)", - target_name, vtt->name, rc); + (tgt->tgt_name != NULL) ? tgt->tgt_name : target_name, + vtt->name, rc); goto out; } EXPORT_SYMBOL(scst_register); @@ -553,10 +556,12 @@ again: del_timer_sync(&tgt->retry_timer); + PRINT_INFO("Target %s for template %s unregistered successfully", + tgt->tgt_name, vtt->name); + scst_tgt_sysfs_put(tgt); /* must not be called under scst_mutex */ - PRINT_INFO("Target %p for template %s unregistered successfully", - tgt, vtt->name); + TRACE_DBG("Unregistering tgt %p finished", tgt); TRACE_EXIT(); return;