PATCH: pyblock: Fix traceback when activating already active dmraid set

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

 



When comparing dm table entries we failed to correctly convert a
/dev/mapper/XXXX entry to a major:minor str (nested dmraid problem) also
in some cases when using a mirror, the string we build and the map of dm have
their disks swapped.
---
 device.py |   39 +++++++++++++++++----------------------
 1 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/device.py b/device.py
index 1c0d7f3..cbf196c 100644
--- a/device.py
+++ b/device.py
@@ -20,6 +20,7 @@

 import sys as _sys
 import os as _os
+import stat as _stat
 import string as _string

 def DeviceMaps():
@@ -668,26 +669,11 @@ class RaidSet:
                 return path.strip()

             try:
-                newpath=path.split('/')[-1]
-                pos = 0
-                dev = None
-                num = None
-                while pos < len(newpath):
-                    if newpath[pos].isdigit():
-                        dev = newpath[:pos]
-                        num = newpath[pos:]
-                        break
-                    pos += 1
-                if dev is None:
-                    dev = newpath
-                sysnewpath = None
-                if num is None:
-                    sysnewpath = '/sys/block/%s/dev' % (dev,)
-                else:
-                    sysnewpath = '/sys/block/%s/%s%s/dev' % (dev, dev, num)
-                f = open(sysnewpath, 'r')
-                l = f.readline()
-                return l.strip()
+                statinfo = _os.stat(path)
+                if not _stat.S_ISBLK(statinfo.st_mode):
+                    return path.strip()
+
+                return "%d:%d" % (statinfo.st_rdev/256, statinfo.st_rdev%256, )
             except:
                 return path.strip()

@@ -696,13 +682,22 @@ class RaidSet:
         table = []
         for part in parts:
             table += [map_dev(part),]
-        table = _string.join(table, ' ')
+        tablestr = _string.join(table, ' ')
+        # sometimes dmraid and dm have the disks of a mirror swapped
+        if self.rs.dmTable.type == "mirror":
+            tmp = table[8]
+            table[8] = table[10]
+            table[10] = tmp
+            alt_tablestr = _string.join(table, ' ')
+        else:
+            alt_tablestr = None

         import dm as _dm

         for map in _dm.maps():
             # XXX wtf?  why's it have a space at the end sometimes?
-            if str(map.table).strip() == table:
+            if str(map.table).strip() == tablestr or alt_tablestr and \
+                   str(map.table).strip() == alt_tablestr:
                 self._RaidSet__map = map
                 self.active = True
                 del _dm
--
1.6.1.3

_______________________________________________
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