BIDI fixes
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Mon, 9 Nov 2009 13:53:57 +0000 (13:53 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Mon, 9 Nov 2009 13:53:57 +0000 (13:53 +0000)
git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@1329 d57e44dd-8a1f-0410-8b47-8ef2f437770f

qla2x00t/qla2x00-target/qla2x00t.c
scst/src/dev_handlers/scst_user.c
scst/src/scst_lib.c
usr/fileio/common.c

index 3bddddf..62c862a 100644 (file)
@@ -1851,7 +1851,7 @@ static int q2t_pre_xmit_response(struct q2t_cmd *cmd,
        full_req_cnt = prm->req_cnt;
 
        if (xmit_type & Q2T_XMIT_STATUS) {
-               if (cmd->data_direction != SCST_DATA_WRITE) {
+               if (cmd->data_direction & SCST_DATA_READ) {
                        int expected;
                        if (IS_FWI2_CAPABLE(ha))
                                expected = be32_to_cpu(cmd->
@@ -2949,12 +2949,11 @@ static int q2x_do_send_cmd_to_scst(struct q2t_cmd *cmd)
        scst_cmd_set_tag(cmd->scst_cmd, cmd->tag);
        scst_cmd_set_tgt_priv(cmd->scst_cmd, cmd);
 
+       dir = SCST_DATA_NONE;
        if (atio->execution_codes & ATIO_EXEC_READ)
-               dir = SCST_DATA_READ;
-       else if (atio->execution_codes & ATIO_EXEC_WRITE)
-               dir = SCST_DATA_WRITE;
-       else
-               dir = SCST_DATA_NONE;
+               dir |= SCST_DATA_READ;
+       if (atio->execution_codes & ATIO_EXEC_WRITE)
+               dir |= SCST_DATA_WRITE;
        scst_cmd_set_expected(cmd->scst_cmd, dir,
                le32_to_cpu(atio->data_length));
 
@@ -3022,12 +3021,11 @@ static int q24_do_send_cmd_to_scst(struct q2t_cmd *cmd)
        scst_cmd_set_tag(cmd->scst_cmd, cmd->tag);
        scst_cmd_set_tgt_priv(cmd->scst_cmd, cmd);
 
+       dir = SCST_DATA_NONE;
        if (atio->fcp_cmnd.rddata)
-               dir = SCST_DATA_READ;
-       else if (atio->fcp_cmnd.wrdata)
-               dir = SCST_DATA_WRITE;
-       else
-               dir = SCST_DATA_NONE;
+               dir |= SCST_DATA_READ;
+       if (atio->fcp_cmnd.wrdata)
+               dir |= SCST_DATA_WRITE;
        scst_cmd_set_expected(cmd->scst_cmd, dir,
                be32_to_cpu(atio->fcp_cmnd.data_length));
 
index ec05a31..62f0d77 100644 (file)
@@ -918,7 +918,7 @@ static int dev_user_exec(struct scst_cmd *cmd)
                "bufflen %d, data_len %d, ubuff %lx)", ucmd, ucmd->h,
                cmd->bufflen, cmd->data_len, ucmd->ubuff);
 
-       if (cmd->data_direction == SCST_DATA_WRITE)
+       if (cmd->data_direction & SCST_DATA_WRITE)
                dev_user_flush_dcache(ucmd);
 
        BUILD_BUG_ON(sizeof(ucmd->user_cmd.exec_cmd.cdb) != sizeof(cmd->cdb));
@@ -982,7 +982,7 @@ static void dev_user_on_free_cmd(struct scst_cmd *cmd)
                ucmd->buff_cached, ucmd->ubuff);
 
        ucmd->cmd = NULL;
-       if (cmd->data_direction == SCST_DATA_WRITE && ucmd->buf_ucmd != NULL)
+       if ((cmd->data_direction & SCST_DATA_WRITE) && ucmd->buf_ucmd != NULL)
                ucmd->buf_ucmd->buf_dirty = 1;
 
        if (ucmd->dev->on_free_cmd_type == SCST_USER_ON_FREE_CMD_IGNORE) {
@@ -1255,6 +1255,7 @@ static int dev_user_process_reply_parse(struct scst_user_cmd *ucmd,
 
        if (unlikely((preply->data_direction != SCST_DATA_WRITE) &&
                     (preply->data_direction != SCST_DATA_READ) &&
+                    (preply->data_direction != SCST_DATA_BIDI) &&
                     (preply->data_direction != SCST_DATA_NONE)))
                goto out_inval;
 
@@ -1346,7 +1347,7 @@ static int dev_user_process_reply_exec(struct scst_user_cmd *ucmd,
        } else if (ereply->reply_type == SCST_EXEC_REPLY_BACKGROUND) {
                if (unlikely(ucmd->background_exec))
                        goto out_inval;
-               if (unlikely((cmd->data_direction == SCST_DATA_READ) ||
+               if (unlikely((cmd->data_direction & SCST_DATA_READ) ||
                             (cmd->resp_data_len != 0)))
                        goto out_inval;
                /*
index ec2c627..419ef8f 100644 (file)
@@ -3075,7 +3075,7 @@ int scst_scsi_exec_async(struct scst_cmd *cmd,
                }
        }
 
-       if (cmd->data_direction  == SCST_DATA_BIDI) {
+       if (cmd->data_direction == SCST_DATA_BIDI) {
                struct request *next_rq;
 
                if (!test_bit(QUEUE_FLAG_BIDI, &q->queue_flags)) {
@@ -5526,7 +5526,7 @@ void scst_update_lat_stats(struct scst_cmd *cmd)
                sess->max_dev_time = dev_time;
 
        /* Save the extended latency information */
-       if (cmd->data_direction == SCST_DATA_READ) {
+       if (cmd->data_direction & SCST_DATA_READ) {
                latency_stat->scst_time_rd += scst_time;
                latency_stat->tgt_time_rd += tgt_time;
                latency_stat->dev_time_rd += dev_time;
@@ -5570,7 +5570,7 @@ void scst_update_lat_stats(struct scst_cmd *cmd)
                        dev_latency_stat->max_tgt_time_rd = tgt_time;
                if (dev_latency_stat->max_dev_time_rd < dev_time)
                        dev_latency_stat->max_dev_time_rd = dev_time;
-       } else if (cmd->data_direction == SCST_DATA_WRITE) {
+       } else if (cmd->data_direction & SCST_DATA_WRITE) {
                latency_stat->scst_time_wr += scst_time;
                latency_stat->tgt_time_wr += tgt_time;
                latency_stat->dev_time_wr += dev_time;
index 47a748b..4597e26 100644 (file)
@@ -840,7 +840,7 @@ again_poll:
 
                switch(cmd.subcode) {
                case SCST_USER_EXEC:
-                       if (cmd.exec_cmd.data_direction == SCST_DATA_WRITE) {
+                       if (cmd.exec_cmd.data_direction & SCST_DATA_WRITE) {
                                TRACE_BUFFER("Received cmd data",
                                        (void *)(unsigned long)cmd.exec_cmd.pbuf,
                                        cmd.exec_cmd.bufflen);