From f49bcbdbf8652e9fd5f21b225e2c1fae24d98aaf Mon Sep 17 00:00:00 2001 From: Cory Snyder Date: Mon, 27 Feb 2023 04:48:08 -0500 Subject: [PATCH] ceph-volume: fix issue with fast device allocs when there are multiple PVs per VG Fixes a regression with fast device allocations when there are multiple PVs per VG. This is the case for clusters that were deployed prior to v15.2.8. Fixes: https://tracker.ceph.com/issues/58857 Signed-off-by: Cory Snyder (cherry picked from commit efcf71be18eb25be10a574d54b70229753538664) --- src/ceph-volume/ceph_volume/devices/lvm/batch.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/batch.py b/src/ceph-volume/ceph_volume/devices/lvm/batch.py index 90c4c22c407aa..72462ee785754 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/batch.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/batch.py @@ -114,16 +114,23 @@ def get_physical_fast_allocs(devices, type_, fast_slots_per_device, new_osds, ar ret = [] vg_device_map = group_devices_by_vg(devices) - for vg_devices in vg_device_map.values(): + for vg_name, vg_devices in vg_device_map.items(): for dev in vg_devices: if not dev.available_lvm: continue # any LV present is considered a taken slot occupied_slots = len(dev.lvs) + # prior to v15.2.8, db/wal deployments were grouping multiple fast devices into single VGs - we need to + # multiply requested_slots (per device) by the number of devices in the VG in order to ensure that + # abs_size is calculated correctly from vg_size + if vg_name == 'unused_devices': + slots_for_vg = requested_slots + else: + slots_for_vg = len(vg_devices) * requested_slots dev_size = dev.vg_size[0] # this only looks at the first vg on device, unsure if there is a better # way - abs_size = disk.Size(b=int(dev_size / requested_slots)) + abs_size = disk.Size(b=int(dev_size / slots_for_vg)) free_size = dev.vg_free[0] relative_size = int(abs_size) / dev_size if requested_size: @@ -149,7 +156,6 @@ def group_devices_by_vg(devices): result['unused_devices'] = [] for dev in devices: if len(dev.vgs) > 0: - # already using assumption that a PV only belongs to single VG in other places vg_name = dev.vgs[0].name if vg_name in result: result[vg_name].append(dev) -- 2.39.5