- Return no residual if expected values not set instead of BUG_ON(),

because this is valid situation for some preliminary comleted commands.

 - Cleanup



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3549 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2011-06-06 21:32:16 +00:00
parent 2f1745eec1
commit ed07de2ffb
2 changed files with 28 additions and 7 deletions

View File

@@ -2186,7 +2186,15 @@ void scst_cmd_set_write_not_received_data_len(struct scst_cmd *cmd,
{
TRACE_ENTRY();
sBUG_ON(!cmd->expected_values_set);
if (!cmd->expected_values_set) {
/*
* No expected values set, so no residuals processing.
* It can happen if a command preliminary completed before
* target driver had a chance to set expected values.
*/
TRACE_MGMT_DBG("No expected values set, ignoring (cmd %p)", cmd);
goto out;
}
cmd->resid_possible = 1;
@@ -2226,13 +2234,25 @@ EXPORT_SYMBOL(scst_cmd_set_write_not_received_data_len);
*/
bool __scst_get_resid(struct scst_cmd *cmd, int *resid, int *bidi_out_resid)
{
bool res;
TRACE_ENTRY();
*resid = 0;
if (bidi_out_resid != NULL)
*bidi_out_resid = 0;
sBUG_ON(!cmd->expected_values_set);
if (!cmd->expected_values_set) {
/*
* No expected values set, so no residuals processing.
* It can happen if a command preliminary completed before
* target driver had a chance to set expected values.
*/
TRACE_MGMT_DBG("No expected values set, returning no residual "
"(cmd %p)", cmd);
res = false;
goto out;
}
if (cmd->expected_data_direction & SCST_DATA_READ) {
*resid = cmd->expected_transfer_len - cmd->resp_data_len;
@@ -2250,13 +2270,16 @@ bool __scst_get_resid(struct scst_cmd *cmd, int *resid, int *bidi_out_resid)
*resid = cmd->write_len - cmd->bufflen;
}
res = true;
TRACE_DBG("cmd %p, resid %d, bidi_out_resid %d (resp_data_len %d, "
"expected_data_direction %d, write_len %d, bufflen %d)", cmd,
*resid, bidi_out_resid ? *bidi_out_resid : 0, cmd->resp_data_len,
cmd->expected_data_direction, cmd->write_len, cmd->bufflen);
TRACE_EXIT_RES(1);
return true;
out:
TRACE_EXIT_RES(res);
return res;
}
EXPORT_SYMBOL(__scst_get_resid);

View File

@@ -213,11 +213,9 @@ struct scst_cmd *scst_rx_cmd(struct scst_session *sess,
cmd->tgtt = sess->tgt->tgtt;
cmd->lun = scst_unpack_lun(lun, lun_len);
if (unlikely(cmd->lun == NO_SUCH_LUN)) {
PRINT_ERROR("Wrong LUN %d, finishing cmd", -1);
if (unlikely(cmd->lun == NO_SUCH_LUN))
scst_set_cmd_error(cmd,
SCST_LOAD_SENSE(scst_sense_lun_not_supported));
}
TRACE_DBG("cmd %p, sess %p", cmd, sess);
scst_sess_get(sess);