diff mbox

[v2,04/12] scsi_tcq.h: Add support for multiple hardware queues

Message ID 5433E4C4.4030104@acm.org (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Bart Van Assche Oct. 7, 2014, 1:04 p.m. UTC
Modify scsi_find_tag() and scsi_host_find_tag() such that these
fuctions can translate a tag generated by blk_mq_unique_tag().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagig@mellanox.com>
---
 include/scsi/scsi_tcq.h | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

Comments

Sagi Grimberg Oct. 19, 2014, 4:12 p.m. UTC | #1
On 10/7/2014 4:04 PM, Bart Van Assche wrote:
> Modify scsi_find_tag() and scsi_host_find_tag() such that these
> fuctions can translate a tag generated by blk_mq_unique_tag().
>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Sagi Grimberg <sagig@mellanox.com>
> ---
>   include/scsi/scsi_tcq.h | 19 +++++++++++--------
>   1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
> index e645835..ea1ca9c 100644
> --- a/include/scsi/scsi_tcq.h
> +++ b/include/scsi/scsi_tcq.h
> @@ -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,
> -		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;
>   }
>
>   /**
>    * scsi_find_tag - find a tagged command by device
>    * @SDpnt:	pointer to the ScSI device
> - * @tag:	the tag number
> + * @tag:	tag generated by blk_mq_unique_tag()
>    *
>    * Notes:
>    *	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)
>
>           if (tag != SCSI_NO_TAG) {
>   		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);

Why is this line different?

>   	        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)
>   /**
>    * scsi_host_find_tag - find the tagged command by host
>    * @shost:	pointer to scsi_host
> - * @tag:	tag of the scsi_cmnd
> + * @tag:	tag generated by blk_mq_unique_tag()
>    *
>    * Notes:
>    *	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,
>
>   	if (tag != SCSI_NO_TAG) {
>   		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);
>   		return req ? (struct scsi_cmnd *)req->special : NULL;
>   	}
>

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bart Van Assche Oct. 20, 2014, 12:01 p.m. UTC | #2
On 10/19/14 18:12, Sagi Grimberg wrote:
> On 10/7/2014 4:04 PM, Bart Van Assche wrote:
>> -            req = blk_queue_find_tag(sdev->request_queue, tag);
>> +        req = blk_queue_find_tag(sdev->request_queue, tag);
>
> Why is this line different?

This is because the indentation has been modified from "8x<space><tab>" 
into "<tab><tab>". I can leave out that change if you want.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christoph Hellwig Oct. 21, 2014, 8:49 a.m. UTC | #3
On Mon, Oct 20, 2014 at 02:01:25PM +0200, Bart Van Assche wrote:
> On 10/19/14 18:12, Sagi Grimberg wrote:
> >On 10/7/2014 4:04 PM, Bart Van Assche wrote:
> >>-            req = blk_queue_find_tag(sdev->request_queue, tag);
> >>+        req = blk_queue_find_tag(sdev->request_queue, tag);
> >
> >Why is this line different?
> 
> This is because the indentation has been modified from "8x<space><tab>" into
> "<tab><tab>". I can leave out that change if you want.

Please keep it.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sagi Grimberg Oct. 21, 2014, 8:59 a.m. UTC | #4
On 10/21/2014 11:49 AM, Christoph Hellwig wrote:
> On Mon, Oct 20, 2014 at 02:01:25PM +0200, Bart Van Assche wrote:
>> On 10/19/14 18:12, Sagi Grimberg wrote:
>>> On 10/7/2014 4:04 PM, Bart Van Assche wrote:
>>>> -            req = blk_queue_find_tag(sdev->request_queue, tag);
>>>> +        req = blk_queue_find_tag(sdev->request_queue, tag);
>>>
>>> Why is this line different?
>>
>> This is because the indentation has been modified from "8x<space><tab>" into
>> "<tab><tab>". I can leave out that change if you want.
>
> Please keep it.
>

I don't have a big objection on this, but the problem with leaving this
stuff is that it tends to screw up git blame...
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Martin K. Petersen Oct. 28, 2014, 2:06 a.m. UTC | #5
>>>>> "Bart" == Bart Van Assche <bvanassche@acm.org> writes:

Bart> Modify scsi_find_tag() and scsi_host_find_tag() such that these
Bart> fuctions can translate a tag generated by blk_mq_unique_tag().

Looks good to me.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
diff mbox

Patch

diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
index e645835..ea1ca9c 100644
--- a/include/scsi/scsi_tcq.h
+++ b/include/scsi/scsi_tcq.h
@@ -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,
-		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;
 }
 
 /**
  * scsi_find_tag - find a tagged command by device
  * @SDpnt:	pointer to the ScSI device
- * @tag:	the tag number
+ * @tag:	tag generated by blk_mq_unique_tag()
  *
  * Notes:
  *	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)
 
         if (tag != SCSI_NO_TAG) {
 		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;
 	}
 
@@ -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
  * @shost:	pointer to scsi_host
- * @tag:	tag of the scsi_cmnd
+ * @tag:	tag generated by blk_mq_unique_tag()
  *
  * Notes:
  *	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,
 
 	if (tag != SCSI_NO_TAG) {
 		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);
 		return req ? (struct scsi_cmnd *)req->special : NULL;
 	}