[f22-branch 2/2] Prevent aligning too big sizes to multiples of PE size

vpodzime installerbot-noreply at redhat.com
Tue Mar 17 08:36:56 UTC 2015


From: Vratislav Podzimek <vpodzime at redhat.com>

Format's (usually file system's) max size may be much bigger than max LV size
and trying to align max format's size may lead to issues with too big numbers
passed to libblockdev. We should prevent such issues by having the max LV size
as one of the limits when calculating maximum growth of an LV requested to grow
and by doing alignment (to PEs) only on the real limit not all potential limits
which may be much bigger.

Related: rhbz#1200812
---
 blivet/partitioning.py | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/blivet/partitioning.py b/blivet/partitioning.py
index 9c3f47d..966e56a 100644
--- a/blivet/partitioning.py
+++ b/blivet/partitioning.py
@@ -936,16 +936,15 @@ def __init__(self, lv):
         self.base = int(lv.vg.align(lv.req_size, roundup=True) // lv.vg.peSize)
 
         if lv.req_grow:
-            limits = [int(l // lv.vg.peSize) for l in
-                        (lv.vg.align(lv.req_max_size),
-                         lv.vg.align(lv.format.maxSize)) if l > Size(0)]
-
-            if limits:
-                max_units = min(limits)
-                self.max_growth = max_units - self.base
-                if self.max_growth <= 0:
-                    # max size is less than or equal to base, so we're done
-                    self.done = True
+            limit = min(l for l in (blockdev.lvm_get_max_lv_size(),
+                                    lv.req_max_size, lv.format.maxSize) if l > Size(0))
+
+            limit = lv.vg.align(limit)
+            max_units = int(limit // lv.vg.peSize)
+            self.max_growth = max_units - self.base
+            if self.max_growth <= 0:
+                # max size is less than or equal to base, so we're done
+                self.done = True
 
 
 class Chunk(object):


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/3b3bd9565c2274758a0693906a4568dd8d5c5d70


More information about the anaconda-patches mailing list