Re: [PATCH] Try to name existing md arrays based on their preferred minor.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looks ok,

Regards,

Hans


On 04/21/2009 01:17 AM, David Lehman wrote:
---
  storage/devicetree.py |   34 +++++++++++++++++++++++++++-------
  1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/storage/devicetree.py b/storage/devicetree.py
index 540719b..c52184d 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,

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux