-
-
Save dwlehman/d9263e8b180c189d9362 to your computer and use it in GitHub Desktop.
Alternate implementation of early format handling.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From: David Lehman <dlehman@redhat.com> | |
Date: Mon, 15 Jun 2015 16:04:31 -0500 | |
Subject: [PATCH] Handle formatting immediately after adding devices from | |
format handlers. | |
If we don't do it right away the device could be looked up successfully | |
and cause confusion due to inaccurate(missing) format data. | |
This is only needed in the places where we add a new device from a | |
format handler. The device additions from add*Device are not vulnerable | |
to this issue. | |
Related: rhbz#1192004 | |
--- | |
blivet/devicetree.py | 25 +++++++++++++++++++++---- | |
1 file changed, 21 insertions(+), 4 deletions(-) | |
diff --git a/blivet/devicetree.py b/blivet/devicetree.py | |
index 7fa750f..37fed43 100644 | |
--- a/blivet/devicetree.py | |
+++ b/blivet/devicetree.py | |
@@ -1116,7 +1116,11 @@ class DeviceTree(object): | |
self._addDevice(device) | |
return device | |
- def addUdevDevice(self, info): | |
+ def addUdevDevice(self, info, updateFmt=False): | |
+ """ | |
+ :param :class:`pyudev.Device` info: udev info for the device | |
+ :keyword bool updateFmt: update original format unconditionally | |
+ """ | |
name = udev.device_get_name(info) | |
log_method_call(self, name=name, info=pprint.pformat(dict(info))) | |
uuid = udev.device_get_uuid(info) | |
@@ -1258,7 +1262,7 @@ class DeviceTree(object): | |
# now handle the device's formatting | |
self.handleUdevDeviceFormat(info, device) | |
- if device_added: | |
+ if updateFmt or device_added: | |
device.originalFormat = copy.copy(device.format) | |
device.deviceLinks = udev.device_get_symlinks(info) | |
@@ -1356,6 +1360,12 @@ class DeviceTree(object): | |
else: | |
luks_device.updateSysfsPath() | |
self._addDevice(luks_device) | |
+ luks_info = udev.get_device(luks_device.sysfsPath) | |
+ if not luks_info: | |
+ log.error("failed to get udev data for %s", luks_device.name) | |
+ return | |
+ | |
+ self.addUdevDevice(luks_info, updateFmt=True) | |
else: | |
log.warning("luks device %s already in the tree", | |
device.format.mapName) | |
@@ -1515,7 +1525,7 @@ class DeviceTree(object): | |
return | |
# do format handling now | |
- self.addUdevDevice(lv_info) | |
+ self.addUdevDevice(lv_info, updateFmt=True) | |
raid = dict((n.replace("[", "").replace("]", ""), | |
{"copies": 0, "log": Size(0), "meta": Size(0)}) | |
@@ -1675,6 +1685,13 @@ class DeviceTree(object): | |
md_array.updateSysfsPath() | |
md_array.parents.append(device) | |
self._addDevice(md_array) | |
+ if md_array.status: | |
+ array_info = udev.get_device(md_array.sysfsPath) | |
+ if not array_info: | |
+ log.error("failed to get udev data for %s", md_array.name) | |
+ return | |
+ | |
+ self.addUdevDevice(array_info, updateFmt=True) | |
def handleUdevDMRaidMemberFormat(self, info, device): | |
# if dmraid usage is disabled skip any dmraid set activation | |
@@ -2082,7 +2099,7 @@ class DeviceTree(object): | |
self._addDevice(loopdev) | |
self._addDevice(dmdev) | |
info = udev.get_device(dmdev.sysfsPath) | |
- self.addUdevDevice(info) | |
+ self.addUdevDevice(info, updateFmt=True) | |
def backupConfigs(self, restore=False): | |
""" Create a backup copies of some storage config files. """ | |
-- | |
2.4.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment