Re: [PATCH 2/2] Remove newly added partition from disk if subsequent commit fails. (#559907)

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

 



Ack.

On 02/12/2010 09:28 PM, David Lehman wrote:
If the commit fails because there's an md array active on the disk
we will try again to add the partition after stopping the array, but
if we don't remove the failed-to-add partition first, we end up with
a mess.
---
  storage/devices.py |    8 +++++++-
  1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 1132df2..eee43e2 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -1253,7 +1253,13 @@ class PartitionDevice(StorageDevice):
              self.setupParents()

              self.disk.format.addPartition(self.partedPartition)
-            self.disk.format.commit()
+
+            try:
+                self.disk.format.commit()
+            except DiskLabelCommitError:
+                part = self.disk.format.partedDisk.getPartitionByPath(self.path)
+                self.disk.format.removePartition(part)
+                raise

              # Ensure old metadata which lived in freespace so did not get
              # explictly destroyed by a destroyformat action gets wiped

_______________________________________________
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