Re: [PATCH] Add currentSize method to the PartitionDevice class (#565822)

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ack.

On Tue, 16 Feb 2010, Hans de Goede wrote:

PartitionDevice was inheriting the currentSize property from StorageDevice,
but that uses partedDevice.getSize() which returns 1024 when called on
extended partitions (as that is what the kernel reports).

This causes _setTargetSize() to try and change the extended partition geometry
even when called with the current extended partition geometry size, as
currentSize was mis-reporting the extended partition size. Since
we do end sector alignment now a days when changing the partition geometry,
we could end up making the extended partition to small to hold the
last logical partition resulting in a:
PartitionException: Unable to satisfy all constraints on the partition.

Error. This patch fixes this by adding a currentSize method to the
PartitionDevice class, which properly reports the currentSize for extended
partitions.
---
storage/devices.py |   12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index eee43e2..44b063a 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -926,6 +926,7 @@ class PartitionDevice(StorageDevice):
        self.partedFlags = {}
        self._partedPartition = None
        self._origPath = None
+        self._currentSize = 0

        # FIXME: Validate size, but only if this is a new partition.
        #        For existing partitions we will get the size from
@@ -1231,6 +1232,7 @@ class PartitionDevice(StorageDevice):

        # this is in MB
        self._size = self.partedPartition.getSize()
+        self._currentSize = self._size
        self.targetSize = self._size

        self._partType = self.partedPartition.type
@@ -1270,6 +1272,7 @@ class PartitionDevice(StorageDevice):
            self.partedPartition = self.disk.format.partedDisk.getPartitionByPath(self.path)

            self.exists = True
+            self._currentSize = self.partedPartition.getSize()
            self.setup()
        finally:
            if w:
@@ -1313,6 +1316,7 @@ class PartitionDevice(StorageDevice):
                                            end=geometry.end)

            self.disk.format.commit()
+            self._currentSize = partition.getSize()

    def destroy(self):
        """ Destroy the device. """
@@ -1426,6 +1430,14 @@ class PartitionDevice(StorageDevice):
        else:
            return self.format.maxSize

+    @property
+    def currentSize(self):
+        """ The device's actual size. """
+        if self.exists:
+            return self._currentSize
+        else:
+            return 0
+

class DMDevice(StorageDevice):
    """ A device-mapper device """


- -- David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkt6yLQACgkQ5hsjjIy1Vkk11wCaA9cPrq0wLxVnkkKfBKcWNKop
FYcAoIwwa7lfgW4TVdcgotAQ3+5oyin4
=Ojqe
-----END PGP SIGNATURE-----

_______________________________________________
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