Commit 1ee8e889 authored by Bart Van Assche's avatar Bart Van Assche Committed by Christoph Hellwig

scsi: add support for multiple hardware queues in scsi_(host_)find_tag

Modify scsi_find_tag() and scsi_host_find_tag() such that these
functions can translate a tag generated by blk_mq_unique_tag().
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent efec4b90
...@@ -111,18 +111,21 @@ static inline int scsi_populate_tag_msg(struct scsi_cmnd *cmd, char *msg) ...@@ -111,18 +111,21 @@ static inline int scsi_populate_tag_msg(struct scsi_cmnd *cmd, char *msg)
} }
static inline struct scsi_cmnd *scsi_mq_find_tag(struct Scsi_Host *shost, static inline struct scsi_cmnd *scsi_mq_find_tag(struct Scsi_Host *shost,
unsigned int hw_ctx, int tag) int unique_tag)
{ {
struct request *req; u16 hwq = blk_mq_unique_tag_to_hwq(unique_tag);
struct request *req = NULL;
req = blk_mq_tag_to_rq(shost->tag_set.tags[hw_ctx], tag); if (hwq < shost->tag_set.nr_hw_queues)
req = blk_mq_tag_to_rq(shost->tag_set.tags[hwq],
blk_mq_unique_tag_to_tag(unique_tag));
return req ? (struct scsi_cmnd *)req->special : NULL; return req ? (struct scsi_cmnd *)req->special : NULL;
} }
/** /**
* scsi_find_tag - find a tagged command by device * scsi_find_tag - find a tagged command by device
* @SDpnt: pointer to the ScSI device * @SDpnt: pointer to the ScSI device
* @tag: the tag number * @tag: tag generated by blk_mq_unique_tag()
* *
* Notes: * Notes:
* Only works with tags allocated by the generic blk layer. * Only works with tags allocated by the generic blk layer.
...@@ -133,9 +136,9 @@ static inline struct scsi_cmnd *scsi_find_tag(struct scsi_device *sdev, int tag) ...@@ -133,9 +136,9 @@ static inline struct scsi_cmnd *scsi_find_tag(struct scsi_device *sdev, int tag)
if (tag != SCSI_NO_TAG) { if (tag != SCSI_NO_TAG) {
if (shost_use_blk_mq(sdev->host)) if (shost_use_blk_mq(sdev->host))
return scsi_mq_find_tag(sdev->host, 0, tag); return scsi_mq_find_tag(sdev->host, tag);
req = blk_queue_find_tag(sdev->request_queue, tag); req = blk_queue_find_tag(sdev->request_queue, tag);
return req ? (struct scsi_cmnd *)req->special : NULL; return req ? (struct scsi_cmnd *)req->special : NULL;
} }
...@@ -174,7 +177,7 @@ static inline int scsi_init_shared_tag_map(struct Scsi_Host *shost, int depth) ...@@ -174,7 +177,7 @@ static inline int scsi_init_shared_tag_map(struct Scsi_Host *shost, int depth)
/** /**
* scsi_host_find_tag - find the tagged command by host * scsi_host_find_tag - find the tagged command by host
* @shost: pointer to scsi_host * @shost: pointer to scsi_host
* @tag: tag of the scsi_cmnd * @tag: tag generated by blk_mq_unique_tag()
* *
* Notes: * Notes:
* Only works with tags allocated by the generic blk layer. * Only works with tags allocated by the generic blk layer.
...@@ -186,7 +189,7 @@ static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost, ...@@ -186,7 +189,7 @@ static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
if (tag != SCSI_NO_TAG) { if (tag != SCSI_NO_TAG) {
if (shost_use_blk_mq(shost)) if (shost_use_blk_mq(shost))
return scsi_mq_find_tag(shost, 0, tag); return scsi_mq_find_tag(shost, tag);
req = blk_map_queue_find_tag(shost->bqt, tag); req = blk_map_queue_find_tag(shost->bqt, tag);
return req ? (struct scsi_cmnd *)req->special : NULL; return req ? (struct scsi_cmnd *)req->special : NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment