[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 09/17] scsi/scsi_bus: switch search direction in scsi_device_f
From: |
Paolo Bonzini |
Subject: |
[PATCH v8 09/17] scsi/scsi_bus: switch search direction in scsi_device_find |
Date: |
Wed, 7 Oct 2020 07:56:52 -0400 |
From: Maxim Levitsky <mlevitsk@redhat.com>
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 3284a5d1fb..6b1ed7ae9a 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;
--
2.26.2
- [PATCH v8 06/17] qtest: check that drives are really appearing and disappearing, (continued)
- [PATCH v8 06/17] qtest: check that drives are really appearing and disappearing, Paolo Bonzini, 2020/10/07
- [PATCH v8 02/17] qtest: Reintroduce qtest_qmp_receive, Paolo Bonzini, 2020/10/07
- [PATCH v8 04/17] device-plug-test: use qtest_qmp to send the device_del command, Paolo Bonzini, 2020/10/07
- [PATCH v8 05/17] qtest: switch users back to qtest_qmp_receive, Paolo Bonzini, 2020/10/07
- [PATCH v8 08/17] qdev: add "check if address free" callback for buses, Paolo Bonzini, 2020/10/07
- [PATCH v8 07/17] qemu-iotests, qtest: rewrite test 067 as a qtest, Paolo Bonzini, 2020/10/07
- [PATCH v8 10/17] device_core: use drain_call_rcu in in qmp_device_add, Paolo Bonzini, 2020/10/07
- [PATCH v8 09/17] scsi/scsi_bus: switch search direction in scsi_device_find,
Paolo Bonzini <=
- [PATCH v8 11/17] device-core: use RCU for list of children of a bus, Paolo Bonzini, 2020/10/07
- [PATCH v8 14/17] scsi/scsi-bus: scsi_device_find: don't return unrealized devices, Paolo Bonzini, 2020/10/07
- [PATCH v8 15/17] scsi/scsi_bus: Add scsi_device_get, Paolo Bonzini, 2020/10/07
- [PATCH v8 12/17] scsi: switch to bus->check_address, Paolo Bonzini, 2020/10/07
- [PATCH v8 13/17] device-core: use atomic_set on .realized property, Paolo Bonzini, 2020/10/07
- [PATCH v8 17/17] scsi/scsi_bus: fix races in REPORT LUNS, Paolo Bonzini, 2020/10/07
- [PATCH v8 16/17] virtio-scsi: use scsi_device_get, Paolo Bonzini, 2020/10/07
- Re: [PATCH v8 00/17] Fix scsi devices plug/unplug races w.r.t virtio-scsi iothread, no-reply, 2020/10/07