OSDN Git Service

scsi: core: add support for request batching
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 30 May 2019 11:28:10 +0000 (13:28 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 22 Jul 2019 20:44:07 +0000 (16:44 -0400)
commit8930a6c207918d5a5675eedab06a71096b1a3d47
treeddb7520a1e2648e3cd50530a145ea5e0ee11e913
parentcf949bbe22bee8749078e0b810ee2dc60a983746
scsi: core: add support for request batching

This allows a list of requests to be issued, with the LLD only writing the
hardware doorbell when necessary, after the last request was prepared.
This is more efficient if we have lists of requests to issue, particularly
on virtualized hardware, where writing the doorbell is more expensive than
on real hardware.

The use case for this is plugged IO, where blk-mq flushes a batch of
requests all at once.

The API is the same as for blk-mq, just with blk-mq concepts tweaked to
fit the SCSI subsystem API: the "last" flag in blk_mq_queue_data becomes a
flag in scsi_cmnd, while the queue_num in the commit_rqs callback is
extracted from the hctx and passed as a parameter.

The only complication is that blk-mq uses different plugging heuristics
depending on whether commit_rqs is present or not.  So we have two
different sets of blk_mq_ops and pick one depending on whether the
scsi_host template uses commit_rqs or not.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_lib.c
include/scsi/scsi_cmnd.h
include/scsi/scsi_host.h