summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorDavid Lehman <dlehman@redhat.com>2009-04-20 17:07:43 -0500
committerDavid Lehman <dlehman@redhat.com>2009-04-21 10:14:24 -0500
commit6fbb07b6c73137dbb317efd7e00b558ea432c411 (patch)
tree60edd6788d2f09e1c31e0e1618cfd4c0afd38ca6 /storage
parentab244645e1c07f490f23d4b0a98eb657bc935565 (diff)
downloadanaconda-6fbb07b6c73137dbb317efd7e00b558ea432c411.tar.gz
anaconda-6fbb07b6c73137dbb317efd7e00b558ea432c411.tar.xz
anaconda-6fbb07b6c73137dbb317efd7e00b558ea432c411.zip
Try to name existing md arrays based on their preferred minor.
Diffstat (limited to 'storage')
-rw-r--r--storage/devicetree.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/storage/devicetree.py b/storage/devicetree.py
index 540719bb9..c52184d64 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -28,6 +28,7 @@ from errors import *
from devices import *
from deviceaction import *
import formats
+import devicelibs.mdraid
from udev import *
from iutil import log_method_call
@@ -1293,15 +1294,34 @@ class DeviceTree(object):
log.warning("invalid data for %s: %s" % (name, e))
return
- # find the first unused minor
- minor = 0
- while True:
- if self.getDeviceByName("md%d" % minor):
- minor += 1
+ # try to name the array based on the preferred minor
+ md_info = devicelibs.mdraid.mdexamine(device.path)
+ md_path = md_info.get("device", "")
+ md_name = devicePathToName(md_info.get("device", ""))
+ if md_name:
+ try:
+ minor = int(md_name[2:]) # strip off leading "md"
+ except (IndexError, ValueError):
+ minor = None
+ md_name = None
else:
- break
+ array = self.getDeviceByName(md_name)
+ if array and array.uuid != md_uuid:
+ md_name = None
+
+ if not md_name:
+ # if we don't have a name yet, find the first unused minor
+ minor = 0
+ while True:
+ if self.getDeviceByName("md%d" % minor):
+ minor += 1
+ else:
+ break
+
+ md_name = "md%d" % minor
- md_name = "md%d" % minor
+ log.debug("using name %s for md array containing member %s"
+ % (md_name, device.name))
md_array = MDRaidArrayDevice(md_name,
level=md_level,
minor=minor,