scsi: remove bidirectional command support
authorChristoph Hellwig <hch@lst.de>
Tue, 29 Jan 2019 08:33:07 +0000 (09:33 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 6 Feb 2019 02:29:21 +0000 (21:29 -0500)
No real need for bidi support once the OSD code is gone.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
12 files changed:
drivers/scsi/cxgbi/libcxgbi.c
drivers/scsi/iscsi_tcp.c
drivers/scsi/libiscsi.c
drivers/scsi/libiscsi_tcp.c
drivers/scsi/scsi_debug.c
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c
drivers/scsi/virtio_scsi.c
drivers/target/loopback/tcm_loop.c
drivers/usb/storage/uas.c
include/scsi/scsi_cmnd.h
include/scsi/scsi_eh.h

index 75f876409fb9d8344adf36f48a4a288da5b7c8ed..4466ae5c9a74efefc6a1c549b39dc28a458fbcb6 100644 (file)
@@ -1211,7 +1211,7 @@ scmd_get_params(struct scsi_cmnd *sc, struct scatterlist **sgl,
                unsigned int *sgcnt, unsigned int *dlen,
                unsigned int prot)
 {
-       struct scsi_data_buffer *sdb = prot ? scsi_prot(sc) : scsi_out(sc);
+       struct scsi_data_buffer *sdb = prot ? scsi_prot(sc) : &sc->sdb;
 
        *sgl = sdb->table.sgl;
        *sgcnt = sdb->table.nents;
@@ -1427,8 +1427,7 @@ static void task_release_itt(struct iscsi_task *task, itt_t hdr_itt)
        log_debug(1 << CXGBI_DBG_DDP,
                  "cdev 0x%p, task 0x%p, release tag 0x%x.\n",
                  cdev, task, tag);
-       if (sc &&
-           (scsi_bidi_cmnd(sc) || sc->sc_data_direction == DMA_FROM_DEVICE) &&
+       if (sc && sc->sc_data_direction == DMA_FROM_DEVICE &&
            cxgbi_ppm_is_ddp_tag(ppm, tag)) {
                struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
                struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo;
@@ -1460,9 +1459,7 @@ static int task_reserve_itt(struct iscsi_task *task, itt_t *hdr_itt)
        u32 tag = 0;
        int err = -EINVAL;
 
-       if (sc &&
-           (scsi_bidi_cmnd(sc) || sc->sc_data_direction == DMA_FROM_DEVICE)
-       ) {
+       if (sc && sc->sc_data_direction == DMA_FROM_DEVICE) {
                struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
                struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo;
 
@@ -1896,7 +1893,7 @@ int cxgbi_conn_alloc_pdu(struct iscsi_task *task, u8 opcode)
        if (SKB_MAX_HEAD(cdev->skb_tx_rsvd) > (512 * MAX_SKB_FRAGS) &&
            (opcode == ISCSI_OP_SCSI_DATA_OUT ||
             (opcode == ISCSI_OP_SCSI_CMD &&
-             (scsi_bidi_cmnd(sc) || sc->sc_data_direction == DMA_TO_DEVICE))))
+             sc->sc_data_direction == DMA_TO_DEVICE)))
                /* data could goes into skb head */
                headroom += min_t(unsigned int,
                                SKB_MAX_HEAD(cdev->skb_tx_rsvd),
@@ -1971,7 +1968,7 @@ int cxgbi_conn_init_pdu(struct iscsi_task *task, unsigned int offset,
                return 0;
 
        if (task->sc) {
-               struct scsi_data_buffer *sdb = scsi_out(task->sc);
+               struct scsi_data_buffer *sdb = &task->sc->sdb;
                struct scatterlist *sg = NULL;
                int err;
 
index cae6368ebb980259c400090eae958c6abd3501ac..ed3debce2819afa24bf066db7c44b76b15f50e48 100644 (file)
@@ -518,7 +518,7 @@ static int iscsi_sw_tcp_pdu_init(struct iscsi_task *task,
        if (!task->sc)
                iscsi_sw_tcp_send_linear_data_prep(conn, task->data, count);
        else {
-               struct scsi_data_buffer *sdb = scsi_out(task->sc);
+               struct scsi_data_buffer *sdb = &task->sc->sdb;
 
                err = iscsi_sw_tcp_send_data_prep(conn, sdb->table.sgl,
                                                  sdb->table.nents, offset,
@@ -952,12 +952,6 @@ static umode_t iscsi_sw_tcp_attr_is_visible(int param_type, int param)
        return 0;
 }
 
-static int iscsi_sw_tcp_slave_alloc(struct scsi_device *sdev)
-{
-       blk_queue_flag_set(QUEUE_FLAG_BIDI, sdev->request_queue);
-       return 0;
-}
-
 static int iscsi_sw_tcp_slave_configure(struct scsi_device *sdev)
 {
        struct iscsi_sw_tcp_host *tcp_sw_host = iscsi_host_priv(sdev->host);
@@ -985,7 +979,6 @@ static struct scsi_host_template iscsi_sw_tcp_sht = {
        .eh_device_reset_handler= iscsi_eh_device_reset,
        .eh_target_reset_handler = iscsi_eh_recover_target,
        .dma_boundary           = PAGE_SIZE - 1,
-       .slave_alloc            = iscsi_sw_tcp_slave_alloc,
        .slave_configure        = iscsi_sw_tcp_slave_configure,
        .target_alloc           = iscsi_target_alloc,
        .proc_name              = "iscsi_tcp",
index b8d325ce8754b4c2b66f275ab5cdba06e73b2e6e..bca3a8636c2708c3a9c4c0a92673d73d71566274 100644 (file)
@@ -228,32 +228,6 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_task *task)
        return 0;
 }
 
-static int iscsi_prep_bidi_ahs(struct iscsi_task *task)
-{
-       struct scsi_cmnd *sc = task->sc;
-       struct iscsi_rlength_ahdr *rlen_ahdr;
-       int rc;
-
-       rlen_ahdr = iscsi_next_hdr(task);
-       rc = iscsi_add_hdr(task, sizeof(*rlen_ahdr));
-       if (rc)
-               return rc;
-
-       rlen_ahdr->ahslength =
-               cpu_to_be16(sizeof(rlen_ahdr->read_length) +
-                                                 sizeof(rlen_ahdr->reserved));
-       rlen_ahdr->ahstype = ISCSI_AHSTYPE_RLENGTH;
-       rlen_ahdr->reserved = 0;
-       rlen_ahdr->read_length = cpu_to_be32(scsi_in(sc)->length);
-
-       ISCSI_DBG_SESSION(task->conn->session,
-                         "bidi-in rlen_ahdr->read_length(%d) "
-                         "rlen_ahdr->ahslength(%d)\n",
-                         be32_to_cpu(rlen_ahdr->read_length),
-                         be16_to_cpu(rlen_ahdr->ahslength));
-       return 0;
-}
-
 /**
  * iscsi_check_tmf_restrictions - check if a task is affected by TMF
  * @task: iscsi task
@@ -392,13 +366,6 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
        memcpy(hdr->cdb, sc->cmnd, cmd_len);
 
        task->imm_count = 0;
-       if (scsi_bidi_cmnd(sc)) {
-               hdr->flags |= ISCSI_FLAG_CMD_READ;
-               rc = iscsi_prep_bidi_ahs(task);
-               if (rc)
-                       return rc;
-       }
-
        if (scsi_get_prot_op(sc) != SCSI_PROT_NORMAL)
                task->protected = true;
 
@@ -473,12 +440,10 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
 
        conn->scsicmd_pdus_cnt++;
        ISCSI_DBG_SESSION(session, "iscsi prep [%s cid %d sc %p cdb 0x%x "
-                         "itt 0x%x len %d bidi_len %d cmdsn %d win %d]\n",
-                         scsi_bidi_cmnd(sc) ? "bidirectional" :
+                         "itt 0x%x len %d cmdsn %d win %d]\n",
                          sc->sc_data_direction == DMA_TO_DEVICE ?
                          "write" : "read", conn->id, sc, sc->cmnd[0],
                          task->itt, transfer_length,
-                         scsi_bidi_cmnd(sc) ? scsi_in(sc)->length : 0,
                          session->cmdsn,
                          session->max_cmdsn - session->exp_cmdsn + 1);
        return 0;
@@ -647,12 +612,7 @@ static void fail_scsi_task(struct iscsi_task *task, int err)
                state = ISCSI_TASK_ABRT_TMF;
 
        sc->result = err << 16;
-       if (!scsi_bidi_cmnd(sc))
-               scsi_set_resid(sc, scsi_bufflen(sc));
-       else {
-               scsi_out(sc)->resid = scsi_out(sc)->length;
-               scsi_in(sc)->resid = scsi_in(sc)->length;
-       }
+       scsi_set_resid(sc, scsi_bufflen(sc));
 
        /* regular RX path uses back_lock */
        spin_lock_bh(&conn->session->back_lock);
@@ -907,14 +867,7 @@ invalid_datalen:
 
        if (rhdr->flags & (ISCSI_FLAG_CMD_BIDI_UNDERFLOW |
                           ISCSI_FLAG_CMD_BIDI_OVERFLOW)) {
-               int res_count = be32_to_cpu(rhdr->bi_residual_count);
-
-               if (scsi_bidi_cmnd(sc) && res_count > 0 &&
-                               (rhdr->flags & ISCSI_FLAG_CMD_BIDI_OVERFLOW ||
-                                res_count <= scsi_in(sc)->length))
-                       scsi_in(sc)->resid = res_count;
-               else
-                       sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
+               sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
        }
 
        if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
@@ -961,8 +914,8 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 
                if (res_count > 0 &&
                    (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
-                    res_count <= scsi_in(sc)->length))
-                       scsi_in(sc)->resid = res_count;
+                    res_count <= sc->sdb.length))
+                       sc->sdb.resid = res_count;
                else
                        sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
        }
@@ -1804,12 +1757,7 @@ fault:
        spin_unlock_bh(&session->frwd_lock);
        ISCSI_DBG_SESSION(session, "iscsi: cmd 0x%x is not queued (%d)\n",
                          sc->cmnd[0], reason);
-       if (!scsi_bidi_cmnd(sc))
-               scsi_set_resid(sc, scsi_bufflen(sc));
-       else {
-               scsi_out(sc)->resid = scsi_out(sc)->length;
-               scsi_in(sc)->resid = scsi_in(sc)->length;
-       }
+       scsi_set_resid(sc, scsi_bufflen(sc));
        sc->scsi_done(sc);
        return 0;
 }
index 8a6b1b3f8277d1e6ddd5c006087509400b964305..9923e9e3b8843b44e6a4212a7411628946892f69 100644 (file)
@@ -495,7 +495,7 @@ static int iscsi_tcp_data_in(struct iscsi_conn *conn, struct iscsi_task *task)
        struct iscsi_tcp_task *tcp_task = task->dd_data;
        struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr;
        int datasn = be32_to_cpu(rhdr->datasn);
-       unsigned total_in_length = scsi_in(task->sc)->length;
+       unsigned total_in_length = task->sc->sdb.length;
 
        /*
         * lib iscsi will update this in the completion handling if there
@@ -580,11 +580,11 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
                              data_length, session->max_burst);
 
        data_offset = be32_to_cpu(rhdr->data_offset);
-       if (data_offset + data_length > scsi_out(task->sc)->length) {
+       if (data_offset + data_length > task->sc->sdb.length) {
                iscsi_conn_printk(KERN_ERR, conn,
                                  "invalid R2T with data len %u at offset %u "
                                  "and total length %d\n", data_length,
-                                 data_offset, scsi_out(task->sc)->length);
+                                 data_offset, task->sc->sdb.length);
                return ISCSI_ERR_DATALEN;
        }
 
@@ -696,7 +696,7 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
                if (tcp_conn->in.datalen) {
                        struct iscsi_tcp_task *tcp_task = task->dd_data;
                        struct ahash_request *rx_hash = NULL;
-                       struct scsi_data_buffer *sdb = scsi_in(task->sc);
+                       struct scsi_data_buffer *sdb = &task->sc->sdb;
 
                        /*
                         * Setup copy of Data-In into the struct scsi_cmnd
index 661512bec3ac683fc2c718e3c1b8675221fb1cdf..8044bb08455d33c5f17ad73a770f804b3f322991 100644 (file)
@@ -430,7 +430,6 @@ static int resp_rsup_opcodes(struct scsi_cmnd *, struct sdebug_dev_info *);
 static int resp_rsup_tmfs(struct scsi_cmnd *, struct sdebug_dev_info *);
 static int resp_write_same_10(struct scsi_cmnd *, struct sdebug_dev_info *);
 static int resp_write_same_16(struct scsi_cmnd *, struct sdebug_dev_info *);
-static int resp_xdwriteread_10(struct scsi_cmnd *, struct sdebug_dev_info *);
 static int resp_comp_write(struct scsi_cmnd *, struct sdebug_dev_info *);
 static int resp_write_buffer(struct scsi_cmnd *, struct sdebug_dev_info *);
 static int resp_sync_cache(struct scsi_cmnd *, struct sdebug_dev_info *);
@@ -600,9 +599,6 @@ static const struct opcode_info_t opcode_info_arr[SDEB_I_LAST_ELEMENT + 1] = {
        {0, 0x42, 0, F_D_OUT | FF_MEDIA_IO, resp_unmap, NULL, /* UNMAP */
            {10,  0x1, 0, 0, 0, 0, 0x3f, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} },
 /* 25 */
-       {0, 0x53, 0, F_D_IN | F_D_OUT | FF_MEDIA_IO, resp_xdwriteread_10,
-           NULL, {10,  0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xc7,
-                  0, 0, 0, 0, 0, 0} },         /* XDWRITEREAD(10) */
        {0, 0x3b, 0, F_D_OUT_MAYBE, resp_write_buffer, NULL,
            {10,  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0, 0,
             0, 0, 0, 0} },                     /* WRITE_BUFFER */
@@ -1010,11 +1006,11 @@ static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr,
                                int arr_len)
 {
        int act_len;
-       struct scsi_data_buffer *sdb = scsi_in(scp);
+       struct scsi_data_buffer *sdb = &scp->sdb;
 
        if (!sdb->length)
                return 0;
-       if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_FROM_DEVICE))
+       if (scp->sc_data_direction != DMA_FROM_DEVICE)
                return DID_ERROR << 16;
 
        act_len = sg_copy_from_buffer(sdb->table.sgl, sdb->table.nents,
@@ -1033,12 +1029,12 @@ static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr,
                                  int arr_len, unsigned int off_dst)
 {
        int act_len, n;
-       struct scsi_data_buffer *sdb = scsi_in(scp);
+       struct scsi_data_buffer *sdb = &scp->sdb;
        off_t skip = off_dst;
 
        if (sdb->length <= off_dst)
                return 0;
-       if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_FROM_DEVICE))
+       if (scp->sc_data_direction != DMA_FROM_DEVICE)
                return DID_ERROR << 16;
 
        act_len = sg_pcopy_from_buffer(sdb->table.sgl, sdb->table.nents,
@@ -1058,7 +1054,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr,
 {
        if (!scsi_bufflen(scp))
                return 0;
-       if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_TO_DEVICE))
+       if (scp->sc_data_direction != DMA_TO_DEVICE)
                return -1;
 
        return scsi_sg_copy_to_buffer(scp, arr, arr_len);
@@ -2477,21 +2473,19 @@ static int do_device_access(struct scsi_cmnd *scmd, u32 sg_skip, u64 lba,
 {
        int ret;
        u64 block, rest = 0;
-       struct scsi_data_buffer *sdb;
+       struct scsi_data_buffer *sdb = &scmd->sdb;
        enum dma_data_direction dir;
 
        if (do_write) {
-               sdb = scsi_out(scmd);
                dir = DMA_TO_DEVICE;
                write_since_sync = true;
        } else {
-               sdb = scsi_in(scmd);
                dir = DMA_FROM_DEVICE;
        }
 
        if (!sdb->length)
                return 0;
-       if (!(scsi_bidi_cmnd(scmd) || scmd->sc_data_direction == dir))
+       if (scmd->sc_data_direction != dir)
                return -1;
 
        block = do_div(lba, sdebug_store_sectors);
@@ -2774,7 +2768,7 @@ static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
        if (unlikely(ret == -1))
                return DID_ERROR << 16;
 
-       scsi_in(scp)->resid = scsi_bufflen(scp) - ret;
+       scp->sdb.resid = scsi_bufflen(scp) - ret;
 
        if (unlikely(sqcp)) {
                if (sqcp->inj_recovered) {
@@ -3718,68 +3712,6 @@ static int resp_report_luns(struct scsi_cmnd *scp,
        return res;
 }
 
-static int resp_xdwriteread(struct scsi_cmnd *scp, unsigned long long lba,
-                           unsigned int num, struct sdebug_dev_info *devip)
-{
-       int j;
-       unsigned char *kaddr, *buf;
-       unsigned int offset;
-       struct scsi_data_buffer *sdb = scsi_in(scp);
-       struct sg_mapping_iter miter;
-
-       /* better not to use temporary buffer. */
-       buf = kzalloc(scsi_bufflen(scp), GFP_ATOMIC);
-       if (!buf) {
-               mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC,
-                               INSUFF_RES_ASCQ);
-               return check_condition_result;
-       }
-
-       scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp));
-
-       offset = 0;
-       sg_miter_start(&miter, sdb->table.sgl, sdb->table.nents,
-                       SG_MITER_ATOMIC | SG_MITER_TO_SG);
-
-       while (sg_miter_next(&miter)) {
-               kaddr = miter.addr;
-               for (j = 0; j < miter.length; j++)
-                       *(kaddr + j) ^= *(buf + offset + j);
-
-               offset += miter.length;
-       }
-       sg_miter_stop(&miter);
-       kfree(buf);
-
-       return 0;
-}
-
-static int resp_xdwriteread_10(struct scsi_cmnd *scp,
-                              struct sdebug_dev_info *devip)
-{
-       u8 *cmd = scp->cmnd;
-       u64 lba;
-       u32 num;
-       int errsts;
-
-       if (!scsi_bidi_cmnd(scp)) {
-               mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC,
-                               INSUFF_RES_ASCQ);
-               return check_condition_result;
-       }
-       errsts = resp_read_dt0(scp, devip);
-       if (errsts)
-               return errsts;
-       if (!(cmd[1] & 0x4)) {          /* DISABLE_WRITE is not set */
-               errsts = resp_write_dt0(scp, devip);
-               if (errsts)
-                       return errsts;
-       }
-       lba = get_unaligned_be32(cmd + 2);
-       num = get_unaligned_be16(cmd + 7);
-       return resp_xdwriteread(scp, lba, num, devip);
-}
-
 static struct sdebug_queue *get_queue(struct scsi_cmnd *cmnd)
 {
        u32 tag = blk_mq_unique_tag(cmnd->request);
@@ -3953,7 +3885,6 @@ static int scsi_debug_slave_alloc(struct scsi_device *sdp)
        if (sdebug_verbose)
                pr_info("slave_alloc <%u %u %u %llu>\n",
                       sdp->host->host_no, sdp->channel, sdp->id, sdp->lun);
-       blk_queue_flag_set(QUEUE_FLAG_BIDI, sdp->request_queue);
        return 0;
 }
 
