qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Maxim Levitsky <mlevitsk@redhat.com>, qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v5 1/9] scsi/scsi_bus: switch search direction in scsi_device_find
Date: Fri, 25 Sep 2020 15:36:11 +0200	[thread overview]
Message-ID: <fe635b2e-fb7f-12e3-d228-2e626abe7474@redhat.com> (raw)
In-Reply-To: <20200913160259.32145-2-mlevitsk@redhat.com>

On 13/09/20 18:02, Maxim Levitsky wrote:
> This change will allow us to convert the bus children list to RCU,
> while not changing the logic of this function
> 
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  hw/scsi/scsi-bus.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
> index df65cc2223..f8adfbc2a5 100644
> --- a/hw/scsi/scsi-bus.c
> +++ b/hw/scsi/scsi-bus.c
> @@ -1572,7 +1572,7 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int id, int lun)
>      BusChild *kid;
>      SCSIDevice *target_dev = NULL;
>  
> -    QTAILQ_FOREACH_REVERSE(kid, &bus->qbus.children, sibling) {
> +    QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) {
>          DeviceState *qdev = kid->child;
>          SCSIDevice *dev = SCSI_DEVICE(qdev);
>  
> @@ -1580,7 +1580,15 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int id, int lun)
>              if (dev->lun == lun) {
>                  return dev;
>              }
> -            target_dev = dev;
> +
> +            /*
> +             * If we don't find exact match (channel/bus/lun),
> +             * we will return the first device which matches channel/bus
> +             */
> +
> +            if (!target_dev) {
> +                target_dev = dev;
> +            }
>          }
>      }
>      return target_dev;
> 

I think this breaks the detection of duplicate LUNs.  I'll play with it
and let you know.

Paolo



  reply	other threads:[~2020-09-25 13:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-13 16:02 [PATCH v5 0/9] Fix scsi devices plug/unplug races w.r.t virtio-scsi iothread Maxim Levitsky
2020-09-13 16:02 ` [PATCH v5 1/9] scsi/scsi_bus: switch search direction in scsi_device_find Maxim Levitsky
2020-09-25 13:36   ` Paolo Bonzini [this message]
2020-09-13 16:02 ` [PATCH v5 2/9] rcu: Implement drain_call_rcu Maxim Levitsky
2020-09-13 16:02 ` [PATCH v5 3/9] device_core: use drain_call_rcu in in hmp_device_del/qmp_device_add Maxim Levitsky
2020-09-13 16:02 ` [PATCH v5 4/9] device-core: use RCU for list of childs of a bus Maxim Levitsky
2020-09-13 16:02 ` [PATCH v5 5/9] device-core: use atomic_set on .realized property Maxim Levitsky
2020-09-13 16:02 ` [PATCH v5 6/9] scsi/scsi-bus: scsi_device_find: don't return unrealized devices Maxim Levitsky
2020-09-13 16:02 ` [PATCH v5 7/9] scsi/scsi_bus: Add scsi_device_get Maxim Levitsky
2020-09-13 16:02 ` [PATCH v5 8/9] virtio-scsi: use scsi_device_get Maxim Levitsky
2020-09-13 16:02 ` [PATCH v5 9/9] scsi/scsi_bus: fix races in REPORT LUNS Maxim Levitsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fe635b2e-fb7f-12e3-d228-2e626abe7474@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=fam@euphon.net \
    --cc=mlevitsk@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).