Re: [PATCH 1/2] Update PartitionDevice's partedPartition when the PartedDisks get reset

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

 



These both look good to me.

Dave

On Fri, 2009-08-28 at 00:37 +0200, Hans de Goede wrote:
> We use 2 in memory copies of the partition table (2 PartedDisk instances),
> one which we manipulate while auto / manual partitioning, and one
> copy on which we reply the changes done by the auto / manual partitioning
> step by step (committing each step to the disk) as we process our
> actions.
> 
> For pre-existing partitions the PartitionDevice's partedPartition member
> would point to the manipulated table's partitions, even though we had
> already switched over and where actually executing actions. This causes
> issues (segfaults!) with the flag clearing in ActionDestroyFormat.execute(),
> as this was now calling unsetFlag on a partition which is no longer part of
> a disk (as it was removed by clearParts).
> 
> This patch fixes this by making PartitionDevice's partedPartition property
> switch over to the partitions in the new PartedDisk after we've
> switched over to it.
> 
> p.s.
> 
> For some reason in my case, the segfault kept getting caught be some handler
> and retriggered, so I had to scp in strace to find out it was segfaulting,
> this showed up as the installer hanging after
> "executing action: Destroy Format None on .... (partition)"
> 
> So this patch might fix some bug reports with these symptoms
> ---
>  storage/devices.py           |   13 +++++++++++--
>  storage/formats/disklabel.py |    3 +--
>  2 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/storage/devices.py b/storage/devices.py
> index de55547..d11fce5 100644
> --- a/storage/devices.py
> +++ b/storage/devices.py
> @@ -970,6 +970,16 @@ class PartitionDevice(StorageDevice):
>                  self.partType & parted.PARTITION_PROTECTED)
>  
>      def _getPartedPartition(self):
> +        if not self.exists:
> +            return self._partedPartition
> +
> +        partitionDisk = self._partedPartition.disk.getPedDisk()
> +        disklabelDisk = self.disk.format.partedDisk.getPedDisk()
> +        if partitionDisk is not disklabelDisk:
> +            # The disklabel's parted disk has been reset, reget our partition
> +            log.debug("regetting partedPartition for %s because of PartedDisk reset" % self.path)
> +            self._partedPartition = self.disk.format.partedDisk.getPartitionByPath(self.path)
> +
>          return self._partedPartition
>  
>      def _setPartedPartition(self, partition):
> @@ -1175,8 +1185,7 @@ class PartitionDevice(StorageDevice):
>              raise DeviceError("Cannot destroy non-leaf device", self.path)
>  
>          self.setupParents()
> -        partition = self.disk.format.partedDisk.getPartitionByPath(self.path)
> -        self.disk.format.removePartition(partition)
> +        self.disk.format.removePartition(self.partedPartition)
>          self.disk.format.commit()
>  
>          self.exists = False
> diff --git a/storage/formats/disklabel.py b/storage/formats/disklabel.py
> index 08e2461..e4122fb 100644
> --- a/storage/formats/disklabel.py
> +++ b/storage/formats/disklabel.py
> @@ -233,8 +233,7 @@ class DiskLabel(DeviceFormat):
>                                       constraint=constraint)
>  
>      def removePartition(self, partition):
> -        rempart = self.partedDisk.getPartitionByPath(partition.path)
> -        self.partedDisk.removePartition(rempart)
> +        self.partedDisk.removePartition(partition)
>  
>      @property
>      def extendedPartition(self):

_______________________________________________
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