index 16eef068e9e93bb35a22abff944b1d37ff3a3b66..1b8378f361399cff8e196943430d9f10702caefd 100644 (file)
@@ -965,7 +965,6 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
        ses->cmnd = scmd->cmnd;
        ses->data_direction = scmd->sc_data_direction;
        ses->sdb = scmd->sdb;
-       ses->next_rq = scmd->request->next_rq;
        ses->result = scmd->result;
        ses->underflow = scmd->underflow;
        ses->prot_op = scmd->prot_op;
@@ -976,7 +975,6 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
        scmd->cmnd = ses->eh_cmnd;
        memset(scmd->cmnd, 0, BLK_MAX_CDB);
        memset(&scmd->sdb, 0, sizeof(scmd->sdb));
-       scmd->request->next_rq = NULL;
        scmd->result = 0;
 
        if (sense_bytes) {
@@ -1029,7 +1027,6 @@ void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, struct scsi_eh_save *ses)
        scmd->cmnd = ses->cmnd;
        scmd->sc_data_direction = ses->data_direction;
        scmd->sdb = ses->sdb;
-       scmd->request->next_rq = ses->next_rq;
        scmd->result = ses->result;
        scmd->underflow = ses->underflow;
        scmd->prot_op = ses->prot_op;
index 00cd365fb7d2c98ec97c1ea39d7a76d6be50cfdc..2667bb95a4410c3a2846280abeffd3e385719d67 100644 (file)
@@ -556,15 +556,8 @@ static void scsi_uninit_cmd(struct scsi_cmnd *cmd)
 
 static void scsi_mq_free_sgtables(struct scsi_cmnd *cmd)
 {
-       struct scsi_data_buffer *sdb;
-
        if (cmd->sdb.table.nents)
                sg_free_table_chained(&cmd->sdb.table, true);
-       if (cmd->request->next_rq) {
-               sdb = cmd->request->next_rq->special;
-               if (sdb)
-                       sg_free_table_chained(&sdb->table, true);
-       }
        if (scsi_prot_sg_count(cmd))
                sg_free_table_chained(&cmd->prot_sdb->table, true);
 }
@@ -578,7 +571,7 @@ static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
 
 /* Returns false when no more bytes to process, true if there are more */
 static bool scsi_end_request(struct request *req, blk_status_t error,
-               unsigned int bytes, unsigned int bidi_bytes)
+               unsigned int bytes)
 {
        struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
        struct scsi_device *sdev = cmd->device;
@@ -587,11 +580,6 @@ static bool scsi_end_request(struct request *req, blk_status_t error,
        if (blk_update_request(req, error, bytes))
                return true;
 
-       /* Bidi request must be completed as a whole */
-       if (unlikely(bidi_bytes) &&
-           blk_update_request(req->next_rq, error, bidi_bytes))
-               return true;
-
        if (blk_queue_add_random(q))
                add_disk_randomness(req->rq_disk);
 
@@ -816,7 +804,7 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
                                scsi_print_command(cmd);
                        }
                }
-               if (!scsi_end_request(req, blk_stat, blk_rq_err_bytes(req), 0))
+               if (!scsi_end_request(req, blk_stat, blk_rq_err_bytes(req)))
                        return;
                /*FALLTHRU*/
        case ACTION_REPREP:
@@ -951,29 +939,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
                 */
                scsi_req(req)->result = cmd->result;
                scsi_req(req)->resid_len = scsi_get_resid(cmd);
