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

[PATCH] Make sure that we tell the user that the LV has a smaller capacity than the



---
 iw/lvm_dialog_gui.py |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/iw/lvm_dialog_gui.py b/iw/lvm_dialog_gui.py
index 8b40890..c571146 100644
--- a/iw/lvm_dialog_gui.py
+++ b/iw/lvm_dialog_gui.py
@@ -818,17 +818,26 @@ class VolumeGroupEditor:
 	return pv
 
     def computeVGSize(self, pvlist, curpe):
-	availSpaceMB = 0L
-	for id in pvlist:
-	    pvreq = self.partitions.getRequestByID(id)
-	    pvsize = pvreq.getActualSize(self.partitions, self.diskset)
-	    # have to clamp pvsize to multiple of PE
-	    pvsize = lvm.clampPVSize(pvsize, curpe)
-
-	    availSpaceMB = availSpaceMB + pvsize
+        availSpaceMB = 0L
+        if self.origvgrequest.preexist and self.origvgrequest.preexist_size:
+            availSpaceMB = lvm.clampPVSize(self.origvgrequest.preexist_size, curpe)
+        else:
+            for id in pvlist:
+                pvreq = self.partitions.getRequestByID(id)
+                pvsize = pvreq.getActualSize(self.partitions, self.diskset)
+                # have to clamp pvsize to multiple of PE
+                clampedSize = lvm.clampPVSize(pvsize, curpe)
+                if pvsize == clampedSize:
+                    # This is a corner case were we say that the available size of the VG
+                    # is the total size of the paritition.  Given that the pvs need metadata
+                    # it is better to be on the safe side and give ourselves on pe of extra
+                    # space.
+                    clampedSize = clampedSize - (curpe / 1024)
+
+                availSpaceMB = availSpaceMB + clampedSize
 
         log.debug("computeVGSize: vgsize is %s" % (availSpaceMB,))
-	return availSpaceMB
+        return availSpaceMB
 
     def computeLVSpaceNeeded(self, logreqs, pesize):
 	neededSpaceMB = 0
-- 
1.5.6.5


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