@@ -821,8 +821,6 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch)
821821 dma_addr_t dma_addr ;
822822 int i , ret = - ENOMEM ;
823823
824- INIT_LIST_HEAD (& ch -> free_reqs );
825-
826824 ch -> req_ring = kcalloc (target -> req_ring_size , sizeof (* ch -> req_ring ),
827825 GFP_KERNEL );
828826 if (!ch -> req_ring )
@@ -853,8 +851,6 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch)
853851 goto out ;
854852
855853 req -> indirect_dma_addr = dma_addr ;
856- req -> index = i ;
857- list_add_tail (& req -> list , & ch -> free_reqs );
858854 }
859855 ret = 0 ;
860856
@@ -1076,7 +1072,6 @@ static void srp_free_req(struct srp_rdma_ch *ch, struct srp_request *req,
10761072
10771073 spin_lock_irqsave (& ch -> lock , flags );
10781074 ch -> req_lim += req_lim_delta ;
1079- list_add_tail (& req -> list , & ch -> free_reqs );
10801075 spin_unlock_irqrestore (& ch -> lock , flags );
10811076}
10821077
@@ -1648,8 +1643,11 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp)
16481643 ch -> tsk_mgmt_status = rsp -> data [3 ];
16491644 complete (& ch -> tsk_mgmt_done );
16501645 } else {
1651- req = & ch -> req_ring [rsp -> tag ];
1652- scmnd = srp_claim_req (ch , req , NULL , NULL );
1646+ scmnd = scsi_host_find_tag (target -> scsi_host , rsp -> tag );
1647+ if (scmnd ) {
1648+ req = (void * )scmnd -> host_scribble ;
1649+ scmnd = srp_claim_req (ch , req , NULL , scmnd );
1650+ }
16531651 if (!scmnd ) {
16541652 shost_printk (KERN_ERR , target -> scsi_host ,
16551653 "Null scmnd for RSP w/tag %016llx\n" ,
@@ -1889,6 +1887,8 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
18891887 struct srp_cmd * cmd ;
18901888 struct ib_device * dev ;
18911889 unsigned long flags ;
1890+ u32 tag ;
1891+ u16 idx ;
18921892 int len , ret ;
18931893 const bool in_scsi_eh = !in_interrupt () && current == shost -> ehandler ;
18941894
@@ -1905,17 +1905,22 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
19051905 if (unlikely (scmnd -> result ))
19061906 goto err ;
19071907
1908+ WARN_ON_ONCE (scmnd -> request -> tag < 0 );
1909+ tag = blk_mq_unique_tag (scmnd -> request );
19081910 ch = & target -> ch ;
1911+ idx = blk_mq_unique_tag_to_tag (tag );
1912+ WARN_ONCE (idx >= target -> req_ring_size , "%s: tag %#x: idx %d >= %d\n" ,
1913+ dev_name (& shost -> shost_gendev ), tag , idx ,
1914+ target -> req_ring_size );
19091915
19101916 spin_lock_irqsave (& ch -> lock , flags );
19111917 iu = __srp_get_tx_iu (ch , SRP_IU_CMD );
1912- if (!iu )
1913- goto err_unlock ;
1914-
1915- req = list_first_entry (& ch -> free_reqs , struct srp_request , list );
1916- list_del (& req -> list );
19171918 spin_unlock_irqrestore (& ch -> lock , flags );
19181919
1920+ if (!iu )
1921+ goto err ;
1922+
1923+ req = & ch -> req_ring [idx ];
19191924 dev = target -> srp_host -> srp_dev -> dev ;
19201925 ib_dma_sync_single_for_cpu (dev , iu -> dma , target -> max_iu_len ,
19211926 DMA_TO_DEVICE );
@@ -1927,7 +1932,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
19271932
19281933 cmd -> opcode = SRP_CMD ;
19291934 cmd -> lun = cpu_to_be64 ((u64 ) scmnd -> device -> lun << 48 );
1930- cmd -> tag = req -> index ;
1935+ cmd -> tag = tag ;
19311936 memcpy (cmd -> cdb , scmnd -> cmnd , scmnd -> cmd_len );
19321937
19331938 req -> scmnd = scmnd ;
@@ -1976,12 +1981,6 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
19761981 */
19771982 req -> scmnd = NULL ;
19781983
1979- spin_lock_irqsave (& ch -> lock , flags );
1980- list_add (& req -> list , & ch -> free_reqs );
1981-
1982- err_unlock :
1983- spin_unlock_irqrestore (& ch -> lock , flags );
1984-
19851984err :
19861985 if (scmnd -> result ) {
19871986 scmnd -> scsi_done (scmnd );
@@ -2387,6 +2386,7 @@ static int srp_abort(struct scsi_cmnd *scmnd)
23872386{
23882387 struct srp_target_port * target = host_to_target (scmnd -> device -> host );
23892388 struct srp_request * req = (struct srp_request * ) scmnd -> host_scribble ;
2389+ u32 tag ;
23902390 struct srp_rdma_ch * ch ;
23912391 int ret ;
23922392
@@ -2395,7 +2395,8 @@ static int srp_abort(struct scsi_cmnd *scmnd)
23952395 ch = & target -> ch ;
23962396 if (!req || !srp_claim_req (ch , req , NULL , scmnd ))
23972397 return SUCCESS ;
2398- if (srp_send_tsk_mgmt (ch , req -> index , scmnd -> device -> lun ,
2398+ tag = blk_mq_unique_tag (scmnd -> request );
2399+ if (srp_send_tsk_mgmt (ch , tag , scmnd -> device -> lun ,
23992400 SRP_TSK_ABORT_TASK ) == 0 )
24002401 ret = SUCCESS ;
24012402 else if (target -> rport -> state == SRP_RPORT_LOST )
@@ -2633,7 +2634,8 @@ static struct scsi_host_template srp_template = {
26332634 .this_id = -1 ,
26342635 .cmd_per_lun = SRP_DEFAULT_CMD_SQ_SIZE ,
26352636 .use_clustering = ENABLE_CLUSTERING ,
2636- .shost_attrs = srp_host_attrs
2637+ .shost_attrs = srp_host_attrs ,
2638+ .use_blk_tags = 1 ,
26372639};
26382640
26392641static int srp_sdev_count (struct Scsi_Host * host )
@@ -3054,6 +3056,10 @@ static ssize_t srp_create_target(struct device *dev,
30543056 if (ret )
30553057 goto err ;
30563058
3059+ ret = scsi_init_shared_tag_map (target_host , target_host -> can_queue );
3060+ if (ret )
3061+ goto err ;
3062+
30573063 target -> req_ring_size = target -> queue_size - SRP_TSK_MGMT_SQ_SIZE ;
30583064
30593065 if (!srp_conn_unique (target -> srp_host , target )) {
0 commit comments