Find more used...same as before. Make DeviceTree.hide()...takes a much more conservative approach to action removal than previous patches. Conservative means removes a whole lot more actions and is rendered thereby simpler and probably less dangerous. Log action...trivial, but desirable, and shouldn't be dangerous.
IMHO we need to extend all the logging functions with some clever meta-programming so that they _never_ cause a crash even if their arguments can not be evaluated. Has anybody heard of a library for this, specifically?
David Lehman (1): Find more used devices when calculating unused devices (#1043763)
mulhern (2): Make DeviceTree.hide() remove a larger set (#1043763) Log action cancelation (#1043763)
blivet/__init__.py | 6 ++++-- blivet/devicetree.py | 29 +++++++---------------------- 2 files changed, 11 insertions(+), 24 deletions(-)
From: David Lehman dlehman@redhat.com
Related: rhbz#1043763
Original commit message (cherry-picked from commit a3bff73119413fb1ea49febfc0d58bf318003ad8):
Newly formatted devices are used unless mountpoint is empty. (#966078)
The previous algorithm was only including filesystems with mountpoints and swap devices, ignoring new prepboot, biosboot, &c.
Signed-off-by: mulhern amulhern@redhat.com --- blivet/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/blivet/__init__.py b/blivet/__init__.py index 6908b2a..c238b84 100644 --- a/blivet/__init__.py +++ b/blivet/__init__.py @@ -444,8 +444,10 @@ class Blivet(object): used_devices.extend(device.ancestors)
for new in [d for d in self.devicetree.leaves if not d.format.exists]: - if new in self.swaps or getattr(new.format, "mountpoint", None): - used_devices.extend(new.ancestors) + if new.format.mountable and not new.format.mountpoint: + continue + + used_devices.extend(new.ancestors)
for device in self.partitions: if getattr(device, "isLogical", False):
Related: rhbz#1043763
If a device is hidden these things now happen: 1) All actions are canceled. Note that canceling a device create action will cause the device to be removed. Note that it should be the case that no existing device has a device create action associated with it. Previously only a subset of actions were canceled. 2) The device being hidden is removed using _removeDevice. An additional post-processing step adds the name of the device back into self.names. Other steps associated with hiding the device remain the same.
Note: The device exists if and only if it has not been removed by the cancellation of all actions. So, if it does not exist, then the method is done after action cancelation. However, if the device does exist, it should be removed, special hiding actions should be done, and its name should be inserted back into self.names.
Signed-off-by: mulhern amulhern@redhat.com --- blivet/devicetree.py | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py index 8a79f14..1b3b750 100644 --- a/blivet/devicetree.py +++ b/blivet/devicetree.py @@ -1795,43 +1795,27 @@ class DeviceTree(object): if device in self._hidden: return
- for d in self.getChildren(device): - self.hide(d) - log.info("hiding device %s %s (id %d)" % (device.type, device.name, device.id))
for action in reversed(self._actions): - if not action.device.dependsOn(device) and action.device != device: - continue - - log.debug("cancelling action: %s" % action) - try: - action.cancel() - except Exception: - log.warning("failed to cancel action while hiding %s: %s" - % (device.name, action)) - finally: - self._actions.remove(action) - - # XXX modifications that do not require actions, like setting a - # mountpoint, will not be reversed here - - # we're intentionally not modifying self.names here - self._devices.remove(device) - for parent in device.parents: - parent.removeChild() + self.cancelAction(action)
if not device.exists: return
+ self._removeDevice(device) + self._hidden.append(device) lvm.lvm_cc_addFilterRejectRegexp(device.name)
if isinstance(device, DASDDevice): self.dasd.removeDASD(device)
+ if device.name not in self.names: + self.names.append(device.name) + def unhide(self, device): # the hidden list should be in leaves-first order for hidden in reversed(self._hidden):
On Tue, 2014-02-25 at 12:44 -0500, mulhern wrote:
Related: rhbz#1043763
If a device is hidden these things now happen:
- All actions are canceled. Note that canceling a device create action will
cause the device to be removed. Note that it should be the case that no existing device has a device create action associated with it. Previously only a subset of actions were canceled. 2) The device being hidden is removed using _removeDevice. An additional post-processing step adds the name of the device back into self.names. Other steps associated with hiding the device remain the same.
Note: The device exists if and only if it has not been removed by the cancellation of all actions. So, if it does not exist, then the method is done after action cancelation. However, if the device does exist, it should be removed, special hiding actions should be done, and its name should be inserted back into self.names.
Signed-off-by: mulhern amulhern@redhat.com
blivet/devicetree.py | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py index 8a79f14..1b3b750 100644 --- a/blivet/devicetree.py +++ b/blivet/devicetree.py @@ -1795,43 +1795,27 @@ class DeviceTree(object): if device in self._hidden: return
for d in self.getChildren(device):self.hide(d)
Don't we still need to do this, although probably after canceling all of the actions? Consider calling hide() on a disk with several preexisting devices on it. I don't think those devices will get hidden with this change. The rest looks good.
log.info("hiding device %s %s (id %d)" % (device.type, device.name, device.id)) for action in reversed(self._actions):
if not action.device.dependsOn(device) and action.device != device:continuelog.debug("cancelling action: %s" % action)try:action.cancel()except Exception:log.warning("failed to cancel action while hiding %s: %s"% (device.name, action))finally:self._actions.remove(action)# XXX modifications that do not require actions, like setting a# mountpoint, will not be reversed here# we're intentionally not modifying self.names hereself._devices.remove(device)for parent in device.parents:parent.removeChild()
self.cancelAction(action) if not device.exists: returnself._removeDevice(device)self._hidden.append(device) lvm.lvm_cc_addFilterRejectRegexp(device.name) if isinstance(device, DASDDevice): self.dasd.removeDASD(device)if device.name not in self.names:self.names.append(device.name)def unhide(self, device): # the hidden list should be in leaves-first order for hidden in reversed(self._hidden):
Related: rbhz#1043763
Signed-off-by: mulhern amulhern@redhat.com --- blivet/devicetree.py | 1 + 1 file changed, 1 insertion(+)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py index 1b3b750..f09c593 100644 --- a/blivet/devicetree.py +++ b/blivet/devicetree.py @@ -386,6 +386,7 @@ class DeviceTree(object):
action.cancel() self._actions.remove(action) + log.info("canceled action %s", action)
def findActions(self, device=None, type=None, object=None, path=None, devid=None):
anaconda-patches@lists.fedorahosted.org