linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio_scsi: Always try to read VPD pages
@ 2017-04-13  2:13 David Gibson
  2017-04-13 13:39 ` Stefan Hajnoczi
  2017-04-19 23:12 ` Martin K. Petersen
  0 siblings, 2 replies; 4+ messages in thread
From: David Gibson @ 2017-04-13  2:13 UTC (permalink / raw)
  To: stefanha, pbonzini, famz
  Cc: jejb, martin.petersen, linux-scsi, linux-kernel, David Gibson

Passed through SCSI targets may have transfer limits which come from the
host SCSI controller something on the host side other than the target
itself.

To make this work properly, the hypervisor can adjust the target's VPD
information to advertise these limits.  But for that to work, the guest has
to look at the VPD pages, which we won't do by default if it is an SPC-2
device, even if it does actually support it.

This adds a workaround to address this, forcing devices attached to a
virtio-scsi controller to always check the VPD pages.  This is modelled on
a similar workaround for the storvsc (Hyper-V) SCSI controller, although
that exists for slightly different reasons.

A specific case which causes this is a volume from IBM's IPR RAID
controller (which presents as an SPC-2 device, although it does support
VPD) passed through with qemu's 'scsi-block' device.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 drivers/scsi/virtio_scsi.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 939c47d..961a1fc 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -29,6 +29,7 @@
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_tcq.h>
+#include <scsi/scsi_devinfo.h>
 #include <linux/seqlock.h>
 #include <linux/blk-mq-virtio.h>
 
@@ -705,6 +706,28 @@ static int virtscsi_device_reset(struct scsi_cmnd *sc)
 	return virtscsi_tmf(vscsi, cmd);
 }
 
+static int virtscsi_device_alloc(struct scsi_device *sdevice)
+{
+	/*
+	 * Passed through SCSI targets (e.g. with qemu's 'scsi-block')
+	 * may have transfer limits which come from the host SCSI
+	 * controller something on the host side other than the target
+	 * itself.
+	 *
+	 * To make this work properly, the hypervisor can adjust the
+	 * target's VPD information to advertise these limits.  But
+	 * for that to work, the guest has to look at the VPD pages,
+	 * which we won't do by default if it is an SPC-2 device, even
+	 * if it does actually support it.
+	 *
+	 * So, set the blist to always try to read the VPD pages.
+	 */
+	sdevice->sdev_bflags = BLIST_TRY_VPD_PAGES;
+
+	return 0;
+}
+
+
 /**
  * virtscsi_change_queue_depth() - Change a virtscsi target's queue depth
  * @sdev:	Virtscsi target whose queue depth to change
@@ -783,6 +806,7 @@ static struct scsi_host_template virtscsi_host_template_single = {
 	.change_queue_depth = virtscsi_change_queue_depth,
 	.eh_abort_handler = virtscsi_abort,
 	.eh_device_reset_handler = virtscsi_device_reset,
+	.slave_alloc = virtscsi_device_alloc,
 
 	.can_queue = 1024,
 	.dma_boundary = UINT_MAX,
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] virtio_scsi: Always try to read VPD pages
  2017-04-13  2:13 [PATCH] virtio_scsi: Always try to read VPD pages David Gibson
@ 2017-04-13 13:39 ` Stefan Hajnoczi
  2017-04-19 14:57   ` Paolo Bonzini
  2017-04-19 23:12 ` Martin K. Petersen
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2017-04-13 13:39 UTC (permalink / raw)
  To: David Gibson
  Cc: pbonzini, famz, jejb, martin.petersen, linux-scsi, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1120 bytes --]

On Thu, Apr 13, 2017 at 12:13:00PM +1000, David Gibson wrote:
> @@ -705,6 +706,28 @@ static int virtscsi_device_reset(struct scsi_cmnd *sc)
>  	return virtscsi_tmf(vscsi, cmd);
>  }
>  
> +static int virtscsi_device_alloc(struct scsi_device *sdevice)
> +{
> +	/*
> +	 * Passed through SCSI targets (e.g. with qemu's 'scsi-block')
> +	 * may have transfer limits which come from the host SCSI
> +	 * controller something on the host side other than the target

s/controller something/controller or something/ ?

> +	 * itself.
> +	 *
> +	 * To make this work properly, the hypervisor can adjust the
> +	 * target's VPD information to advertise these limits.  But
> +	 * for that to work, the guest has to look at the VPD pages,
> +	 * which we won't do by default if it is an SPC-2 device, even
> +	 * if it does actually support it.
> +	 *
> +	 * So, set the blist to always try to read the VPD pages.
> +	 */
> +	sdevice->sdev_bflags = BLIST_TRY_VPD_PAGES;
> +
> +	return 0;
> +}

Looks good to me.  Not a SCSI expert but I checked
scsi_device_supports_vpd() callers and this seems sane.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] virtio_scsi: Always try to read VPD pages
  2017-04-13 13:39 ` Stefan Hajnoczi
@ 2017-04-19 14:57   ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2017-04-19 14:57 UTC (permalink / raw)
  To: Stefan Hajnoczi, David Gibson
  Cc: famz, jejb, martin.petersen, linux-scsi, linux-kernel



On 13/04/2017 15:39, Stefan Hajnoczi wrote:
> On Thu, Apr 13, 2017 at 12:13:00PM +1000, David Gibson wrote:
>> @@ -705,6 +706,28 @@ static int virtscsi_device_reset(struct scsi_cmnd *sc)
>>  	return virtscsi_tmf(vscsi, cmd);
>>  }
>>  
>> +static int virtscsi_device_alloc(struct scsi_device *sdevice)
>> +{
>> +	/*
>> +	 * Passed through SCSI targets (e.g. with qemu's 'scsi-block')
>> +	 * may have transfer limits which come from the host SCSI
>> +	 * controller something on the host side other than the target
> 
> s/controller something/controller or something/ ?

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

with this change.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] virtio_scsi: Always try to read VPD pages
  2017-04-13  2:13 [PATCH] virtio_scsi: Always try to read VPD pages David Gibson
  2017-04-13 13:39 ` Stefan Hajnoczi
@ 2017-04-19 23:12 ` Martin K. Petersen
  1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2017-04-19 23:12 UTC (permalink / raw)
  To: David Gibson
  Cc: stefanha, pbonzini, famz, jejb, martin.petersen, linux-scsi,
	linux-kernel


David,

> Passed through SCSI targets may have transfer limits which come from
> the host SCSI controller something on the host side other than the
> target itself.
>
> To make this work properly, the hypervisor can adjust the target's VPD
> information to advertise these limits.  But for that to work, the
> guest has to look at the VPD pages, which we won't do by default if it
> is an SPC-2 device, even if it does actually support it.

Applied to 4.12/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-19 23:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-13  2:13 [PATCH] virtio_scsi: Always try to read VPD pages David Gibson
2017-04-13 13:39 ` Stefan Hajnoczi
2017-04-19 14:57   ` Paolo Bonzini
2017-04-19 23:12 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).