|
From: <vl...@us...> - 2006-11-09 11:07:36
|
Revision: 30
http://svn.sourceforge.net/scst/?rev=30&view=rev
Author: vlnb
Date: 2006-11-09 03:07:14 -0800 (Thu, 09 Nov 2006)
Log Message:
-----------
Pass-through mode resid handlning updated
Modified Paths:
--------------
trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c 2006-11-07 10:53:35 UTC (rev 29)
+++ trunk/scst/src/scst_targ.c 2006-11-09 11:07:14 UTC (rev 30)
@@ -1011,7 +1011,8 @@
}
static void scst_do_cmd_done(struct scst_cmd *cmd, int result,
- const uint8_t *rq_sense, int rq_sense_len, int *next_state)
+ const uint8_t *rq_sense, int rq_sense_len, int resid,
+ int *next_state)
{
unsigned char type;
@@ -1022,9 +1023,19 @@
cmd->msg_status = msg_byte(result);
cmd->host_status = host_byte(result);
cmd->driver_status = driver_byte(result);
- TRACE(TRACE_SCSI, "result=%x, cmd->status=%x, "
+ if (unlikely(resid != 0)) {
+#ifdef EXTRACHECKS
+ if ((resid < 0) || (resid >= cmd->resp_data_len)) {
+ PRINT_ERROR_PR("Wrong resid %d (cmd->resp_data_len=%d)",
+ resid, cmd->resp_data_len);
+ } else
+#endif
+ scst_set_resp_data_len(cmd, cmd->resp_data_len - resid);
+ }
+
+ TRACE(TRACE_SCSI, "result=%x, cmd->status=%x, resid=%d, "
"cmd->masked_status=%x, cmd->msg_status=%x, cmd->host_status=%x, "
- "cmd->driver_status=%x", result, cmd->status,
+ "cmd->driver_status=%x", result, cmd->status, resid,
cmd->masked_status, cmd->msg_status, cmd->host_status,
cmd->driver_status);
@@ -1091,22 +1102,13 @@
WARN_ON(in_irq());
- /*
- * We don't use scsi_cmd->resid, because:
- * 1. Many low level initiator drivers don't use (set) this field
- * 2. We determine the command's buffer size directly from CDB,
- * so scsi_cmd->resid is not relevant for us, and target drivers
- * should know the residual, if necessary, by comparing expected
- * and actual transfer sizes.
- */
-
cmd = scst_get_cmd(scsi_cmd, &req);
if (cmd == NULL)
goto out;
next_state = SCST_CMD_STATE_DEV_DONE;
scst_do_cmd_done(cmd, req->sr_result, req->sr_sense_buffer,
- sizeof(req->sr_sense_buffer), &next_state);
+ sizeof(req->sr_sense_buffer), scsi_cmd->resid, &next_state);
/* Clear out request structure */
req->sr_use_sg = 0;
@@ -1153,7 +1155,7 @@
goto out;
next_state = SCST_CMD_STATE_DEV_DONE;
- scst_do_cmd_done(cmd, result, sense, SCSI_SENSE_BUFFERSIZE,
+ scst_do_cmd_done(cmd, result, sense, SCSI_SENSE_BUFFERSIZE, resid,
&next_state);
cmd->state = next_state;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vl...@us...> - 2006-12-12 09:18:06
|
Revision: 45
http://svn.sourceforge.net/scst/?rev=45&view=rev
Author: vlnb
Date: 2006-12-12 01:18:04 -0800 (Tue, 12 Dec 2006)
Log Message:
-----------
Take 2 of fixing the race, which could lead to BUG() in scst_mgmt_thread()
Modified Paths:
--------------
trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c 2006-12-05 10:22:53 UTC (rev 44)
+++ trunk/scst/src/scst_targ.c 2006-12-12 09:18:04 UTC (rev 45)
@@ -3861,17 +3861,15 @@
list_for_each_entry(sess, &scst_sess_mgmt_list,
sess_mgmt_list_entry)
{
- int shutting_down;
TRACE_DBG("Removing sess %p from scst_sess_mgmt_list",
sess);
list_del(&sess->sess_mgmt_list_entry);
- shutting_down = sess->shutting_down;
spin_unlock_irq(&scst_mgmt_lock);
- if (shutting_down) {
+ if (sess->init_phase == SCST_SESS_IPH_INITING) {
+ scst_init_session(sess);
+ } else if (sess->shutting_down) {
BUG_ON(atomic_read(&sess->refcnt) != 0);
scst_free_session_callback(sess);
- } else if (sess->init_phase == SCST_SESS_IPH_INITING) {
- scst_init_session(sess);
} else {
PRINT_ERROR_PR("session %p is in "
"scst_sess_mgmt_list, but in unknown "
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vl...@us...> - 2008-04-22 15:04:22
|
Revision: 351
http://scst.svn.sourceforge.net/scst/?rev=351&view=rev
Author: vlnb
Date: 2008-04-22 08:04:09 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
Fixed wrong state assigmnent in scst_xmit_response()
Modified Paths:
--------------
trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c 2008-04-22 10:30:53 UTC (rev 350)
+++ trunk/scst/src/scst_targ.c 2008-04-22 15:04:09 UTC (rev 351)
@@ -2591,7 +2591,7 @@
goto out;
/* Restore the previous state */
- cmd->state = SCST_CMD_STATE_PRE_XMIT_RESP;
+ cmd->state = SCST_CMD_STATE_XMIT_RESP;
switch (rc) {
case SCST_TGT_RES_QUEUE_FULL:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vl...@us...> - 2007-11-15 15:54:59
|
Revision: 222
http://scst.svn.sourceforge.net/scst/?rev=222&view=rev
Author: vlnb
Date: 2007-11-15 07:54:53 -0800 (Thu, 15 Nov 2007)
Log Message:
-----------
Fixes race found by Anton Novodvorsky <ano...@gm...>
Modified Paths:
--------------
trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c 2007-11-13 17:28:28 UTC (rev 221)
+++ trunk/scst/src/scst_targ.c 2007-11-15 15:54:53 UTC (rev 222)
@@ -1835,9 +1835,10 @@
return;
}
-static int scst_send_to_midlev(struct scst_cmd *cmd)
+static int scst_send_to_midlev(struct scst_cmd **active_cmd)
{
int res, rc;
+ struct scst_cmd *cmd = *active_cmd;
struct scst_tgt_dev *tgt_dev = cmd->tgt_dev;
struct scst_device *dev = cmd->dev;
typeof(tgt_dev->expected_sn) expected_sn;
@@ -1921,6 +1922,7 @@
"thread context, rescheduling");
res = SCST_CMD_STATE_RES_NEED_THREAD;
scst_dec_on_dev_cmd(cmd);
+ *active_cmd = cmd;
if (count != 0)
goto out_unplug;
else
@@ -2885,7 +2887,7 @@
cmd->tag);
break;
}
- res = scst_send_to_midlev(cmd);
+ res = scst_send_to_midlev(&cmd);
/* !! At this point cmd, sess & tgt_dev can be already freed !! */
break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vl...@us...> - 2007-11-16 18:46:12
|
Revision: 224
http://scst.svn.sourceforge.net/scst/?rev=224&view=rev
Author: vlnb
Date: 2007-11-16 10:46:02 -0800 (Fri, 16 Nov 2007)
Log Message:
-----------
Fixes crash on reservation conflict + some cleanups
Modified Paths:
--------------
trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c 2007-11-15 16:12:08 UTC (rev 223)
+++ trunk/scst/src/scst_targ.c 2007-11-16 18:46:02 UTC (rev 224)
@@ -1230,7 +1230,7 @@
static int scst_report_luns_local(struct scst_cmd *cmd)
{
- int res = SCST_EXEC_COMPLETED, rc;
+ int rc;
int dev_cnt = 0;
int buffer_size;
int i;
@@ -1323,8 +1323,8 @@
/* Report the result */
scst_cmd_done_local(cmd, SCST_CMD_STATE_DEFAULT);
- TRACE_EXIT_RES(res);
- return res;
+ TRACE_EXIT();
+ return SCST_EXEC_COMPLETED;
out_put_err:
scst_put_buf(cmd, buffer);
@@ -1360,22 +1360,9 @@
return res;
}
-static inline void scst_report_reserved(struct scst_cmd *cmd)
-{
- TRACE_ENTRY();
-
- scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT);
- cmd->completed = 1;
- /* Report the result */
- scst_cmd_done_local(cmd, SCST_CMD_STATE_DEFAULT);
-
- TRACE_EXIT();
- return;
-}
-
static int scst_reserve_local(struct scst_cmd *cmd)
{
- int res = SCST_EXEC_NOT_COMPLETED, rc;
+ int res, rc;
struct scst_device *dev;
struct scst_tgt_dev *tgt_dev_tmp;
@@ -1391,9 +1378,7 @@
"(lun=%Ld)", (uint64_t)cmd->lun);
scst_set_cmd_error(cmd,
SCST_LOAD_SENSE(scst_sense_invalid_field_in_cdb));
- cmd->completed = 1;
- res = SCST_EXEC_COMPLETED;
- goto out;
+ goto out_compl;
}
dev = cmd->dev;
@@ -1407,10 +1392,9 @@
spin_lock_bh(&dev->dev_lock);
if (test_bit(SCST_TGT_DEV_RESERVED, &cmd->tgt_dev->tgt_dev_flags)) {
- scst_report_reserved(cmd);
- /* !! At this point cmd, sess & tgt_dev can be already freed !! */
- res = SCST_EXEC_COMPLETED;
- goto out_unlock;
+ spin_unlock_bh(&dev->dev_lock);
+ scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT);
+ goto out_compl;
}
list_for_each_entry(tgt_dev_tmp, &dev->dev_tgt_dev_list,
@@ -1422,23 +1406,27 @@
}
dev->dev_reserved = 1;
-out_unlock:
+ res = SCST_EXEC_NOT_COMPLETED;
+
spin_unlock_bh(&dev->dev_lock);
out:
TRACE_EXIT_RES(res);
return res;
+out_compl:
+ cmd->completed = 1;
+
out_done:
- res = SCST_EXEC_COMPLETED;
/* Report the result */
scst_cmd_done_local(cmd, SCST_CMD_STATE_DEFAULT);
+ res = SCST_EXEC_COMPLETED;
goto out;
}
static int scst_release_local(struct scst_cmd *cmd)
{
- int res = SCST_EXEC_NOT_COMPLETED, rc;
+ int res, rc;
struct scst_tgt_dev *tgt_dev_tmp;
struct scst_device *dev;
@@ -1483,12 +1471,17 @@
spin_unlock_bh(&dev->dev_lock);
if (res == SCST_EXEC_COMPLETED)
- goto out_done;
+ goto out_compl;
+ res = SCST_EXEC_NOT_COMPLETED;
+
out:
TRACE_EXIT_RES(res);
return res;
+out_compl:
+ cmd->completed = 1;
+
out_done:
res = SCST_EXEC_COMPLETED;
/* Report the result */
@@ -1517,7 +1510,7 @@
(cmd->cdb[0] != ALLOW_MEDIUM_REMOVAL || (cmd->cdb[4] & 3)) &&
(cmd->cdb[0] != LOG_SENSE) && (cmd->cdb[0] != REQUEST_SENSE))
{
- scst_report_reserved(cmd);
+ scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT);
goto out_complete;
}
}
@@ -1788,7 +1781,7 @@
out_done:
rc = SCST_EXEC_COMPLETED;
- /* Report the result. The cmd is not completed */
+ /* Report the result */
scst_cmd_done_local(cmd, SCST_CMD_STATE_DEFAULT);
goto out;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vl...@us...> - 2008-03-14 10:42:51
|
Revision: 303
http://scst.svn.sourceforge.net/scst/?rev=303&view=rev
Author: vlnb
Date: 2008-03-14 03:42:03 -0700 (Fri, 14 Mar 2008)
Log Message:
-----------
Fixes possible *dev_cmd_count leak
Modified Paths:
--------------
trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c 2008-03-13 10:58:44 UTC (rev 302)
+++ trunk/scst/src/scst_targ.c 2008-03-14 10:42:03 UTC (rev 303)
@@ -2312,9 +2312,6 @@
TRACE_ENTRY();
- atomic_dec(&cmd->tgt_dev->tgt_dev_cmd_count);
- atomic_dec(&cmd->dev->dev_cmd_count);
-
rc = scst_done_cmd_check(cmd, &res);
if (rc)
goto out;
@@ -2505,7 +2502,10 @@
}
#endif
- if (cmd->tgt_dev != NULL) {
+ if (likely(cmd->tgt_dev != NULL)) {
+ atomic_dec(&cmd->tgt_dev->tgt_dev_cmd_count);
+ atomic_dec(&cmd->dev->dev_cmd_count);
+
if (unlikely(cmd->queue_type == SCST_CMD_QUEUE_HEAD_OF_QUEUE))
scst_on_hq_cmd_response(cmd);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|