[PATCH V2 3/5] scsi: core: implement callback of .complete_queue_affinity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Implement scsi core's callback of .complete_queue_affinity for
supporting to drain in-flight requests in case that SCSI HBA
supports multiple completion queue.

Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
---
 drivers/scsi/scsi_lib.c  | 14 ++++++++++++++
 include/scsi/scsi_host.h | 10 ++++++++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 65d0a10c76ad..ac57dc98a8c0 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1750,6 +1750,19 @@ static int scsi_map_queues(struct blk_mq_tag_set *set)
 	return blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]);
 }
 
+static const struct cpumask *
+scsi_complete_queue_affinity(struct blk_mq_hw_ctx *hctx, int cpu)
+{
+	struct request_queue *q = hctx->queue;
+	struct scsi_device *sdev = q->queuedata;
+	struct Scsi_Host *shost = sdev->host;
+
+	if (shost->hostt->complete_queue_affinity)
+		return shost->hostt->complete_queue_affinity(shost, cpu);
+
+	return NULL;
+}
+
 void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
 {
 	struct device *dev = shost->dma_dev;
@@ -1802,6 +1815,7 @@ static const struct blk_mq_ops scsi_mq_ops = {
 	.initialize_rq_fn = scsi_initialize_rq,
 	.busy		= scsi_mq_lld_busy,
 	.map_queues	= scsi_map_queues,
+	.complete_queue_affinity = scsi_complete_queue_affinity,
 };
 
 struct request_queue *scsi_mq_alloc_queue(struct scsi_device *sdev)
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index a5fcdad4a03e..65ccac1429a1 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -268,6 +268,16 @@ struct scsi_host_template {
 	 */
 	int (* map_queues)(struct Scsi_Host *shost);
 
+	/*
+	 * This functions lets the driver expose complete queue's cpu
+	 * affinity to the block layer. @cpu is used for retrieving
+	 * the mapped completion queue.
+	 *
+	 * Status: OPTIONAL
+	 */
+	const struct cpumask * (* complete_queue_affinity)(struct Scsi_Host *,
+							   int cpu);
+
 	/*
 	 * This function determines the BIOS parameters for a given
 	 * harddisk.  These tend to be numbers that are made up by
-- 
2.20.1




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux