@@ -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)
@@ -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
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@redhat.com> --- drivers/scsi/scsi_lib.c | 14 ++++++++++++++ include/scsi/scsi_host.h | 10 ++++++++++ 2 files changed, 24 insertions(+)