|
29 | 29 | #include <scsi/scsi_device.h>
|
30 | 30 | #include <scsi/scsi_cmnd.h>
|
31 | 31 | #include <scsi/scsi_tcq.h>
|
| 32 | +#include <scsi/scsi_devinfo.h> |
32 | 33 | #include <linux/seqlock.h>
|
33 | 34 | #include <linux/blk-mq-virtio.h>
|
34 | 35 |
|
@@ -705,6 +706,28 @@ static int virtscsi_device_reset(struct scsi_cmnd *sc)
|
705 | 706 | return virtscsi_tmf(vscsi, cmd);
|
706 | 707 | }
|
707 | 708 |
|
| 709 | +static int virtscsi_device_alloc(struct scsi_device *sdevice) |
| 710 | +{ |
| 711 | + /* |
| 712 | + * Passed through SCSI targets (e.g. with qemu's 'scsi-block') |
| 713 | + * may have transfer limits which come from the host SCSI |
| 714 | + * controller or something on the host side other than the |
| 715 | + * target itself. |
| 716 | + * |
| 717 | + * To make this work properly, the hypervisor can adjust the |
| 718 | + * target's VPD information to advertise these limits. But |
| 719 | + * for that to work, the guest has to look at the VPD pages, |
| 720 | + * which we won't do by default if it is an SPC-2 device, even |
| 721 | + * if it does actually support it. |
| 722 | + * |
| 723 | + * So, set the blist to always try to read the VPD pages. |
| 724 | + */ |
| 725 | + sdevice->sdev_bflags = BLIST_TRY_VPD_PAGES; |
| 726 | + |
| 727 | + return 0; |
| 728 | +} |
| 729 | + |
| 730 | + |
708 | 731 | /**
|
709 | 732 | * virtscsi_change_queue_depth() - Change a virtscsi target's queue depth
|
710 | 733 | * @sdev: Virtscsi target whose queue depth to change
|
@@ -783,6 +806,7 @@ static struct scsi_host_template virtscsi_host_template_single = {
|
783 | 806 | .change_queue_depth = virtscsi_change_queue_depth,
|
784 | 807 | .eh_abort_handler = virtscsi_abort,
|
785 | 808 | .eh_device_reset_handler = virtscsi_device_reset,
|
| 809 | + .slave_alloc = virtscsi_device_alloc, |
786 | 810 |
|
787 | 811 | .can_queue = 1024,
|
788 | 812 | .dma_boundary = UINT_MAX,
|
|
0 commit comments