Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: remove bidirectional command support

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>

authored by

Christoph Hellwig and committed by
Martin K. Petersen
ae3d56d8 19fcae3d

+34 -268
+5 -8
drivers/scsi/cxgbi/libcxgbi.c
··· 1211 1211 unsigned int *sgcnt, unsigned int *dlen, 1212 1212 unsigned int prot) 1213 1213 { 1214 - struct scsi_data_buffer *sdb = prot ? scsi_prot(sc) : scsi_out(sc); 1214 + struct scsi_data_buffer *sdb = prot ? scsi_prot(sc) : &sc->sdb; 1215 1215 1216 1216 *sgl = sdb->table.sgl; 1217 1217 *sgcnt = sdb->table.nents; ··· 1427 1427 log_debug(1 << CXGBI_DBG_DDP, 1428 1428 "cdev 0x%p, task 0x%p, release tag 0x%x.\n", 1429 1429 cdev, task, tag); 1430 - if (sc && 1431 - (scsi_bidi_cmnd(sc) || sc->sc_data_direction == DMA_FROM_DEVICE) && 1430 + if (sc && sc->sc_data_direction == DMA_FROM_DEVICE && 1432 1431 cxgbi_ppm_is_ddp_tag(ppm, tag)) { 1433 1432 struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task); 1434 1433 struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo; ··· 1459 1460 u32 tag = 0; 1460 1461 int err = -EINVAL; 1461 1462 1462 - if (sc && 1463 - (scsi_bidi_cmnd(sc) || sc->sc_data_direction == DMA_FROM_DEVICE) 1464 - ) { 1463 + if (sc && sc->sc_data_direction == DMA_FROM_DEVICE) { 1465 1464 struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task); 1466 1465 struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo; 1467 1466 ··· 1893 1896 if (SKB_MAX_HEAD(cdev->skb_tx_rsvd) > (512 * MAX_SKB_FRAGS) && 1894 1897 (opcode == ISCSI_OP_SCSI_DATA_OUT || 1895 1898 (opcode == ISCSI_OP_SCSI_CMD && 1896 - (scsi_bidi_cmnd(sc) || sc->sc_data_direction == DMA_TO_DEVICE)))) 1899 + sc->sc_data_direction == DMA_TO_DEVICE))) 1897 1900 /* data could goes into skb head */ 1898 1901 headroom += min_t(unsigned int, 1899 1902 SKB_MAX_HEAD(cdev->skb_tx_rsvd), ··· 1968 1971 return 0; 1969 1972 1970 1973 if (task->sc) { 1971 - struct scsi_data_buffer *sdb = scsi_out(task->sc); 1974 + struct scsi_data_buffer *sdb = &task->sc->sdb; 1972 1975 struct scatterlist *sg = NULL; 1973 1976 int err; 1974 1977
+1 -8
drivers/scsi/iscsi_tcp.c
··· 518 518 if (!task->sc) 519 519 iscsi_sw_tcp_send_linear_data_prep(conn, task->data, count); 520 520 else { 521 - struct scsi_data_buffer *sdb = scsi_out(task->sc); 521 + struct scsi_data_buffer *sdb = &task->sc->sdb; 522 522 523 523 err = iscsi_sw_tcp_send_data_prep(conn, sdb->table.sgl, 524 524 sdb->table.nents, offset, ··· 952 952 return 0; 953 953 } 954 954 955 - static int iscsi_sw_tcp_slave_alloc(struct scsi_device *sdev) 956 - { 957 - blk_queue_flag_set(QUEUE_FLAG_BIDI, sdev->request_queue); 958 - return 0; 959 - } 960 - 961 955 static int iscsi_sw_tcp_slave_configure(struct scsi_device *sdev) 962 956 { 963 957 struct iscsi_sw_tcp_host *tcp_sw_host = iscsi_host_priv(sdev->host); ··· 979 985 .eh_device_reset_handler= iscsi_eh_device_reset, 980 986 .eh_target_reset_handler = iscsi_eh_recover_target, 981 987 .dma_boundary = PAGE_SIZE - 1, 982 - .slave_alloc = iscsi_sw_tcp_slave_alloc, 983 988 .slave_configure = iscsi_sw_tcp_slave_configure, 984 989 .target_alloc = iscsi_target_alloc, 985 990 .proc_name = "iscsi_tcp",
+6 -58
drivers/scsi/libiscsi.c
··· 228 228 return 0; 229 229 } 230 230 231 - static int iscsi_prep_bidi_ahs(struct iscsi_task *task) 232 - { 233 - struct scsi_cmnd *sc = task->sc; 234 - struct iscsi_rlength_ahdr *rlen_ahdr; 235 - int rc; 236 - 237 - rlen_ahdr = iscsi_next_hdr(task); 238 - rc = iscsi_add_hdr(task, sizeof(*rlen_ahdr)); 239 - if (rc) 240 - return rc; 241 - 242 - rlen_ahdr->ahslength = 243 - cpu_to_be16(sizeof(rlen_ahdr->read_length) + 244 - sizeof(rlen_ahdr->reserved)); 245 - rlen_ahdr->ahstype = ISCSI_AHSTYPE_RLENGTH; 246 - rlen_ahdr->reserved = 0; 247 - rlen_ahdr->read_length = cpu_to_be32(scsi_in(sc)->length); 248 - 249 - ISCSI_DBG_SESSION(task->conn->session, 250 - "bidi-in rlen_ahdr->read_length(%d) " 251 - "rlen_ahdr->ahslength(%d)\n", 252 - be32_to_cpu(rlen_ahdr->read_length), 253 - be16_to_cpu(rlen_ahdr->ahslength)); 254 - return 0; 255 - } 256 - 257 231 /** 258 232 * iscsi_check_tmf_restrictions - check if a task is affected by TMF 259 233 * @task: iscsi task ··· 366 392 memcpy(hdr->cdb, sc->cmnd, cmd_len); 367 393 368 394 task->imm_count = 0; 369 - if (scsi_bidi_cmnd(sc)) { 370 - hdr->flags |= ISCSI_FLAG_CMD_READ; 371 - rc = iscsi_prep_bidi_ahs(task); 372 - if (rc) 373 - return rc; 374 - } 375 - 376 395 if (scsi_get_prot_op(sc) != SCSI_PROT_NORMAL) 377 396 task->protected = true; 378 397 ··· 440 473 441 474 conn->scsicmd_pdus_cnt++; 442 475 ISCSI_DBG_SESSION(session, "iscsi prep [%s cid %d sc %p cdb 0x%x " 443 - "itt 0x%x len %d bidi_len %d cmdsn %d win %d]\n", 444 - scsi_bidi_cmnd(sc) ? "bidirectional" : 476 + "itt 0x%x len %d cmdsn %d win %d]\n", 445 477 sc->sc_data_direction == DMA_TO_DEVICE ? 446 478 "write" : "read", conn->id, sc, sc->cmnd[0], 447 479 task->itt, transfer_length, 448 - scsi_bidi_cmnd(sc) ? scsi_in(sc)->length : 0, 449 480 session->cmdsn, 450 481 session->max_cmdsn - session->exp_cmdsn + 1); 451 482 return 0; ··· 612 647 state = ISCSI_TASK_ABRT_TMF; 613 648 614 649 sc->result = err << 16; 615 - if (!scsi_bidi_cmnd(sc)) 616 - scsi_set_resid(sc, scsi_bufflen(sc)); 617 - else { 618 - scsi_out(sc)->resid = scsi_out(sc)->length; 619 - scsi_in(sc)->resid = scsi_in(sc)->length; 620 - } 650 + scsi_set_resid(sc, scsi_bufflen(sc)); 621 651 622 652 /* regular RX path uses back_lock */ 623 653 spin_lock_bh(&conn->session->back_lock); ··· 867 907 868 908 if (rhdr->flags & (ISCSI_FLAG_CMD_BIDI_UNDERFLOW | 869 909 ISCSI_FLAG_CMD_BIDI_OVERFLOW)) { 870 - int res_count = be32_to_cpu(rhdr->bi_residual_count); 871 - 872 - if (scsi_bidi_cmnd(sc) && res_count > 0 && 873 - (rhdr->flags & ISCSI_FLAG_CMD_BIDI_OVERFLOW || 874 - res_count <= scsi_in(sc)->length)) 875 - scsi_in(sc)->resid = res_count; 876 - else 877 - sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status; 910 + sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status; 878 911 } 879 912 880 913 if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW | ··· 914 961 915 962 if (res_count > 0 && 916 963 (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW || 917 - res_count <= scsi_in(sc)->length)) 918 - scsi_in(sc)->resid = res_count; 964 + res_count <= sc->sdb.length)) 965 + sc->sdb.resid = res_count; 919 966 else 920 967 sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status; 921 968 } ··· 1757 1804 spin_unlock_bh(&session->frwd_lock); 1758 1805 ISCSI_DBG_SESSION(session, "iscsi: cmd 0x%x is not queued (%d)\n", 1759 1806 sc->cmnd[0], reason); 1760 - if (!scsi_bidi_cmnd(sc)) 1761 - scsi_set_resid(sc, scsi_bufflen(sc)); 1762 - else { 1763 - scsi_out(sc)->resid = scsi_out(sc)->length; 1764 - scsi_in(sc)->resid = scsi_in(sc)->length; 1765 - } 1807 + scsi_set_resid(sc, scsi_bufflen(sc)); 1766 1808 sc->scsi_done(sc); 1767 1809 return 0; 1768 1810 }
+4 -4
drivers/scsi/libiscsi_tcp.c
··· 495 495 struct iscsi_tcp_task *tcp_task = task->dd_data; 496 496 struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr; 497 497 int datasn = be32_to_cpu(rhdr->datasn); 498 - unsigned total_in_length = scsi_in(task->sc)->length; 498 + unsigned total_in_length = task->sc->sdb.length; 499 499 500 500 /* 501 501 * lib iscsi will update this in the completion handling if there ··· 580 580 data_length, session->max_burst); 581 581 582 582 data_offset = be32_to_cpu(rhdr->data_offset); 583 - if (data_offset + data_length > scsi_out(task->sc)->length) { 583 + if (data_offset + data_length > task->sc->sdb.length) { 584 584 iscsi_conn_printk(KERN_ERR, conn, 585 585 "invalid R2T with data len %u at offset %u " 586 586 "and total length %d\n", data_length, 587 - data_offset, scsi_out(task->sc)->length); 587 + data_offset, task->sc->sdb.length); 588 588 return ISCSI_ERR_DATALEN; 589 589 } 590 590 ··· 696 696 if (tcp_conn->in.datalen) { 697 697 struct iscsi_tcp_task *tcp_task = task->dd_data; 698 698 struct ahash_request *rx_hash = NULL; 699 - struct scsi_data_buffer *sdb = scsi_in(task->sc); 699 + struct scsi_data_buffer *sdb = &task->sc->sdb; 700 700 701 701 /* 702 702 * Setup copy of Data-In into the struct scsi_cmnd
+8 -77
drivers/scsi/scsi_debug.c
··· 430 430 static int resp_rsup_tmfs(struct scsi_cmnd *, struct sdebug_dev_info *); 431 431 static int resp_write_same_10(struct scsi_cmnd *, struct sdebug_dev_info *); 432 432 static int resp_write_same_16(struct scsi_cmnd *, struct sdebug_dev_info *); 433 - static int resp_xdwriteread_10(struct scsi_cmnd *, struct sdebug_dev_info *); 434 433 static int resp_comp_write(struct scsi_cmnd *, struct sdebug_dev_info *); 435 434 static int resp_write_buffer(struct scsi_cmnd *, struct sdebug_dev_info *); 436 435 static int resp_sync_cache(struct scsi_cmnd *, struct sdebug_dev_info *); ··· 599 600 {0, 0x42, 0, F_D_OUT | FF_MEDIA_IO, resp_unmap, NULL, /* UNMAP */ 600 601 {10, 0x1, 0, 0, 0, 0, 0x3f, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} }, 601 602 /* 25 */ 602 - {0, 0x53, 0, F_D_IN | F_D_OUT | FF_MEDIA_IO, resp_xdwriteread_10, 603 - NULL, {10, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xc7, 604 - 0, 0, 0, 0, 0, 0} }, /* XDWRITEREAD(10) */ 605 603 {0, 0x3b, 0, F_D_OUT_MAYBE, resp_write_buffer, NULL, 606 604 {10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0, 0, 607 605 0, 0, 0, 0} }, /* WRITE_BUFFER */ ··· 1006 1010 int arr_len) 1007 1011 { 1008 1012 int act_len; 1009 - struct scsi_data_buffer *sdb = scsi_in(scp); 1013 + struct scsi_data_buffer *sdb = &scp->sdb; 1010 1014 1011 1015 if (!sdb->length) 1012 1016 return 0; 1013 - if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_FROM_DEVICE)) 1017 + if (scp->sc_data_direction != DMA_FROM_DEVICE) 1014 1018 return DID_ERROR << 16; 1015 1019 1016 1020 act_len = sg_copy_from_buffer(sdb->table.sgl, sdb->table.nents, ··· 1029 1033 int arr_len, unsigned int off_dst) 1030 1034 { 1031 1035 int act_len, n; 1032 - struct scsi_data_buffer *sdb = scsi_in(scp); 1036 + struct scsi_data_buffer *sdb = &scp->sdb; 1033 1037 off_t skip = off_dst; 1034 1038 1035 1039 if (sdb->length <= off_dst) 1036 1040 return 0; 1037 - if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_FROM_DEVICE)) 1041 + if (scp->sc_data_direction != DMA_FROM_DEVICE) 1038 1042 return DID_ERROR << 16; 1039 1043 1040 1044 act_len = sg_pcopy_from_buffer(sdb->table.sgl, sdb->table.nents, ··· 1054 1058 { 1055 1059 if (!scsi_bufflen(scp)) 1056 1060 return 0; 1057 - if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_TO_DEVICE)) 1061 + if (scp->sc_data_direction != DMA_TO_DEVICE) 1058 1062 return -1; 1059 1063 1060 1064 return scsi_sg_copy_to_buffer(scp, arr, arr_len); ··· 2473 2477 { 2474 2478 int ret; 2475 2479 u64 block, rest = 0; 2476 - struct scsi_data_buffer *sdb; 2480 + struct scsi_data_buffer *sdb = &scmd->sdb; 2477 2481 enum dma_data_direction dir; 2478 2482 2479 2483 if (do_write) { 2480 - sdb = scsi_out(scmd); 2481 2484 dir = DMA_TO_DEVICE; 2482 2485 write_since_sync = true; 2483 2486 } else { 2484 - sdb = scsi_in(scmd); 2485 2487 dir = DMA_FROM_DEVICE; 2486 2488 } 2487 2489 2488 2490 if (!sdb->length) 2489 2491 return 0; 2490 - if (!(scsi_bidi_cmnd(scmd) || scmd->sc_data_direction == dir)) 2492 + if (scmd->sc_data_direction != dir) 2491 2493 return -1; 2492 2494 2493 2495 block = do_div(lba, sdebug_store_sectors); ··· 2768 2774 if (unlikely(ret == -1)) 2769 2775 return DID_ERROR << 16; 2770 2776 2771 - scsi_in(scp)->resid = scsi_bufflen(scp) - ret; 2777 + scp->sdb.resid = scsi_bufflen(scp) - ret; 2772 2778 2773 2779 if (unlikely(sqcp)) { 2774 2780 if (sqcp->inj_recovered) { ··· 3712 3718 return res; 3713 3719 } 3714 3720 3715 - static int resp_xdwriteread(struct scsi_cmnd *scp, unsigned long long lba, 3716 - unsigned int num, struct sdebug_dev_info *devip) 3717 - { 3718 - int j; 3719 - unsigned char *kaddr, *buf; 3720 - unsigned int offset; 3721 - struct scsi_data_buffer *sdb = scsi_in(scp); 3722 - struct sg_mapping_iter miter; 3723 - 3724 - /* better not to use temporary buffer. */ 3725 - buf = kzalloc(scsi_bufflen(scp), GFP_ATOMIC); 3726 - if (!buf) { 3727 - mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, 3728 - INSUFF_RES_ASCQ); 3729 - return check_condition_result; 3730 - } 3731 - 3732 - scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); 3733 - 3734 - offset = 0; 3735 - sg_miter_start(&miter, sdb->table.sgl, sdb->table.nents, 3736 - SG_MITER_ATOMIC | SG_MITER_TO_SG); 3737 - 3738 - while (sg_miter_next(&miter)) { 3739 - kaddr = miter.addr; 3740 - for (j = 0; j < miter.length; j++) 3741 - *(kaddr + j) ^= *(buf + offset + j); 3742 - 3743 - offset += miter.length; 3744 - } 3745 - sg_miter_stop(&miter); 3746 - kfree(buf); 3747 - 3748 - return 0; 3749 - } 3750 - 3751 - static int resp_xdwriteread_10(struct scsi_cmnd *scp, 3752 - struct sdebug_dev_info *devip) 3753 - { 3754 - u8 *cmd = scp->cmnd; 3755 - u64 lba; 3756 - u32 num; 3757 - int errsts; 3758 - 3759 - if (!scsi_bidi_cmnd(scp)) { 3760 - mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, 3761 - INSUFF_RES_ASCQ); 3762 - return check_condition_result; 3763 - } 3764 - errsts = resp_read_dt0(scp, devip); 3765 - if (errsts) 3766 - return errsts; 3767 - if (!(cmd[1] & 0x4)) { /* DISABLE_WRITE is not set */ 3768 - errsts = resp_write_dt0(scp, devip); 3769 - if (errsts) 3770 - return errsts; 3771 - } 3772 - lba = get_unaligned_be32(cmd + 2); 3773 - num = get_unaligned_be16(cmd + 7); 3774 - return resp_xdwriteread(scp, lba, num, devip); 3775 - } 3776 - 3777 3721 static struct sdebug_queue *get_queue(struct scsi_cmnd *cmnd) 3778 3722 { 3779 3723 u32 tag = blk_mq_unique_tag(cmnd->request); ··· 3885 3953 if (sdebug_verbose) 3886 3954 pr_info("slave_alloc <%u %u %u %llu>\n", 3887 3955 sdp->host->host_no, sdp->channel, sdp->id, sdp->lun); 3888 - blk_queue_flag_set(QUEUE_FLAG_BIDI, sdp->request_queue); 3889 3956 return 0; 3890 3957 } 3891 3958
-3
drivers/scsi/scsi_error.c
··· 965 965 ses->cmnd = scmd->cmnd; 966 966 ses->data_direction = scmd->sc_data_direction; 967 967 ses->sdb = scmd->sdb; 968 - ses->next_rq = scmd->request->next_rq; 969 968 ses->result = scmd->result; 970 969 ses->underflow = scmd->underflow; 971 970 ses->prot_op = scmd->prot_op; ··· 975 976 scmd->cmnd = ses->eh_cmnd; 976 977 memset(scmd->cmnd, 0, BLK_MAX_CDB); 977 978 memset(&scmd->sdb, 0, sizeof(scmd->sdb)); 978 - scmd->request->next_rq = NULL; 979 979 scmd->result = 0; 980 980 981 981 if (sense_bytes) { ··· 1027 1029 scmd->cmnd = ses->cmnd; 1028 1030 scmd->sc_data_direction = ses->data_direction; 1029 1031 scmd->sdb = ses->sdb; 1030 - scmd->request->next_rq = ses->next_rq; 1031 1032 scmd->result = ses->result; 1032 1033 scmd->underflow = ses->underflow; 1033 1034 scmd->prot_op = ses->prot_op;
+4 -56
drivers/scsi/scsi_lib.c
··· 556 556 557 557 static void scsi_mq_free_sgtables(struct scsi_cmnd *cmd) 558 558 { 559 - struct scsi_data_buffer *sdb; 560 - 561 559 if (cmd->sdb.table.nents) 562 560 sg_free_table_chained(&cmd->sdb.table, true); 563 - if (cmd->request->next_rq) { 564 - sdb = cmd->request->next_rq->special; 565 - if (sdb) 566 - sg_free_table_chained(&sdb->table, true); 567 - } 568 561 if (scsi_prot_sg_count(cmd)) 569 562 sg_free_table_chained(&cmd->prot_sdb->table, true); 570 563 } ··· 571 578 572 579 /* Returns false when no more bytes to process, true if there are more */ 573 580 static bool scsi_end_request(struct request *req, blk_status_t error, 574 - unsigned int bytes, unsigned int bidi_bytes) 581 + unsigned int bytes) 575 582 { 576 583 struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); 577 584 struct scsi_device *sdev = cmd->device; 578 585 struct request_queue *q = sdev->request_queue; 579 586 580 587 if (blk_update_request(req, error, bytes)) 581 - return true; 582 - 583 - /* Bidi request must be completed as a whole */ 584 - if (unlikely(bidi_bytes) && 585 - blk_update_request(req->next_rq, error, bidi_bytes)) 586 588 return true; 587 589 588 590 if (blk_queue_add_random(q)) ··· 804 816 scsi_print_command(cmd); 805 817 } 806 818 } 807 - if (!scsi_end_request(req, blk_stat, blk_rq_err_bytes(req), 0)) 819 + if (!scsi_end_request(req, blk_stat, blk_rq_err_bytes(req))) 808 820 return; 809 821 /*FALLTHRU*/ 810 822 case ACTION_REPREP: ··· 939 951 */ 940 952 scsi_req(req)->result = cmd->result; 941 953 scsi_req(req)->resid_len = scsi_get_resid(cmd); 942 - 943 - if (unlikely(scsi_bidi_cmnd(cmd))) { 944 - /* 945 - * Bidi commands Must be complete as a whole, 946 - * both sides at once. 947 - */ 948 - scsi_req(req->next_rq)->resid_len = scsi_in(cmd)->resid; 949 - if (scsi_end_request(req, BLK_STS_OK, blk_rq_bytes(req), 950 - blk_rq_bytes(req->next_rq))) 951 - WARN_ONCE(true, 952 - "Bidi command with remaining bytes"); 953 - return; 954 - } 955 - } 956 - 957 - /* no bidi support yet, other than in pass-through */ 958 - if (unlikely(blk_bidi_rq(req))) { 959 - WARN_ONCE(true, "Only support bidi command in passthrough"); 960 - scmd_printk(KERN_ERR, cmd, "Killing bidi command\n"); 961 - if (scsi_end_request(req, BLK_STS_IOERR, blk_rq_bytes(req), 962 - blk_rq_bytes(req->next_rq))) 963 - WARN_ONCE(true, "Bidi command with remaining bytes"); 964 - return; 965 954 } 966 955 967 956 /* ··· 955 990 * to retry code. Fast path should return in this block. 956 991 */ 957 992 if (likely(blk_rq_bytes(req) > 0 || blk_stat == BLK_STS_OK)) { 958 - if (likely(!scsi_end_request(req, blk_stat, good_bytes, 0))) 993 + if (likely(!scsi_end_request(req, blk_stat, good_bytes))) 959 994 return; /* no bytes remaining */ 960 995 } 961 996 962 997 /* Kill remainder if no retries. */ 963 998 if (unlikely(blk_stat && scsi_noretry_cmd(cmd))) { 964 - if (scsi_end_request(req, blk_stat, blk_rq_bytes(req), 0)) 999 + if (scsi_end_request(req, blk_stat, blk_rq_bytes(req))) 965 1000 WARN_ONCE(true, 966 1001 "Bytes remaining after failed, no-retry command"); 967 1002 return; ··· 1022 1057 ret = scsi_init_sgtable(rq, &cmd->sdb); 1023 1058 if (ret) 1024 1059 return ret; 1025 - 1026 - if (blk_bidi_rq(rq)) { 1027 - ret = scsi_init_sgtable(rq->next_rq, rq->next_rq->special); 1028 - if (ret) 1029 - goto out_free_sgtables; 1030 - } 1031 1060 1032 1061 if (blk_integrity_rq(rq)) { 1033 1062 struct scsi_data_buffer *prot_sdb = cmd->prot_sdb; ··· 1581 1622 1582 1623 cmd->prot_sdb->table.sgl = 1583 1624 (struct scatterlist *)(cmd->prot_sdb + 1); 1584 - } 1585 - 1586 - if (blk_bidi_rq(req)) { 1587 - struct request *next_rq = req->next_rq; 1588 - struct scsi_data_buffer *bidi_sdb = blk_mq_rq_to_pdu(next_rq); 1589 - 1590 - memset(bidi_sdb, 0, sizeof(struct scsi_data_buffer)); 1591 - bidi_sdb->table.sgl = 1592 - (struct scatterlist *)(bidi_sdb + 1); 1593 - 1594 - next_rq->special = bidi_sdb; 1595 1625 } 1596 1626 1597 1627 blk_mq_start_request(req);
+3 -11
drivers/scsi/virtio_scsi.c
··· 100 100 101 101 static void virtscsi_compute_resid(struct scsi_cmnd *sc, u32 resid) 102 102 { 103 - if (!resid) 104 - return; 105 - 106 - if (!scsi_bidi_cmnd(sc)) { 103 + if (resid) 107 104 scsi_set_resid(sc, resid); 108 - return; 109 - } 110 - 111 - scsi_in(sc)->resid = min(resid, scsi_in(sc)->length); 112 - scsi_out(sc)->resid = resid - scsi_in(sc)->resid; 113 105 } 114 106 115 107 /** ··· 395 403 396 404 if (sc && sc->sc_data_direction != DMA_NONE) { 397 405 if (sc->sc_data_direction != DMA_FROM_DEVICE) 398 - out = &scsi_out(sc)->table; 406 + out = &sc->sdb.table; 399 407 if (sc->sc_data_direction != DMA_TO_DEVICE) 400 - in = &scsi_in(sc)->table; 408 + in = &sc->sdb.table; 401 409 } 402 410 403 411 /* Request header. */
-15
drivers/target/loopback/tcm_loop.c
··· 128 128 set_host_byte(sc, DID_ERROR); 129 129 goto out_done; 130 130 } 131 - if (scsi_bidi_cmnd(sc)) { 132 - struct scsi_data_buffer *sdb = scsi_in(sc); 133 - 134 - sgl_bidi = sdb->table.sgl; 135 - sgl_bidi_count = sdb->table.nents; 136 - se_cmd->se_cmd_flags |= SCF_BIDI; 137 - 138 - } 139 131 140 132 transfer_length = scsi_transfer_length(sc); 141 133 if (!scsi_prot_sg_count(sc) && ··· 296 304 return FAILED; 297 305 } 298 306 299 - static int tcm_loop_slave_alloc(struct scsi_device *sd) 300 - { 301 - blk_queue_flag_set(QUEUE_FLAG_BIDI, sd->request_queue); 302 - return 0; 303 - } 304 - 305 307 static struct scsi_host_template tcm_loop_driver_template = { 306 308 .show_info = tcm_loop_show_info, 307 309 .proc_name = "tcm_loopback", ··· 311 325 .cmd_per_lun = 1024, 312 326 .max_sectors = 0xFFFF, 313 327 .dma_boundary = PAGE_SIZE - 1, 314 - .slave_alloc = tcm_loop_slave_alloc, 315 328 .module = THIS_MODULE, 316 329 .track_queue_depth = 1, 317 330 };
+2 -9
drivers/usb/storage/uas.c
··· 368 368 struct scsi_cmnd *cmnd = urb->context; 369 369 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; 370 370 struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; 371 - struct scsi_data_buffer *sdb = NULL; 371 + struct scsi_data_buffer *sdb = &cmnd->sdb; 372 372 unsigned long flags; 373 373 int status = urb->status; 374 374 375 375 spin_lock_irqsave(&devinfo->lock, flags); 376 376 377 377 if (cmdinfo->data_in_urb == urb) { 378 - sdb = scsi_in(cmnd); 379 378 cmdinfo->state &= ~DATA_IN_URB_INFLIGHT; 380 379 cmdinfo->data_in_urb = NULL; 381 380 } else if (cmdinfo->data_out_urb == urb) { 382 - sdb = scsi_out(cmnd); 383 381 cmdinfo->state &= ~DATA_OUT_URB_INFLIGHT; 384 382 cmdinfo->data_out_urb = NULL; 385 - } 386 - if (sdb == NULL) { 387 - WARN_ON_ONCE(1); 388 - goto out; 389 383 } 390 384 391 385 if (devinfo->resetting) ··· 420 426 struct usb_device *udev = devinfo->udev; 421 427 struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; 422 428 struct urb *urb = usb_alloc_urb(0, gfp); 423 - struct scsi_data_buffer *sdb = (dir == DMA_FROM_DEVICE) 424 - ? scsi_in(cmnd) : scsi_out(cmnd); 429 + struct scsi_data_buffer *sdb = &cmnd->sdb; 425 430 unsigned int pipe = (dir == DMA_FROM_DEVICE) 426 431 ? devinfo->data_in_pipe : devinfo->data_out_pipe; 427 432
+1 -18
include/scsi/scsi_cmnd.h
··· 213 213 #define scsi_for_each_sg(cmd, sg, nseg, __i) \ 214 214 for_each_sg(scsi_sglist(cmd), sg, nseg, __i) 215 215 216 - static inline int scsi_bidi_cmnd(struct scsi_cmnd *cmd) 217 - { 218 - return blk_bidi_rq(cmd->request) && 219 - (cmd->request->next_rq->special != NULL); 220 - } 221 - 222 - static inline struct scsi_data_buffer *scsi_in(struct scsi_cmnd *cmd) 223 - { 224 - return scsi_bidi_cmnd(cmd) ? 225 - cmd->request->next_rq->special : &cmd->sdb; 226 - } 227 - 228 - static inline struct scsi_data_buffer *scsi_out(struct scsi_cmnd *cmd) 229 - { 230 - return &cmd->sdb; 231 - } 232 - 233 216 static inline int scsi_sg_copy_from_buffer(struct scsi_cmnd *cmd, 234 217 void *buf, int buflen) 235 218 { ··· 334 351 335 352 static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd) 336 353 { 337 - unsigned int xfer_len = scsi_out(scmd)->length; 354 + unsigned int xfer_len = scmd->sdb.length; 338 355 unsigned int prot_interval = scsi_prot_interval(scmd); 339 356 340 357 if (scmd->prot_flags & SCSI_PROT_TRANSFER_PI)
-1
include/scsi/scsi_eh.h
··· 39 39 unsigned char prot_op; 40 40 unsigned char *cmnd; 41 41 struct scsi_data_buffer sdb; 42 - struct request *next_rq; 43 42 /* new command support */ 44 43 unsigned char eh_cmnd[BLK_MAX_CDB]; 45 44 struct scatterlist sense_sgl;