diff mbox series

[v3,4/4] scsi: set shost as hctx driver_data

Message ID 20210201051619.19909-5-kashyap.desai@broadcom.com
State New
Headers show
Series io_uring iopoll in scsi layer | expand

Commit Message

Kashyap Desai Feb. 1, 2021, 5:16 a.m. UTC
hctx->driver_data is not set for SCSI currently.
Separately set hctx->driver_data = shost.

Suggested-by: John Garry <john.garry@huawei.com>
Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Reviewed-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/scsi_lib.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

Comments

Hannes Reinecke March 1, 2021, 7:30 a.m. UTC | #1
On 2/1/21 6:16 AM, Kashyap Desai wrote:
> hctx->driver_data is not set for SCSI currently.

> Separately set hctx->driver_data = shost.

> 

> Suggested-by: John Garry <john.garry@huawei.com>

> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>

> Reviewed-by: John Garry <john.garry@huawei.com>

> ---

>   drivers/scsi/scsi_lib.c | 19 +++++++++++++------

>   1 file changed, 13 insertions(+), 6 deletions(-)

> 

> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c

> index 8c29bf0e4cfd..f661c50f3b88 100644

> --- a/drivers/scsi/scsi_lib.c

> +++ b/drivers/scsi/scsi_lib.c

> @@ -1792,9 +1792,7 @@ static void scsi_mq_exit_request(struct blk_mq_tag_set *set, struct request *rq,

>   

>   static int scsi_mq_poll(struct blk_mq_hw_ctx *hctx)

>   {

> -	struct request_queue *q = hctx->queue;

> -	struct scsi_device *sdev = q->queuedata;

> -	struct Scsi_Host *shost = sdev->host;

> +	struct Scsi_Host *shost = hctx->driver_data;

>   

>   	if (shost->hostt->mq_poll)

>   		return shost->hostt->mq_poll(shost, hctx->queue_num);

> @@ -1802,6 +1800,15 @@ static int scsi_mq_poll(struct blk_mq_hw_ctx *hctx)

>   	return 0;

>   }

>   

> +static int scsi_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,

> +			  unsigned int hctx_idx)

> +{

> +	struct Scsi_Host *shost = data;

> +

> +	hctx->driver_data = shost;

> +	return 0;

> +}

> +

>   static int scsi_map_queues(struct blk_mq_tag_set *set)

>   {

>   	struct Scsi_Host *shost = container_of(set, struct Scsi_Host, tag_set);

> @@ -1869,15 +1876,14 @@ static const struct blk_mq_ops scsi_mq_ops_no_commit = {

>   	.cleanup_rq	= scsi_cleanup_rq,

>   	.busy		= scsi_mq_lld_busy,

>   	.map_queues	= scsi_map_queues,

> +	.init_hctx	= scsi_init_hctx,

>   	.poll		= scsi_mq_poll,

>   };

>   

>   

>   static void scsi_commit_rqs(struct blk_mq_hw_ctx *hctx)

>   {

> -	struct request_queue *q = hctx->queue;

> -	struct scsi_device *sdev = q->queuedata;

> -	struct Scsi_Host *shost = sdev->host;

> +	struct Scsi_Host *shost = hctx->driver_data;

>   

>   	shost->hostt->commit_rqs(shost, hctx->queue_num);

>   }

> @@ -1898,6 +1904,7 @@ static const struct blk_mq_ops scsi_mq_ops = {

>   	.cleanup_rq	= scsi_cleanup_rq,

>   	.busy		= scsi_mq_lld_busy,

>   	.map_queues	= scsi_map_queues,

> +	.init_hctx	= scsi_init_hctx,

>   	.poll		= scsi_mq_poll,

>   };

>   

> 

Reviewed-by: Hannes Reinecke <hare@suse.de>


Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 8c29bf0e4cfd..f661c50f3b88 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1792,9 +1792,7 @@  static void scsi_mq_exit_request(struct blk_mq_tag_set *set, struct request *rq,
 
 static int scsi_mq_poll(struct blk_mq_hw_ctx *hctx)
 {
-	struct request_queue *q = hctx->queue;
-	struct scsi_device *sdev = q->queuedata;
-	struct Scsi_Host *shost = sdev->host;
+	struct Scsi_Host *shost = hctx->driver_data;
 
 	if (shost->hostt->mq_poll)
 		return shost->hostt->mq_poll(shost, hctx->queue_num);
@@ -1802,6 +1800,15 @@  static int scsi_mq_poll(struct blk_mq_hw_ctx *hctx)
 	return 0;
 }
 
+static int scsi_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
+			  unsigned int hctx_idx)
+{
+	struct Scsi_Host *shost = data;
+
+	hctx->driver_data = shost;
+	return 0;
+}
+
 static int scsi_map_queues(struct blk_mq_tag_set *set)
 {
 	struct Scsi_Host *shost = container_of(set, struct Scsi_Host, tag_set);
@@ -1869,15 +1876,14 @@  static const struct blk_mq_ops scsi_mq_ops_no_commit = {
 	.cleanup_rq	= scsi_cleanup_rq,
 	.busy		= scsi_mq_lld_busy,
 	.map_queues	= scsi_map_queues,
+	.init_hctx	= scsi_init_hctx,
 	.poll		= scsi_mq_poll,
 };
 
 
 static void scsi_commit_rqs(struct blk_mq_hw_ctx *hctx)
 {
-	struct request_queue *q = hctx->queue;
-	struct scsi_device *sdev = q->queuedata;
-	struct Scsi_Host *shost = sdev->host;
+	struct Scsi_Host *shost = hctx->driver_data;
 
 	shost->hostt->commit_rqs(shost, hctx->queue_num);
 }
@@ -1898,6 +1904,7 @@  static const struct blk_mq_ops scsi_mq_ops = {
 	.cleanup_rq	= scsi_cleanup_rq,
 	.busy		= scsi_mq_lld_busy,
 	.map_queues	= scsi_map_queues,
+	.init_hctx	= scsi_init_hctx,
 	.poll		= scsi_mq_poll,
 };