-
-               if (unlikely(scsi_bidi_cmnd(cmd))) {
-                       /*
-                        * Bidi commands Must be complete as a whole,
-                        * both sides at once.
-                        */
-                       scsi_req(req->next_rq)->resid_len = scsi_in(cmd)->resid;
-                       if (scsi_end_request(req, BLK_STS_OK, blk_rq_bytes(req),
-                                       blk_rq_bytes(req->next_rq)))
-                               WARN_ONCE(true,
-                                         "Bidi command with remaining bytes");
-                       return;
-               }
-       }
-
-       /* no bidi support yet, other than in pass-through */
-       if (unlikely(blk_bidi_rq(req))) {
-               WARN_ONCE(true, "Only support bidi command in passthrough");
-               scmd_printk(KERN_ERR, cmd, "Killing bidi command\n");
-               if (scsi_end_request(req, BLK_STS_IOERR, blk_rq_bytes(req),
-                                    blk_rq_bytes(req->next_rq)))
-                       WARN_ONCE(true, "Bidi command with remaining bytes");
-               return;
        }
 
        /*
@@ -990,13 +955,13 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
         * to retry code. Fast path should return in this block.
         */
        if (likely(blk_rq_bytes(req) > 0 || blk_stat == BLK_STS_OK)) {
-               if (likely(!scsi_end_request(req, blk_stat, good_bytes, 0)))
+               if (likely(!scsi_end_request(req, blk_stat, good_bytes)))
                        return; /* no bytes remaining */
        }
 
        /* Kill remainder if no retries. */
        if (unlikely(blk_stat && scsi_noretry_cmd(cmd))) {
-               if (scsi_end_request(req, blk_stat, blk_rq_bytes(req), 0))
+               if (scsi_end_request(req, blk_stat, blk_rq_bytes(req)))
                        WARN_ONCE(true,
                            "Bytes remaining after failed, no-retry command");
                return;
@@ -1058,12 +1023,6 @@ blk_status_t scsi_init_io(struct scsi_cmnd *cmd)
        if (ret)
                return ret;
 
-       if (blk_bidi_rq(rq)) {
-               ret = scsi_init_sgtable(rq->next_rq, rq->next_rq->special);
-               if (ret)
-                       goto out_free_sgtables;
-       }
-
        if (blk_integrity_rq(rq)) {
                struct scsi_data_buffer *prot_sdb = cmd->prot_sdb;
                int ivecs, count;
@@ -1624,17 +1583,6 @@ static blk_status_t scsi_mq_prep_fn(struct request *req)
                        (struct scatterlist *)(cmd->prot_sdb + 1);
        }
 
-       if (blk_bidi_rq(req)) {
-               struct request *next_rq = req->next_rq;
-               struct scsi_data_buffer *bidi_sdb = blk_mq_rq_to_pdu(next_rq);
-
-               memset(bidi_sdb, 0, sizeof(struct scsi_data_buffer));
-               bidi_sdb->table.sgl =
-                       (struct scatterlist *)(bidi_sdb + 1);
-
-               next_rq->special = bidi_sdb;
-       }
-
        blk_mq_start_request(req);
 
        return scsi_setup_cmnd(sdev, req);
index 772b976e4ee43dde5e1c05a9bd3760a505b7b26e..1a6f150cd2d873682d21e58660958d2c7bb51893 100644 (file)
@@ -100,16 +100,8 @@ static inline struct Scsi_Host *virtio_scsi_host(struct virtio_device *vdev)
 
 static void virtscsi_compute_resid(struct scsi_cmnd *sc, u32 resid)
 {
-       if (!resid)
-               return;
-
-       if (!scsi_bidi_cmnd(sc)) {
+       if (resid)
                scsi_set_resid(sc, resid);
-               return;
-       }
-
-       scsi_in(sc)->resid = min(resid, scsi_in(sc)->length);
-       scsi_out(sc)->resid = resid - scsi_in(sc)->resid;
 }
 
 /**
@@ -403,9 +395,9 @@ static int virtscsi_add_cmd(struct virtqueue *vq,
 
        if (sc && sc->sc_data_direction != DMA_NONE) {
                if (sc->sc_data_direction != DMA_FROM_DEVICE)
-                       out = &scsi_out(sc)->table;
+                       out = &sc->sdb.table;
                if (sc->sc_data_direction != DMA_TO_DEVICE)
-                       in = &scsi_in(sc)->table;
+                       in = &sc->sdb.table;
        }
 
        /* Request header.  */
index 89c6e3719d2b99561a3a044d24e18bf8c7142ce7..3305b47fdf536f2aaeaf9cb7ed8aca000f998eac 100644 (file)
@@ -128,14 +128,6 @@ static void tcm_loop_submission_work(struct work_struct *work)
                set_host_byte(sc, DID_ERROR);
                goto out_done;
        }
-       if (scsi_bidi_cmnd(sc)) {
-               struct scsi_data_buffer *sdb = scsi_in(sc);
-
-               sgl_bidi = sdb->table.sgl;
-               sgl_bidi_count = sdb->table.nents;
-               se_cmd->se_cmd_flags |= SCF_BIDI;
-
-       }
 
        transfer_length = scsi_transfer_length(sc);
        if (!scsi_prot_sg_count(sc) &&
@@ -304,12 +296,6 @@ static int tcm_loop_target_reset(struct scsi_cmnd *sc)
        return FAILED;
 }
 
-static int tcm_loop_slave_alloc(struct scsi_device *sd)
-{
-       blk_queue_flag_set(QUEUE_FLAG_BIDI, sd->request_queue);
-       return 0;
-}
-
 static struct scsi_host_template tcm_loop_driver_template = {
        .show_info              = tcm_loop_show_info,
        .proc_name              = "tcm_loopback",
@@ -325,7 +311,6 @@ static struct scsi_host_template tcm_loop_driver_template = {
        .cmd_per_lun            = 1024,
        .max_sectors            = 0xFFFF,
        .dma_boundary           = PAGE_SIZE - 1,
-       .slave_alloc            = tcm_loop_slave_alloc,
        .module                 = THIS_MODULE,
        .track_queue_depth      = 1,
 };
index 36742e8e7edcc1f67743f509e061a236b7f392f3..95f2142093d5e9b3465f59821f9abb56e4b0520a 100644 (file)
@@ -368,25 +368,19 @@ static void uas_data_cmplt(struct urb *urb)
        struct scsi_cmnd *cmnd = urb->context;
        struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
        struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata;
-       struct scsi_data_buffer *sdb = NULL;
+       struct scsi_data_buffer *sdb = &cmnd->sdb;
        unsigned long flags;
        int status = urb->status;
 
        spin_lock_irqsave(&devinfo->lock, flags);
 
        if (cmdinfo->data_in_urb == urb) {
-               sdb = scsi_in(cmnd);
                cmdinfo->state &= ~DATA_IN_URB_INFLIGHT;
                cmdinfo->data_in_urb = NULL;
        } else if (cmdinfo->data_out_urb == urb) {
-               sdb = scsi_out(cmnd);
                cmdinfo->state &= ~DATA_OUT_URB_INFLIGHT;
                cmdinfo->data_out_urb = NULL;
        }
-       if (sdb == NULL) {
-               WARN_ON_ONCE(1);
-               goto out;
-       }
 
        if (devinfo->resetting)
                goto out;
@@ -426,8 +420,7 @@ static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp,
        struct usb_device *udev = devinfo->udev;
        struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
        struct urb *urb = usb_alloc_urb(0, gfp);
-       struct scsi_data_buffer *sdb = (dir == DMA_FROM_DEVICE)
-               ? scsi_in(cmnd) : scsi_out(cmnd);
+       struct scsi_data_buffer *sdb = &cmnd->sdb;
        unsigned int pipe = (dir == DMA_FROM_DEVICE)
                ? devinfo->data_in_pipe : devinfo->data_out_pipe;
 
index d85e6befa26b27ca93a042639f8ed4a61ee126fe..af6ae3e1eba6aa8f6ac9a156914cd74c9da81f5c 100644 (file)
@@ -213,23 +213,6 @@ static inline int scsi_get_resid(struct scsi_cmnd *cmd)
 #define scsi_for_each_sg(cmd, sg, nseg, __i)                   \
        for_each_sg(scsi_sglist(cmd), sg, nseg, __i)
 
-static inline int scsi_bidi_cmnd(struct scsi_cmnd *cmd)
-{
-       return blk_bidi_rq(cmd->request) &&
-               (cmd->request->next_rq->special != NULL);
-}
-
-static inline struct scsi_data_buffer *scsi_in(struct scsi_cmnd *cmd)
-{
-       return scsi_bidi_cmnd(cmd) ?
-               cmd->request->next_rq->special : &cmd->sdb;
-}
-
-static inline struct scsi_data_buffer *scsi_out(struct scsi_cmnd *cmd)
-{
-       return &cmd->sdb;
-}
-
 static inline int scsi_sg_copy_from_buffer(struct scsi_cmnd *cmd,
                                           void *buf, int buflen)
 {
@@ -351,7 +334,7 @@ static inline void set_driver_byte(struct scsi_cmnd *cmd, char status)
 
 static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
 {
-       unsigned int xfer_len = scsi_out(scmd)->length;
+       unsigned int xfer_len = scmd->sdb.length;
        unsigned int prot_interval = scsi_prot_interval(scmd);
 
        if (scmd->prot_flags & SCSI_PROT_TRANSFER_PI)
index 2b7e227960e1602123aecf88b11f9be00e975655..3810b340551c35d2a621c7b243dced26dd4d7c28 100644 (file)
@@ -39,7 +39,6 @@ struct scsi_eh_save {
        unsigned char prot_op;
        unsigned char *cmnd;
        struct scsi_data_buffer sdb;
-       struct request *next_rq;
        /* new command support */
        unsigned char eh_cmnd[BLK_MAX_CDB];
        struct scatterlist sense_sgl;