Re: [PATCH 1/2] scsi_host: add support for request batching

From: Paolo Bonzini
Date: Thu May 30 2019 - 11:58:31 EST


On 30/05/19 17:36, Bart Van Assche wrote:
> On 5/30/19 4:28 AM, Paolo Bonzini wrote:
>> +static const struct blk_mq_ops scsi_mq_ops_no_commit = {
>> +ÂÂÂ .get_budgetÂÂÂ = scsi_mq_get_budget,
>> +ÂÂÂ .put_budgetÂÂÂ = scsi_mq_put_budget,
>> +ÂÂÂ .queue_rqÂÂÂ = scsi_queue_rq,
>> +ÂÂÂ .completeÂÂÂ = scsi_softirq_done,
>> +ÂÂÂ .timeoutÂÂÂ = scsi_timeout,
>> +#ifdef CONFIG_BLK_DEBUG_FS
>> +ÂÂÂ .show_rqÂÂÂ = scsi_show_rq,
>> +#endif
>> +ÂÂÂ .init_requestÂÂÂ = scsi_mq_init_request,
>> +ÂÂÂ .exit_requestÂÂÂ = scsi_mq_exit_request,
>> +ÂÂÂ .initialize_rq_fn = scsi_initialize_rq,
>> +ÂÂÂ .busyÂÂÂÂÂÂÂ = scsi_mq_lld_busy,
>> +ÂÂÂ .map_queuesÂÂÂ = scsi_map_queues,
>> +};
>> +
>> +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;
>> +
>> +ÂÂÂ shost->hostt->commit_rqs(shost, hctx->queue_num);
>> +}
>> +
>> Â static const struct blk_mq_ops scsi_mq_ops = {
>> ÂÂÂÂÂ .get_budgetÂÂÂ = scsi_mq_get_budget,
>> ÂÂÂÂÂ .put_budgetÂÂÂ = scsi_mq_put_budget,
>> ÂÂÂÂÂ .queue_rqÂÂÂ = scsi_queue_rq,
>> +ÂÂÂ .commit_rqsÂÂÂ = scsi_commit_rqs,
>> ÂÂÂÂÂ .completeÂÂÂ = scsi_softirq_done,
>> ÂÂÂÂÂ .timeoutÂÂÂ = scsi_timeout,
>> Â #ifdef CONFIG_BLK_DEBUG_FS
>
> Hi Paolo,
>
> Have you considered to modify the block layer such that a single
> scsi_mq_ops structure can be used for all SCSI LLD types?

Yes, but I don't think it's possible to do it in a nice way.
Any adjustment we make to the block layer to fit the SCSI subsystem's
desires would make all other block drivers uglier, so I chose to confine
the ugliness here.

The root issue is that the SCSI subsystem is unique in how it sits on
top of the block layer; this is the famous "adapter" (or "midlayer",
though that is confusing when talking about SCSI) design that Linux
usually tries to avoid.

Paolo