[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/4] scsi/scsi_bus: switch search direction in scsi_device_find
From: |
Maxim Levitsky |
Subject: |
[PATCH 1/4] scsi/scsi_bus: switch search direction in scsi_device_find |
Date: |
Thu, 16 Apr 2020 23:36:21 +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 <address@hidden>
---
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 1c980cab38..7bbc37acec 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -1584,7 +1584,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);
@@ -1592,7 +1592,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.17.2
- [PATCH 0/4] RFC/WIP: Fix scsi devices plug/unplug races w.r.t virtio-scsi iothread, Maxim Levitsky, 2020/04/16
- [PATCH 1/4] scsi/scsi_bus: switch search direction in scsi_device_find,
Maxim Levitsky <=
- [PATCH 2/4] device-core: use RCU for list of childs of a bus, Maxim Levitsky, 2020/04/16
- [PATCH 4/4] virtio-scsi: don't touch scsi devices that are not yet realized, Maxim Levitsky, 2020/04/16
- [PATCH 3/4] device-core: use atomic_set on .realized property, Maxim Levitsky, 2020/04/16
- Re: [PATCH 0/4] RFC/WIP: Fix scsi devices plug/unplug races w.r.t virtio-scsi iothread, no-reply, 2020/04/16
- Re: [PATCH 0/4] RFC/WIP: Fix scsi devices plug/unplug races w.r.t virtio-scsi iothread, no-reply, 2020/04/16
- Re: [PATCH 0/4] RFC/WIP: Fix scsi devices plug/unplug races w.r.t virtio-scsi iothread, no-reply, 2020/04/16