[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 06/13] scsi/scsi_bus: switch search direction in scsi_device_f
From: |
Maxim Levitsky |
Subject: |
[PATCH v7 06/13] scsi/scsi_bus: switch search direction in scsi_device_find |
Date: |
Tue, 6 Oct 2020 15:38:57 +0300 |
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>
Message-Id: <20200913160259.32145-2-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@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 94921c04b1..69d7c3f90c 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -1571,7 +1571,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);
@@ -1579,7 +1579,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;
--
2.26.2
- [PATCH v7 02/13] qtest: Reintroduce qtest_qmp_receive, (continued)
[PATCH v7 03/13] qtest: switch users back to qtest_qmp_receive, Maxim Levitsky, 2020/10/06
[PATCH v7 04/13] qdev: add "check if address free" callback for buses, Maxim Levitsky, 2020/10/06
[PATCH v7 05/13] scsi: switch to bus->check_address, Maxim Levitsky, 2020/10/06
[PATCH v7 06/13] scsi/scsi_bus: switch search direction in scsi_device_find,
Maxim Levitsky <=
[PATCH v7 07/13] device_core: use drain_call_rcu in in qmp_device_add, Maxim Levitsky, 2020/10/06
[PATCH v7 08/13] device-core: use RCU for list of children of a bus, Maxim Levitsky, 2020/10/06
[PATCH v7 09/13] device-core: use atomic_set on .realized property, Maxim Levitsky, 2020/10/06
[PATCH v7 10/13] scsi/scsi-bus: scsi_device_find: don't return unrealized devices, Maxim Levitsky, 2020/10/06
[PATCH v7 11/13] scsi/scsi_bus: Add scsi_device_get, Maxim Levitsky, 2020/10/06
[PATCH v7 12/13] virtio-scsi: use scsi_device_get, Maxim Levitsky, 2020/10/06
[PATCH v7 13/13] scsi/scsi_bus: fix races in REPORT LUNS, Maxim Levitsky, 2020/10/06
Re: [PATCH v7 00/13] Fix scsi devices plug/unplug races w.r.t virtio-scsi iothread, no-reply, 2020/10/06