On 06/20/2014 06:47 AM, Anne Mulhern wrote:
----- Original Message -----
From: "David Lehman" dlehman@redhat.com To: anaconda-patches@lists.fedorahosted.org Sent: Thursday, June 19, 2014 1:05:22 PM Subject: Re: [blivet:master 3/8] Omit special check for md devices in addUdevDevice().
On 06/18/2014 02:05 PM, mulhern wrote:
If the device appears to be an md device, just call addUdevMDDevice directly.
Use udev_device_get_md_uuid() to get the mduuid of the array, but catch a key error. This has the same effect as the previous code, but is a bit more proper, even if more wordy.
Signed-off-by: mulhern amulhern@redhat.com
blivet/devicetree.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py index b4e5b00..36b8b05 100644 --- a/blivet/devicetree.py +++ b/blivet/devicetree.py @@ -891,7 +891,12 @@ class DeviceTree(object): device = self.getDeviceByName(name)
if device is None:
device = self.getDeviceByUuid(info.get("MD_UUID"))
try:
uuid = udev.udev_device_get_md_uuid(info)
except KeyError:
log.warning("failed to obtain uuid for mdraid device")
else:
device = self.getDeviceByUuid(uuid) # if we get here, we found all of the slave devices and # something must be wrong -- if all of the slaves are in
@@ -1188,16 +1193,7 @@ class DeviceTree(object): device = self.addUdevDMDevice(info) elif udev.udev_device_is_md(info) and not udev.udev_device_get_md_container(info): log.info("%s is an md device", name)
try:
md_uuid = udev.udev_device_get_md_uuid(info)
except KeyError:
pass
else:
# try to find the device by uuid
device = self.getDeviceByUuid(md_uuid)
if device is None:
device = self.addUdevMDDevice(info)
device = self.addUdevMDDevice(info) elif udev.udev_device_is_cdrom(info): log.info("%s is a cdrom", name) device = self.addUdevOpticalDevice(info)
It looks okay to me except that now we'll always run that code to add all of the member devices, which takes/wastes time. In all normal circumstances the array will already be active and most likely already in the tree by the time we get to it, so the expectation is that the short-circuit lookup will succeed. Maybe you could add an attempt to look up the device to the top of addUdevMDDevice if you want to clean up addUDevDevice.
David _______________________________________________ anaconda-patches mailing list anaconda-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
Is there any possibility that the device would have already been added (because one of its members was added) but some of its slaves have not been added and should be added in addUdevMDDevice?
The members should all get added the same way, so no -- we don't need to count on adding member devices via addUdevMDDevice unless by coincidence due to some bug.
David
- mulhern
anaconda-patches mailing list anaconda-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches