[blivet:master 3/8] Omit special check for md devices in addUdevDevice().
David Lehman
dlehman at redhat.com
Thu Jun 19 17:05:22 UTC 2014
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 at 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
More information about the anaconda-patches
mailing list