Skip to content

Commit ae3d56d

Browse files
Christoph Hellwigmartinkpetersen
authored andcommitted
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>
1 parent 19fcae3 commit ae3d56d

12 files changed

Lines changed: 34 additions & 268 deletions

File tree

‎drivers/scsi/cxgbi/libcxgbi.c‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ scmd_get_params(struct scsi_cmnd *sc, struct scatterlist **sgl,
12111211
unsigned int *sgcnt, unsigned int *dlen,
12121212
unsigned int prot)
12131213
{
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;
12151215

12161216
*sgl = sdb->table.sgl;
12171217
*sgcnt = sdb->table.nents;
@@ -1427,8 +1427,7 @@ static void task_release_itt(struct iscsi_task *task, itt_t hdr_itt)
14271427
log_debug(1 << CXGBI_DBG_DDP,
14281428
"cdev 0x%p, task 0x%p, release tag 0x%x.\n",
14291429
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 &&
14321431
cxgbi_ppm_is_ddp_tag(ppm, tag)) {
14331432
struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
14341433
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)
14601459
u32 tag = 0;
14611460
int err = -EINVAL;
14621461

1463-
if (sc &&
1464-
(scsi_bidi_cmnd(sc) || sc->sc_data_direction == DMA_FROM_DEVICE)
1465-
) {
1462+
if (sc && sc->sc_data_direction == DMA_FROM_DEVICE) {
14661463
struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
14671464
struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo;
14681465

@@ -1896,7 +1893,7 @@ int cxgbi_conn_alloc_pdu(struct iscsi_task *task, u8 opcode)
18961893
if (SKB_MAX_HEAD(cdev->skb_tx_rsvd) > (512 * MAX_SKB_FRAGS) &&
18971894
(opcode == ISCSI_OP_SCSI_DATA_OUT ||
18981895
(opcode == ISCSI_OP_SCSI_CMD &&
1899-
(scsi_bidi_cmnd(sc) || sc->sc_data_direction == DMA_TO_DEVICE))))
1896+
sc->sc_data_direction == DMA_TO_DEVICE)))
19001897
/* data could goes into skb head */
19011898
headroom += min_t(unsigned int,
19021899
SKB_MAX_HEAD(cdev->skb_tx_rsvd),
@@ -1971,7 +1968,7 @@ int cxgbi_conn_init_pdu(struct iscsi_task *task, unsigned int offset,
19711968
return 0;
19721969

19731970
if (task->sc) {
1974-
struct scsi_data_buffer *sdb = scsi_out(task->sc);
1971+
struct scsi_data_buffer *sdb = &task->sc->sdb;
19751972
struct scatterlist *sg = NULL;
19761973
int err;
19771974

‎drivers/scsi/iscsi_tcp.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static int iscsi_sw_tcp_pdu_init(struct iscsi_task *task,
518518
if (!task->sc)
519519
iscsi_sw_tcp_send_linear_data_prep(conn, task->data, count);
520520
else {
521-
struct scsi_data_buffer *sdb = scsi_out(task->sc);
521+
struct scsi_data_buffer *sdb = &task->sc->sdb;
522522

523523
err = iscsi_sw_tcp_send_data_prep(conn, sdb->table.sgl,
524524
sdb->table.nents, offset,
@@ -952,12 +952,6 @@ static umode_t iscsi_sw_tcp_attr_is_visible(int param_type, int param)
952952
return 0;
953953
}
954954

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-
961955
static int iscsi_sw_tcp_slave_configure(struct scsi_device *sdev)
962956
{
963957
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 = {
985979
.eh_device_reset_handler= iscsi_eh_device_reset,
986980
.eh_target_reset_handler = iscsi_eh_recover_target,
987981
.dma_boundary = PAGE_SIZE - 1,
988-
.slave_alloc = iscsi_sw_tcp_slave_alloc,
989982
.slave_configure = iscsi_sw_tcp_slave_configure,
990983
.target_alloc = iscsi_target_alloc,
991984
.proc_name = "iscsi_tcp",

‎drivers/scsi/libiscsi.c‎

Lines changed: 6 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -228,32 +228,6 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_task *task)
228228
return 0;
229229
}
230230

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-
257231
/**
258232
* iscsi_check_tmf_restrictions - check if a task is affected by TMF
259233
* @task: iscsi task
@@ -392,13 +366,6 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
392366
memcpy(hdr->cdb, sc->cmnd, cmd_len);
393367

394368
task->imm_count = 0;
395-
if (scsi_bidi_cmnd(sc)) {
396-
hdr->flags |= ISCSI_FLAG_CMD_READ;
397-
rc = iscsi_prep_bidi_ahs(task);
398-
if (rc)
399-
return rc;
400-
}
401-
402369
if (scsi_get_prot_op(sc) != SCSI_PROT_NORMAL)
403370
task->protected = true;
404371

@@ -473,12 +440,10 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
473440

474441
conn->scsicmd_pdus_cnt++;
475442
ISCSI_DBG_SESSION(session, "iscsi prep [%s cid %d sc %p cdb 0x%x "
476-
"itt 0x%x len %d bidi_len %d cmdsn %d win %d]\n",
477-
scsi_bidi_cmnd(sc) ? "bidirectional" :
443+
"itt 0x%x len %d cmdsn %d win %d]\n",
478444
sc->sc_data_direction == DMA_TO_DEVICE ?
479445
"write" : "read", conn->id, sc, sc->cmnd[0],
480446
task->itt, transfer_length,
481-
scsi_bidi_cmnd(sc) ? scsi_in(sc)->length : 0,
482447
session->cmdsn,
483448
session->max_cmdsn - session->exp_cmdsn + 1);
484449
return 0;
@@ -647,12 +612,7 @@ static void fail_scsi_task(struct iscsi_task *task, int err)
647612
state = ISCSI_TASK_ABRT_TMF;
648613

649614
sc->result = err << 16;
650-
if (!scsi_bidi_cmnd(sc))
651-
scsi_set_resid(sc, scsi_bufflen(sc));
652-
else {
653-
scsi_out(sc)->resid = scsi_out(sc)->length;
654-
scsi_in(sc)->resid = scsi_in(sc)->length;
655-
}
615+
scsi_set_resid(sc, scsi_bufflen(sc));
656616

657617
/* regular RX path uses back_lock */
658618
spin_lock_bh(&conn->session->back_lock);
@@ -907,14 +867,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
907867

908868
if (rhdr->flags & (ISCSI_FLAG_CMD_BIDI_UNDERFLOW |
909869
ISCSI_FLAG_CMD_BIDI_OVERFLOW)) {
910-
int res_count = be32_to_cpu(rhdr->bi_residual_count);
911-
912-
if (scsi_bidi_cmnd(sc) && res_count > 0 &&
913-
(rhdr->flags & ISCSI_FLAG_CMD_BIDI_OVERFLOW ||
914-
res_count <= scsi_in(sc)->length))
915-
scsi_in(sc)->resid = res_count;
916-
else
917-
sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
870+
sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
918871
}
919872

920873
if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
@@ -961,8 +914,8 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
961914

962915
if (res_count > 0 &&
963916
(rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
964-
res_count <= scsi_in(sc)->length))
965-
scsi_in(sc)->resid = res_count;
917+
res_count <= sc->sdb.length))
918+
sc->sdb.resid = res_count;
966919
else
967920
sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
968921
}
@@ -1804,12 +1757,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
18041757
spin_unlock_bh(&session->frwd_lock);
18051758
ISCSI_DBG_SESSION(session, "iscsi: cmd 0x%x is not queued (%d)\n",
18061759
sc->cmnd[0], reason);
1807-
if (!scsi_bidi_cmnd(sc))
1808-
scsi_set_resid(sc, scsi_bufflen(sc));
1809-
else {
1810-
scsi_out(sc)->resid = scsi_out(sc)->length;
1811-
scsi_in(sc)->resid = scsi_in(sc)->length;
1812-
}
1760+
scsi_set_resid(sc, scsi_bufflen(sc));
18131761
sc->scsi_done(sc);
18141762
return 0;
18151763
}

‎drivers/scsi/libiscsi_tcp.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static int iscsi_tcp_data_in(struct iscsi_conn *conn, struct iscsi_task *task)
495495
struct iscsi_tcp_task *tcp_task = task->dd_data;
496496
struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr;
497497
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;
499499

500500
/*
501501
* 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)
580580
data_length, session->max_burst);
581581

582582
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) {
584584
iscsi_conn_printk(KERN_ERR, conn,
585585
"invalid R2T with data len %u at offset %u "
586586
"and total length %d\n", data_length,
587-
data_offset, scsi_out(task->sc)->length);
587+
data_offset, task->sc->sdb.length);
588588
return ISCSI_ERR_DATALEN;
589589
}
590590

@@ -696,7 +696,7 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
696696
if (tcp_conn->in.datalen) {
697697
struct iscsi_tcp_task *tcp_task = task->dd_data;
698698
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;
700700

701701
/*
702702
* Setup copy of Data-In into the struct scsi_cmnd

‎drivers/scsi/scsi_debug.c‎

Lines changed: 8 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ static int resp_rsup_opcodes(struct scsi_cmnd *, struct sdebug_dev_info *);
430430
static int resp_rsup_tmfs(struct scsi_cmnd *, struct sdebug_dev_info *);
431431
static int resp_write_same_10(struct scsi_cmnd *, struct sdebug_dev_info *);
432432
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 *);
434433
static int resp_comp_write(struct scsi_cmnd *, struct sdebug_dev_info *);
435434
static int resp_write_buffer(struct scsi_cmnd *, struct sdebug_dev_info *);
436435
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] = {
600599
{0, 0x42, 0, F_D_OUT | FF_MEDIA_IO, resp_unmap, NULL, /* UNMAP */
601600
{10, 0x1, 0, 0, 0, 0, 0x3f, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0, 0} },
602601
/* 25 */
603-
{0, 0x53, 0, F_D_IN | F_D_OUT | FF_MEDIA_IO, resp_xdwriteread_10,
604-
NULL, {10, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xc7,
605-
0, 0, 0, 0, 0, 0} }, /* XDWRITEREAD(10) */
606602
{0, 0x3b, 0, F_D_OUT_MAYBE, resp_write_buffer, NULL,
607603
{10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0, 0,
608604
0, 0, 0, 0} }, /* WRITE_BUFFER */
@@ -1010,11 +1006,11 @@ static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr,
10101006
int arr_len)
10111007
{
10121008
int act_len;
1013-
struct scsi_data_buffer *sdb = scsi_in(scp);
1009+
struct scsi_data_buffer *sdb = &scp->sdb;
10141010

10151011
if (!sdb->length)
10161012
return 0;
1017-
if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_FROM_DEVICE))
1013+
if (scp->sc_data_direction != DMA_FROM_DEVICE)
10181014
return DID_ERROR << 16;
10191015

10201016
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,
10331029
int arr_len, unsigned int off_dst)
10341030
{
10351031
int act_len, n;
1036-
struct scsi_data_buffer *sdb = scsi_in(scp);
1032+
struct scsi_data_buffer *sdb = &scp->sdb;
10371033
off_t skip = off_dst;
10381034

10391035
if (sdb->length <= off_dst)
10401036
return 0;
1041-
if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_FROM_DEVICE))
1037+
if (scp->sc_data_direction != DMA_FROM_DEVICE)
10421038
return DID_ERROR << 16;
10431039

10441040
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,
10581054
{
10591055
if (!scsi_bufflen(scp))
10601056
return 0;
1061-
if (!(scsi_bidi_cmnd(scp) || scp->sc_data_direction == DMA_TO_DEVICE))
1057+
if (scp->sc_data_direction != DMA_TO_DEVICE)
10621058
return -1;
10631059

10641060
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,
24772473
{
24782474
int ret;
24792475
u64 block, rest = 0;
2480-
struct scsi_data_buffer *sdb;
2476+
struct scsi_data_buffer *sdb = &scmd->sdb;
24812477
enum dma_data_direction dir;
24822478

24832479
if (do_write) {
2484-
sdb = scsi_out(scmd);
24852480
dir = DMA_TO_DEVICE;
24862481
write_since_sync = true;
24872482
} else {
2488-
sdb = scsi_in(scmd);
24892483
dir = DMA_FROM_DEVICE;
24902484
}
24912485

24922486
if (!sdb->length)
24932487
return 0;
2494-
if (!(scsi_bidi_cmnd(scmd) || scmd->sc_data_direction == dir))
2488+
if (scmd->sc_data_direction != dir)
24952489
return -1;
24962490

24972491
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)
27742768
if (unlikely(ret == -1))
27752769
return DID_ERROR << 16;
27762770

2777-
scsi_in(scp)->resid = scsi_bufflen(scp) - ret;
2771+
scp->sdb.resid = scsi_bufflen(scp) - ret;
27782772

27792773
if (unlikely(sqcp)) {
27802774
if (sqcp->inj_recovered) {
@@ -3718,68 +3712,6 @@ static int resp_report_luns(struct scsi_cmnd *scp,
37183712
return res;
37193713
}
37203714

3721-
static int resp_xdwriteread(struct scsi_cmnd *scp, unsigned long long lba,
3722-
unsigned int num, struct sdebug_dev_info *devip)
3723-
{
3724-
int j;
3725-
unsigned char *kaddr, *buf;
3726-
unsigned int offset;
3727-
struct scsi_data_buffer *sdb = scsi_in(scp);
3728-
struct sg_mapping_iter miter;
3729-
3730-
/* better not to use temporary buffer. */
3731-
buf = kzalloc(scsi_bufflen(scp), GFP_ATOMIC);
3732-
if (!buf) {
3733-
mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC,
3734-
INSUFF_RES_ASCQ);
3735-
return check_condition_result;
3736-
}
3737-
3738-
scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp));
3739-
3740-
offset = 0;
3741-
sg_miter_start(&miter, sdb->table.sgl, sdb->table.nents,
3742-
SG_MITER_ATOMIC | SG_MITER_TO_SG);
3743-
3744-
while (sg_miter_next(&miter)) {
3745-
kaddr = miter.addr;
3746-
for (j = 0; j < miter.length; j++)
3747-
*(kaddr + j) ^= *(buf + offset + j);
3748-
3749-
offset += miter.length;
3750-
}
3751-
sg_miter_stop(&miter);
3752-
kfree(buf);
3753-
3754-
return 0;
3755-
}
3756-
3757-
static int resp_xdwriteread_10(struct scsi_cmnd *scp,
3758-
struct sdebug_dev_info *devip)
3759-
{
3760-
u8 *cmd = scp->cmnd;
3761-
u64 lba;
3762-
u32 num;
3763-
int errsts;
3764-
3765-
if (!scsi_bidi_cmnd(scp)) {
3766-
mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC,
3767-
INSUFF_RES_ASCQ);
3768-
return check_condition_result;
3769-
}
3770-
errsts = resp_read_dt0(scp, devip);
3771-
if (errsts)
3772-
return errsts;
3773-
if (!(cmd[1] & 0x4)) { /* DISABLE_WRITE is not set */
3774-
errsts = resp_write_dt0(scp, devip);
3775-
if (errsts)
3776-
return errsts;
3777-
}
3778-
lba = get_unaligned_be32(cmd + 2);
3779-
num = get_unaligned_be16(cmd + 7);
3780-
return resp_xdwriteread(scp, lba, num, devip);
3781-
}
3782-
37833715
static struct sdebug_queue *get_queue(struct scsi_cmnd *cmnd)
37843716
{
37853717
u32 tag = blk_mq_unique_tag(cmnd->request);
@@ -3953,7 +3885,6 @@ static int scsi_debug_slave_alloc(struct scsi_device *sdp)
39533885
if (sdebug_verbose)
39543886
pr_info("slave_alloc <%u %u %u %llu>\n",
39553887
sdp->host->host_no, sdp->channel, sdp->id, sdp->lun);
3956-
blk_queue_flag_set(QUEUE_FLAG_BIDI, sdp->request_queue);
39573888
return 0;
39583889
}
39593890

0 commit comments

Comments
 (0)