Skip to content

Commit

Permalink
ceph-volume: use extents instead of size when creating block.db lvs
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
andrewschoen committed Dec 6, 2018
1 parent 893b61b commit add9f88
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/ceph-volume/ceph_volume/devices/lvm/strategies/bluestore.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import print_function
import json
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 ceph_volume.devices.lvm.create import Create
Expand Down Expand Up @@ -154,6 +154,8 @@ def __init__(self, devices, args):
self.block_db_size = self.get_block_size()
self.system_vgs = lvm.VolumeGroups()
self.dbs_needed = len(self.hdds) * self.osds_per_device
# use block.db lvs that are as large as possible
self.use_large_block_db = False
if self.devices:
self.validate()
self.compute()
Expand Down Expand Up @@ -218,6 +220,7 @@ def compute(self):
# 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
Expand Down Expand Up @@ -275,11 +278,6 @@ def execute(self):
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)
Expand All @@ -289,6 +287,13 @@ def execute(self):
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']:
Expand All @@ -300,7 +305,7 @@ def execute(self):
'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',
Expand Down

0 comments on commit add9f88

Please sign in to comment.