]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: use extents instead of size when creating block.db lvs
authorAndrew Schoen <aschoen@redhat.com>
Tue, 27 Nov 2018 23:39:38 +0000 (17:39 -0600)
committerJan Fajerski <jfajerski@suse.com>
Fri, 19 Jul 2019 10:43:39 +0000 (12:43 +0200)
In the batch command use extents instead of size when creating lvs. This
gives a more precise size and avoids rounding errors.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
(cherry picked from commit add9f88dc800913adf387c90cbf4352e392b0a75)

 Conflicts:
src/ceph-volume/ceph_volume/devices/lvm/strategies/bluestore.py
        remove json import; pick ours and add self.use_large_block_db = False

(cherry picked from commit 83e71842d8cd77b7d45efdd344bd8fac31078745)

src/ceph-volume/ceph_volume/devices/lvm/strategies/bluestore.py

index ee269a39463f799c79885d1b9d0aaf11ea42baa7..42c10296962f5bd0b7ce109fc76224a9473ce61c 100644 (file)
@@ -1,5 +1,5 @@
 from __future__ import print_function
-from ceph_volume.util import disk, prepare
+from ceph_volume.util import disk, prepare, str_to_int
 from ceph_volume.api import lvm
 from . import validators
 from .strategies import Strategy
@@ -129,6 +129,7 @@ class MixedType(MixedStrategy):
         self.block_db_size = self.get_block_size()
         self.system_vgs = lvm.VolumeGroups()
         self.dbs_needed = len(self.hdds) * self.osds_per_device
+        self.use_large_block_db = False
         self.validate_compute()
 
     @staticmethod
@@ -186,6 +187,7 @@ class MixedType(MixedStrategy):
         # as possible from looking at extents
         if self.block_db_size.b == 0:
             self.block_db_size = disk.Size(b=self.vg_extents['sizes'])
+            self.use_large_block_db = True
 
         if not self.common_vg:
             # there isn't a common vg, so a new one must be created with all
@@ -243,11 +245,6 @@ class MixedType(MixedStrategy):
         else:
             db_vg = self.common_vg
 
-        # since we are falling back to a block_db_size that might be "as large
-        # as possible" we can't fully rely on LV format coming from the helper
-        # function that looks up this value
-        block_db_size = "%sG" % self.block_db_size.gb.as_int()
-
         # create 1 vg per data device first, mapping them to the device path,
         # when the lv gets created later, it can create as many as needed (or
         # even just 1)
@@ -257,6 +254,13 @@ class MixedType(MixedStrategy):
                 vg = lvm.create_vg(osd['data']['path'], name_prefix='ceph-block')
                 data_vgs[osd['data']['path']] = vg
 
+        if self.use_large_block_db:
+            # make the block.db lvs as large as possible
+            vg_free_count = str_to_int(db_vg.vg_free_count)
+            db_lv_extents = int(vg_free_count / self.dbs_needed)
+        else:
+            db_lv_extents = db_vg.sizing(size=self.block_db_size.gb.as_int())['extents']
+
         # create the data lvs, and create the OSD with an lv from the common
         # block.db vg from before
         for osd in self.computed['osds']:
@@ -268,7 +272,7 @@ class MixedType(MixedStrategy):
                 'osd-block', data_vg.name, extents=data_lv_extents, uuid_name=True
             )
             db_lv = lvm.create_lv(
-                'osd-block-db', db_vg.name, size=block_db_size, uuid_name=True
+                'osd-block-db', db_vg.name, extents=db_lv_extents, uuid_name=True
             )
             command = [
                 '--bluestore',