[anaconda:rhel7 2/2] Changes for scheduling size change on an existing device (#1076055)

mulhern amulhern at redhat.com
Tue Sep 30 17:20:11 UTC 2014


Related: rhbz#1076055

When changing size, the device which gets its size changed is always the
raw device.

Do a little ad-hoc adjustment of the size in case the raw device and the
device that the user sees the size of are different.
Since the only situation where these are different is with a LUKS device
use crypto constant for the adjustment.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 pyanaconda/ui/gui/spokes/custom.py | 39 ++++++++++++++++++++++++--------------
 1 file changed, 25 insertions(+), 14 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index c33d30f..0190cfb 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -1618,36 +1618,44 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
                 self.__storage.resetDevice(original_device)
 
         if changed_size:
+            # If a LUKS device is being displayed, adjust the size
+            # to the appropriate size for the raw device.
+            use_size = size
+            use_old_size = old_size
+            if use_dev is not device:
+                use_size = size + crypto.LUKS_METADATA_SIZE
+                use_old_size = use_dev.size
+
             # If no size was specified, we just want to grow to
             # the maximum.  But resizeDevice doesn't take None for
             # a value.
-            if not size:
-                size = device.maxSize
-            elif size < device.minSize:
-                size = device.minSize
-            elif size > device.maxSize:
-                size = device.maxSize
+            if not use_size:
+                use_size = use_dev.maxSize
+            elif use_size < use_dev.minSize:
+                use_size = use_dev.minSize
+            elif use_size > use_dev.maxSize:
+                use_size = use_dev.maxSize
 
             # And then we need to re-check that the max size is actually
             # different from the current size.
             _changed_size = False
-            if size != device.size and size == device.currentSize:
+            if use_size != use_dev.size and use_size == use_dev.currentSize:
                 # size has been set back to its original value
                 actions = self.__storage.devicetree.findActions(action_type="resize",
-                                                                devid=device.id)
+                                                                devid=use_dev.id)
                 with ui_storage_logger():
                     for action in reversed(actions):
                         self.__storage.devicetree.cancelAction(action)
                         _changed_size = True
-            elif size != device.size:
-                log.debug("scheduling resize of device %s to %s", device.name, size)
+            elif use_size != use_dev.size:
+                log.debug("scheduling resize of device %s to %s", use_dev.name, use_size)
 
                 with ui_storage_logger():
                     try:
-                        self.__storage.resizeDevice(device, size)
+                        self.__storage.resizeDevice(use_dev, use_size)
                     except StorageError as e:
                         log.error("failed to schedule device resize: %s", e)
-                        device.size = old_size
+                        use_dev.size = use_old_size
                         self._error = e
                         self.set_warning(_("Device resize request failed. "
                                            "Click for details."))
@@ -1656,10 +1664,13 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
                         _changed_size = True
 
             if _changed_size:
-                log.debug("new size: %s", device.size)
-                log.debug("target size: %s", device.targetSize)
+                log.debug("new size: %s", use_dev.size)
+                log.debug("target size: %s", use_dev.targetSize)
 
                 # update the selector's size property
+                # The selector shows the visible disk, so it is necessary
+                # to use device and size, which are the values visible to
+                # the user.
                 for s in self._accordion.allSelectors:
                     if s._device == device:
                         s.size = str(device.size)
-- 
1.9.3



More information about the anaconda-patches mailing list