Commit ccbedf11 authored by Ming Lei's avatar Ming Lei Committed by Christoph Hellwig

virtio_scsi: support multi hw queue of blk-mq

Since virtio_scsi has supported multi virtqueue already,
it is natural to map the virtque to hw-queue of blk-mq.
Signed-off-by: default avatarMing Lei <ming.lei@canonical.com>
Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 4c413128
...@@ -561,6 +561,15 @@ static int virtscsi_queuecommand_single(struct Scsi_Host *sh, ...@@ -561,6 +561,15 @@ static int virtscsi_queuecommand_single(struct Scsi_Host *sh,
return virtscsi_queuecommand(vscsi, &vscsi->req_vqs[0], sc); return virtscsi_queuecommand(vscsi, &vscsi->req_vqs[0], sc);
} }
static struct virtio_scsi_vq *virtscsi_pick_vq_mq(struct virtio_scsi *vscsi,
struct scsi_cmnd *sc)
{
u32 tag = blk_mq_unique_tag(sc->request);
u16 hwq = blk_mq_unique_tag_to_hwq(tag);
return &vscsi->req_vqs[hwq];
}
static struct virtio_scsi_vq *virtscsi_pick_vq(struct virtio_scsi *vscsi, static struct virtio_scsi_vq *virtscsi_pick_vq(struct virtio_scsi *vscsi,
struct virtio_scsi_target_state *tgt) struct virtio_scsi_target_state *tgt)
{ {
...@@ -604,7 +613,12 @@ static int virtscsi_queuecommand_multi(struct Scsi_Host *sh, ...@@ -604,7 +613,12 @@ static int virtscsi_queuecommand_multi(struct Scsi_Host *sh,
struct virtio_scsi *vscsi = shost_priv(sh); struct virtio_scsi *vscsi = shost_priv(sh);
struct virtio_scsi_target_state *tgt = struct virtio_scsi_target_state *tgt =
scsi_target(sc->device)->hostdata; scsi_target(sc->device)->hostdata;
struct virtio_scsi_vq *req_vq = virtscsi_pick_vq(vscsi, tgt); struct virtio_scsi_vq *req_vq;
if (shost_use_blk_mq(sh))
req_vq = virtscsi_pick_vq_mq(vscsi, sc);
else
req_vq = virtscsi_pick_vq(vscsi, tgt);
return virtscsi_queuecommand(vscsi, req_vq, sc); return virtscsi_queuecommand(vscsi, req_vq, sc);
} }
...@@ -981,6 +995,7 @@ static int virtscsi_probe(struct virtio_device *vdev) ...@@ -981,6 +995,7 @@ static int virtscsi_probe(struct virtio_device *vdev)
shost->max_id = num_targets; shost->max_id = num_targets;
shost->max_channel = 0; shost->max_channel = 0;
shost->max_cmd_len = VIRTIO_SCSI_CDB_SIZE; shost->max_cmd_len = VIRTIO_SCSI_CDB_SIZE;
shost->nr_hw_queues = num_queues;
if (virtio_has_feature(vdev, VIRTIO_SCSI_F_T10_PI)) { if (virtio_has_feature(vdev, VIRTIO_SCSI_F_T10_PI)) {
host_prot = SHOST_DIF_TYPE1_PROTECTION | SHOST_DIF_TYPE2_PROTECTION | host_prot = SHOST_DIF_TYPE1_PROTECTION | SHOST_DIF_TYPE2_PROTECTION |
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment