[PATCH 5/5] Only cancel actions on disks related to the one we are hiding.
Vratislav Podzimek
vpodzime at redhat.com
Thu Sep 18 07:08:49 UTC 2014
On Tue, 2014-09-16 at 16:01 -0500, David Lehman wrote:
> This includes all actions related to the disk and all actions related
> to disks that are linked to the disk being hidden by multi-disk devices
> like lvm volume groups.
>
> Fedora:
> Related: rhbz#1121383
>
> RHEL:
> Related: rhbz#1085201
> Related: rhbz#1129595
> Related: rhbz#1075671
> ---
> blivet/devicetree.py | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/blivet/devicetree.py b/blivet/devicetree.py
> index 417e39a..0c784a1 100644
> --- a/blivet/devicetree.py
> +++ b/blivet/devicetree.py
> @@ -1905,8 +1905,8 @@ class DeviceTree(object):
> :param device: the device to hide
> :type device: :class:`~.devices.StorageDevice`
>
> - Hiding a device will cancel all actions and will remove the
> - device from the device list.
> + Hiding a device will cancel all actions that involve the device and
> + will remove the device from the device list.
>
> If the device is not a leaf device, all devices that depend on it
> will be hidden leaves-first until the device is a leaf device.
> @@ -1939,8 +1939,20 @@ class DeviceTree(object):
> return
>
> # cancel actions first thing so that we hide the correct set of devices
> - for action in reversed(self._actions):
> - self.cancelAction(action)
> + if device.isDisk:
> + # Cancel all actions on this disk and any disk related by way of an
> + # aggregate/container device (eg: lvm volume group).
> + disks = [device]
> + related_actions = [a for a in self._actions
> + if a.device.dependsOn(device)]
This could be a generator (comprehension) instead of a list.
> + for related_device in (a.device for a in related_actions):
> + disks.extend(related_device.disks)
> +
> + disks = set(disks)
> + cancel = [a for a in self._actions
> + if set(a.device.disks).intersection(disks)]
Same applies here, reversed() returns a list, don't need to construct
two.
> + for action in reversed(cancel):
> + self.cancelAction(action)
>
> for d in self.getChildren(device):
> self.hide(d)
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list