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

too much partition clearing



For reference:

   https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=232936

We're just running the partition clearing code too often.  Every time
through openDevices, we are clearing the disks out.  This happens even
after partitions have been created.  And since it's kind of hard to make
physical volumes or RAID members on partitions that don't exist, we
explode.

One fix could be the addition of some sort of flag that gets set the
first time we clear partitions, and then is checked every time.  Yuck.
Also, openDevices is kind of a mess and needs to be doing less stuff on
each of the many times it's called.  It especially doesn't need to do
something destructive like clearing out the partitions every time.

I've moved the clearpart stuff out into its own method and call it from
turnOnFilesystems and when we do the early swap stuff.  I know this is
really subtle code so I may have messed something up.  However, basic
tests I've performed here today seem okay so far.  The patch is
attached.  Comments welcome.

- Chris
? less-clearpart.diff
Index: packages.py
===================================================================
RCS file: /usr/local/CVS/anaconda/packages.py,v
retrieving revision 1.333
diff -u -r1.333 packages.py
--- packages.py	14 Mar 2007 14:38:16 -0000	1.333
+++ packages.py	27 Mar 2007 21:03:32 -0000
@@ -141,6 +141,7 @@
     if flags.setupFilesystems:
 	if not anaconda.id.upgrade:
             anaconda.id.partitions.doMetaDeletes(anaconda.id.diskset)
+            anaconda.id.diskset.clearDevices()
             anaconda.id.fsset.setActive(anaconda.id.diskset)
             if not anaconda.id.fsset.isActive():
                 anaconda.id.diskset.savePartitions ()
Index: partedUtils.py
===================================================================
RCS file: /usr/local/CVS/anaconda/partedUtils.py,v
retrieving revision 1.118
diff -u -r1.118 partedUtils.py
--- partedUtils.py	22 Mar 2007 17:43:09 -0000	1.118
+++ partedUtils.py	27 Mar 2007 21:03:32 -0000
@@ -990,6 +990,49 @@
 
         return 1
 
+    def clearDevices (self):
+        def inClearDevs (drive, clearDevs):
+            return (clearDevs is None) or (len(clearDevs) == 0) or (drive in clearDevs)
+
+        clearDevs = []
+        initAll = False
+
+        if self.anaconda is not None and self.anaconda.isKickstart:
+            clearDevs = self.anaconda.id.ksdata.clearpart.drives
+            initAll = self.anaconda.id.ksdata.clearpart.initAll
+
+        for drive in self.driveList():
+            # ignoredisk takes precedence over clearpart (#186438).
+            if drive in DiskSet.skippedDisks:
+                continue
+
+            deviceFile = isys.makeDevInode(drive, "/dev/" + drive)
+
+            if not isys.mediaPresent(drive):
+                DiskSet.skippedDisks.append(drive)
+                continue
+
+            try:
+                dev = parted.PedDevice.get (deviceFile)
+            except parted.error, msg:
+                DiskSet.skippedDisks.append(drive)
+                continue
+
+            if initAll and inClearDevs(drive, clearDevs) and not flags.test \
+                       and not hasProtectedPartitions(drive, self.anaconda):
+                if rhpl.getArch() == "s390" and drive[:4] == "dasd":
+                    if self.dasdFmt(drive):
+                        DiskSet.skippedDrives.append(drive)
+                        continue
+                else:
+                    try:
+                        log.info("clearing drive %s" % drive)
+                        disk = dev.disk_new_fresh(getDefaultDiskType())
+                        disk.commit()
+                    except parted.error, msg:
+                        DiskSet.skippedDisks.append(drive)
+                        continue
+
     def openDevices (self):
         """Open the disks on the system and skip unopenable devices."""
 
@@ -1017,11 +1060,11 @@
             ks = False
             clearDevs = []
             initAll = False
-            if self.anaconda is not None:
-                if self.anaconda.isKickstart:
-                    ks = True
-                    clearDevs = self.anaconda.id.ksdata.clearpart.drives
-                    initAll = self.anaconda.id.ksdata.clearpart.initAll
+
+            if self.anaconda is not None and self.anaconda.isKickstart:
+                ks = True
+                clearDevs = self.anaconda.id.ksdata.clearpart.drives
+                initAll = self.anaconda.id.ksdata.clearpart.initAll
 
             # FIXME: need the right fix for z/VM formatted dasd
             if rhpl.getArch() == "s390" and drive[:4] == "dasd" and isys.getDasdState(drive):
@@ -1060,22 +1103,6 @@
                 DiskSet.skippedDisks.append(drive)
                 continue
 
-            if initAll and ((clearDevs is None) or (len(clearDevs) == 0) \
-                       or (drive in clearDevs)) and not flags.test \
-                       and not hasProtectedPartitions(drive, self.anaconda):
-                if rhpl.getArch() == "s390" and drive[:4] == "dasd":
-                    if self.dasdFmt(drive):
-                        DiskSet.skippedDisks.append(drive)
-                        continue                    
-                else:
-                    try:
-                        disk = dev.disk_new_fresh(getDefaultDiskType())
-                        disk.commit()
-                        self.disks[drive] = disk
-                    except parted.error, msg:
-                        DiskSet.skippedDisks.append(drive)
-                        continue
-                
             try:
                 disk = parted.PedDisk.new(dev)
                 self.disks[drive] = disk
Index: partitioning.py
===================================================================
RCS file: /usr/local/CVS/anaconda/partitioning.py,v
retrieving revision 1.180
diff -u -r1.180 partitioning.py
--- partitioning.py	13 Dec 2006 20:52:19 -0000	1.180
+++ partitioning.py	27 Mar 2007 21:03:32 -0000
@@ -100,6 +100,7 @@
         
     if rc:
         anaconda.id.partitions.doMetaDeletes(anaconda.id.diskset)        
+        anaconda.id.diskset.clearDevices()
         anaconda.id.fsset.setActive(anaconda.id.diskset)
         anaconda.id.diskset.savePartitions ()
         anaconda.id.fsset.createLogicalVolumes(anaconda.rootPath)        

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