Skip to content

Commit 59057fb

Browse files
Nicholas BellingerJames Bottomley
authored andcommitted
[SCSI] virtio-scsi: Add vdrv->scan for post VIRTIO_CONFIG_S_DRIVER_OK LUN scanning
This patch changes virtio-scsi to use a new virtio_driver->scan() callback so that scsi_scan_host() can be properly invoked once virtio_dev_probe() has set add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK) to signal active virtio-ring operation, instead of from within virtscsi_probe(). This fixes a bug where SCSI LUN scanning for both virtio-scsi-raw and virtio-scsi/tcm_vhost setups was happening before VIRTIO_CONFIG_S_DRIVER_OK had been set, causing VIRTIO_SCSI_S_BAD_TARGET to occur. This fixes a bug with virtio-scsi/tcm_vhost where LUN scan was not detecting LUNs. Tested with virtio-scsi-raw + virtio-scsi/tcm_vhost w/ IBLOCK on 3.5-rc2 code. Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent 0b1017a commit 59057fb

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎drivers/scsi/virtio_scsi.c‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,13 @@ static struct virtio_scsi_target_state *virtscsi_alloc_tgt(
571571
return tgt;
572572
}
573573

574+
static void virtscsi_scan(struct virtio_device *vdev)
575+
{
576+
struct Scsi_Host *shost = (struct Scsi_Host *)vdev->priv;
577+
578+
scsi_scan_host(shost);
579+
}
580+
574581
static void virtscsi_remove_vqs(struct virtio_device *vdev)
575582
{
576583
struct Scsi_Host *sh = virtio_scsi_host(vdev);
@@ -677,9 +684,10 @@ static int __devinit virtscsi_probe(struct virtio_device *vdev)
677684
err = scsi_add_host(shost, &vdev->dev);
678685
if (err)
679686
goto scsi_add_host_failed;
680-
681-
scsi_scan_host(shost);
682-
687+
/*
688+
* scsi_scan_host() happens in virtscsi_scan() via virtio_driver->scan()
689+
* after VIRTIO_CONFIG_S_DRIVER_OK has been set..
690+
*/
683691
return 0;
684692

685693
scsi_add_host_failed:
@@ -735,6 +743,7 @@ static struct virtio_driver virtio_scsi_driver = {
735743
.driver.owner = THIS_MODULE,
736744
.id_table = id_table,
737745
.probe = virtscsi_probe,
746+
.scan = virtscsi_scan,
738747
#ifdef CONFIG_PM
739748
.freeze = virtscsi_freeze,
740749
.restore = virtscsi_restore,

‎drivers/virtio/virtio.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,11 @@ static int virtio_dev_probe(struct device *_d)
141141
err = drv->probe(dev);
142142
if (err)
143143
add_status(dev, VIRTIO_CONFIG_S_FAILED);
144-
else
144+
else {
145145
add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
146+
if (drv->scan)
147+
drv->scan(dev);
148+
}
146149

147150
return err;
148151
}

‎include/linux/virtio.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ struct virtio_driver {
9292
const unsigned int *feature_table;
9393
unsigned int feature_table_size;
9494
int (*probe)(struct virtio_device *dev);
95+
void (*scan)(struct virtio_device *dev);
9596
void (*remove)(struct virtio_device *dev);
9697
void (*config_changed)(struct virtio_device *dev);
9798
#ifdef CONFIG_PM

0 commit comments

Comments
 (0)