* [PATCH] Rescan the entire target on transport reset when LUN is 0
@ 2020-08-28 12:21 Matej Genci
2020-09-08 14:15 ` Michael S. Tsirkin
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Matej Genci @ 2020-08-28 12:21 UTC (permalink / raw)
To: linux-kernel
Cc: mst, jasowang, pbonzini, stefanha, jejb, martin.petersen,
virtualization, linux-scsi, Felipe Franciosi, Matej Genci
VirtIO 1.0 spec says
The removed and rescan events ... when sent for LUN 0, they MAY
apply to the entire target so the driver can ask the initiator
to rescan the target to detect this.
This change introduces the behaviour described above by scanning the
entire scsi target when LUN is set to 0. This is both a functional and a
performance fix. It aligns the driver with the spec and allows control
planes to hotplug targets with large numbers of LUNs without having to
request a RESCAN for each one of them.
Signed-off-by: Matej Genci <matej@nutanix.com>
Suggested-by: Felipe Franciosi <felipe@nutanix.com>
---
drivers/scsi/virtio_scsi.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index bfec84aacd90..a4b9bc7b4b4a 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -284,7 +284,12 @@ static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi,
switch (virtio32_to_cpu(vscsi->vdev, event->reason)) {
case VIRTIO_SCSI_EVT_RESET_RESCAN:
- scsi_add_device(shost, 0, target, lun);
+ if (lun == 0) {
+ scsi_scan_target(&shost->shost_gendev, 0, target,
+ SCAN_WILD_CARD, SCSI_SCAN_INITIAL);
+ } else {
+ scsi_add_device(shost, 0, target, lun);
+ }
break;
case VIRTIO_SCSI_EVT_RESET_REMOVED:
sdev = scsi_device_lookup(shost, 0, target, lun);
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Rescan the entire target on transport reset when LUN is 0
2020-08-28 12:21 [PATCH] Rescan the entire target on transport reset when LUN is 0 Matej Genci
@ 2020-09-08 14:15 ` Michael S. Tsirkin
2020-09-08 14:22 ` Paolo Bonzini
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2020-09-08 14:15 UTC (permalink / raw)
To: Matej Genci
Cc: linux-kernel, jasowang, pbonzini, stefanha, jejb,
martin.petersen, virtualization, linux-scsi, Felipe Franciosi
On Fri, Aug 28, 2020 at 12:21:35PM +0000, Matej Genci wrote:
> VirtIO 1.0 spec says
> The removed and rescan events ... when sent for LUN 0, they MAY
> apply to the entire target so the driver can ask the initiator
> to rescan the target to detect this.
>
> This change introduces the behaviour described above by scanning the
> entire scsi target when LUN is set to 0. This is both a functional and a
> performance fix. It aligns the driver with the spec and allows control
> planes to hotplug targets with large numbers of LUNs without having to
> request a RESCAN for each one of them.
>
> Signed-off-by: Matej Genci <matej@nutanix.com>
> Suggested-by: Felipe Franciosi <felipe@nutanix.com>
Stefan, Paolo, could you review this pls?
> ---
> drivers/scsi/virtio_scsi.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index bfec84aacd90..a4b9bc7b4b4a 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -284,7 +284,12 @@ static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi,
>
> switch (virtio32_to_cpu(vscsi->vdev, event->reason)) {
> case VIRTIO_SCSI_EVT_RESET_RESCAN:
> - scsi_add_device(shost, 0, target, lun);
> + if (lun == 0) {
> + scsi_scan_target(&shost->shost_gendev, 0, target,
> + SCAN_WILD_CARD, SCSI_SCAN_INITIAL);
> + } else {
> + scsi_add_device(shost, 0, target, lun);
> + }
> break;
> case VIRTIO_SCSI_EVT_RESET_REMOVED:
> sdev = scsi_device_lookup(shost, 0, target, lun);
> --
> 2.20.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Rescan the entire target on transport reset when LUN is 0
2020-08-28 12:21 [PATCH] Rescan the entire target on transport reset when LUN is 0 Matej Genci
2020-09-08 14:15 ` Michael S. Tsirkin
@ 2020-09-08 14:22 ` Paolo Bonzini
2020-09-08 17:53 ` Felipe Franciosi
2020-09-16 1:52 ` Martin K. Petersen
2020-09-22 3:56 ` Martin K. Petersen
3 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2020-09-08 14:22 UTC (permalink / raw)
To: Matej Genci, linux-kernel
Cc: mst, jasowang, stefanha, jejb, martin.petersen, virtualization,
linux-scsi, Felipe Franciosi
On 28/08/20 14:21, Matej Genci wrote:
> VirtIO 1.0 spec says
> The removed and rescan events ... when sent for LUN 0, they MAY
> apply to the entire target so the driver can ask the initiator
> to rescan the target to detect this.
>
> This change introduces the behaviour described above by scanning the
> entire scsi target when LUN is set to 0. This is both a functional and a
> performance fix. It aligns the driver with the spec and allows control
> planes to hotplug targets with large numbers of LUNs without having to
> request a RESCAN for each one of them.
>
> Signed-off-by: Matej Genci <matej@nutanix.com>
> Suggested-by: Felipe Franciosi <felipe@nutanix.com>
> ---
> drivers/scsi/virtio_scsi.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index bfec84aacd90..a4b9bc7b4b4a 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -284,7 +284,12 @@ static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi,
>
> switch (virtio32_to_cpu(vscsi->vdev, event->reason)) {
> case VIRTIO_SCSI_EVT_RESET_RESCAN:
> - scsi_add_device(shost, 0, target, lun);
> + if (lun == 0) {
> + scsi_scan_target(&shost->shost_gendev, 0, target,
> + SCAN_WILD_CARD, SCSI_SCAN_INITIAL);
> + } else {
> + scsi_add_device(shost, 0, target, lun);
> + }
> break;
> case VIRTIO_SCSI_EVT_RESET_REMOVED:
> sdev = scsi_device_lookup(shost, 0, target, lun);
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Rescan the entire target on transport reset when LUN is 0
2020-09-08 14:22 ` Paolo Bonzini
@ 2020-09-08 17:53 ` Felipe Franciosi
2020-09-09 5:54 ` Greg KH
0 siblings, 1 reply; 7+ messages in thread
From: Felipe Franciosi @ 2020-09-08 17:53 UTC (permalink / raw)
To: Paolo Bonzini, stable
Cc: Matej Genci, linux-kernel, mst, jasowang, stefanha, jejb,
martin.petersen, virtualization, linux-scsi
> On Sep 8, 2020, at 3:22 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 28/08/20 14:21, Matej Genci wrote:
>> VirtIO 1.0 spec says
>> The removed and rescan events ... when sent for LUN 0, they MAY
>> apply to the entire target so the driver can ask the initiator
>> to rescan the target to detect this.
>>
>> This change introduces the behaviour described above by scanning the
>> entire scsi target when LUN is set to 0. This is both a functional and a
>> performance fix. It aligns the driver with the spec and allows control
>> planes to hotplug targets with large numbers of LUNs without having to
>> request a RESCAN for each one of them.
>>
>> Signed-off-by: Matej Genci <matej@nutanix.com>
>> Suggested-by: Felipe Franciosi <felipe@nutanix.com>
>> ---
>> drivers/scsi/virtio_scsi.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
>> index bfec84aacd90..a4b9bc7b4b4a 100644
>> --- a/drivers/scsi/virtio_scsi.c
>> +++ b/drivers/scsi/virtio_scsi.c
>> @@ -284,7 +284,12 @@ static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi,
>>
>> switch (virtio32_to_cpu(vscsi->vdev, event->reason)) {
>> case VIRTIO_SCSI_EVT_RESET_RESCAN:
>> - scsi_add_device(shost, 0, target, lun);
>> + if (lun == 0) {
>> + scsi_scan_target(&shost->shost_gendev, 0, target,
>> + SCAN_WILD_CARD, SCSI_SCAN_INITIAL);
>> + } else {
>> + scsi_add_device(shost, 0, target, lun);
>> + }
>> break;
>> case VIRTIO_SCSI_EVT_RESET_REMOVED:
>> sdev = scsi_device_lookup(shost, 0, target, lun);
>>
>
>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org
Thanks, Paolo.
I'm Cc'ing stable as I believe this fixes a driver bug where it
doesn't follow the spec. Per commit message, today devices are
required to issue RESCAN events for each LUN behind a target when
hotplugging, or risking the driver not seeing the new LUNs.
Is this enough? Or should we resend after merge per below?
https://www.kernel.org/doc/Documentation/process/stable-kernel-rules.rst
F.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Rescan the entire target on transport reset when LUN is 0
2020-09-08 17:53 ` Felipe Franciosi
@ 2020-09-09 5:54 ` Greg KH
0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2020-09-09 5:54 UTC (permalink / raw)
To: Felipe Franciosi
Cc: Paolo Bonzini, stable, Matej Genci, linux-kernel, mst, jasowang,
stefanha, jejb, martin.petersen, virtualization, linux-scsi
On Tue, Sep 08, 2020 at 05:53:16PM +0000, Felipe Franciosi wrote:
>
>
> > On Sep 8, 2020, at 3:22 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> >
> > On 28/08/20 14:21, Matej Genci wrote:
> >> VirtIO 1.0 spec says
> >> The removed and rescan events ... when sent for LUN 0, they MAY
> >> apply to the entire target so the driver can ask the initiator
> >> to rescan the target to detect this.
> >>
> >> This change introduces the behaviour described above by scanning the
> >> entire scsi target when LUN is set to 0. This is both a functional and a
> >> performance fix. It aligns the driver with the spec and allows control
> >> planes to hotplug targets with large numbers of LUNs without having to
> >> request a RESCAN for each one of them.
> >>
> >> Signed-off-by: Matej Genci <matej@nutanix.com>
> >> Suggested-by: Felipe Franciosi <felipe@nutanix.com>
> >> ---
> >> drivers/scsi/virtio_scsi.c | 7 ++++++-
> >> 1 file changed, 6 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> >> index bfec84aacd90..a4b9bc7b4b4a 100644
> >> --- a/drivers/scsi/virtio_scsi.c
> >> +++ b/drivers/scsi/virtio_scsi.c
> >> @@ -284,7 +284,12 @@ static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi,
> >>
> >> switch (virtio32_to_cpu(vscsi->vdev, event->reason)) {
> >> case VIRTIO_SCSI_EVT_RESET_RESCAN:
> >> - scsi_add_device(shost, 0, target, lun);
> >> + if (lun == 0) {
> >> + scsi_scan_target(&shost->shost_gendev, 0, target,
> >> + SCAN_WILD_CARD, SCSI_SCAN_INITIAL);
> >> + } else {
> >> + scsi_add_device(shost, 0, target, lun);
> >> + }
> >> break;
> >> case VIRTIO_SCSI_EVT_RESET_REMOVED:
> >> sdev = scsi_device_lookup(shost, 0, target, lun);
> >>
> >
> >
> > Acked-by: Paolo Bonzini <pbonzini@redhat.com>
>
> Cc: stable@vger.kernel.org
>
> Thanks, Paolo.
>
> I'm Cc'ing stable as I believe this fixes a driver bug where it
> doesn't follow the spec. Per commit message, today devices are
> required to issue RESCAN events for each LUN behind a target when
> hotplugging, or risking the driver not seeing the new LUNs.
>
> Is this enough? Or should we resend after merge per below?
> https://www.kernel.org/doc/Documentation/process/stable-kernel-rules.rst
You need to let stable know the git commit id of the patch in Linus's
tree if the cc: stable is not on the final commit that gets merged.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Rescan the entire target on transport reset when LUN is 0
2020-08-28 12:21 [PATCH] Rescan the entire target on transport reset when LUN is 0 Matej Genci
2020-09-08 14:15 ` Michael S. Tsirkin
2020-09-08 14:22 ` Paolo Bonzini
@ 2020-09-16 1:52 ` Martin K. Petersen
2020-09-22 3:56 ` Martin K. Petersen
3 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2020-09-16 1:52 UTC (permalink / raw)
To: Matej Genci
Cc: linux-kernel, mst, jasowang, pbonzini, stefanha, jejb,
martin.petersen, virtualization, linux-scsi, Felipe Franciosi
Matej,
> This change introduces the behaviour described above by scanning the
> entire scsi target when LUN is set to 0. This is both a functional and a
> performance fix. It aligns the driver with the spec and allows control
> planes to hotplug targets with large numbers of LUNs without having to
> request a RESCAN for each one of them.
Applied to 5.10/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Rescan the entire target on transport reset when LUN is 0
2020-08-28 12:21 [PATCH] Rescan the entire target on transport reset when LUN is 0 Matej Genci
` (2 preceding siblings ...)
2020-09-16 1:52 ` Martin K. Petersen
@ 2020-09-22 3:56 ` Martin K. Petersen
3 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2020-09-22 3:56 UTC (permalink / raw)
To: Matej Genci, linux-kernel
Cc: Martin K . Petersen, jejb, linux-scsi, jasowang, stefanha,
pbonzini, virtualization, mst, Felipe Franciosi
On Fri, 28 Aug 2020 12:21:35 +0000, Matej Genci wrote:
> VirtIO 1.0 spec says
> The removed and rescan events ... when sent for LUN 0, they MAY
> apply to the entire target so the driver can ask the initiator
> to rescan the target to detect this.
>
> This change introduces the behaviour described above by scanning the
> entire scsi target when LUN is set to 0. This is both a functional and a
> performance fix. It aligns the driver with the spec and allows control
> planes to hotplug targets with large numbers of LUNs without having to
> request a RESCAN for each one of them.
Applied to 5.10/scsi-queue, thanks!
[1/1] scsi: virtio_scsi: Rescan the entire target on transport reset when LUN is 0
https://git.kernel.org/mkp/scsi/c/beef6fd02b90
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-09-22 3:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 12:21 [PATCH] Rescan the entire target on transport reset when LUN is 0 Matej Genci
2020-09-08 14:15 ` Michael S. Tsirkin
2020-09-08 14:22 ` Paolo Bonzini
2020-09-08 17:53 ` Felipe Franciosi
2020-09-09 5:54 ` Greg KH
2020-09-16 1:52 ` Martin K. Petersen
2020-09-22 3:56 ` 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).