From ef820f07d19b71096e55beafa6ef3770995b2344 Mon Sep 17 00:00:00 2001 From: Dmitrii Shcherbakov Date: Fri, 25 Aug 2017 01:16:46 +0300 Subject: [PATCH] handle wal and db similarly to filestore journal ceph-disk uses the same logic for partitioning if wal and db are put on devices separate from the data device: it will use sgdisk to find the next available partition to put wal or db to. This is no different from the filestore partitioning behavior so we can just reuse this logic here fs-type option is filestore-specific so let's filter it out if bluestore is used. osd_format is a file system format for FileStore so this becomes irrelevant. also, rename least_used_journal finding function to a more generic name to handle "utility" devices (journals, WALs, db-devices etc.) Partial-Bug: #1710474 Change-Id: I483ee9dae4ce69c71ae06359d0fb96aaa1c56cbc --- ceph/utils.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ceph/utils.py b/ceph/utils.py index 19192de..0fd3e80 100644 --- a/ceph/utils.py +++ b/ceph/utils.py @@ -1355,8 +1355,17 @@ def get_partitions(dev): return [] -def find_least_used_journal(journal_devices): - usages = map(lambda a: (len(get_partitions(a)), a), journal_devices) +def find_least_used_utility_device(utility_devices): + """ + Find a utility device which has the smallest number of partitions + among other devices in the supplied list. + + :utility_devices: A list of devices to be used for filestore journal + or bluestore wal or db. + :return: string device name + """ + + usages = map(lambda a: (len(get_partitions(a)), a), utility_devices) least = min(usages, key=lambda t: t[0]) return least[1] @@ -1427,18 +1436,20 @@ def osdize_dev(dev, osd_format, osd_journal, reformat_osd=False, wal = get_devices('bluestore-wal') if wal: cmd.append('--block.wal') - cmd.append(wal) + least_used_wal = find_least_used_utility_device(wal) + cmd.append(least_used_wal) db = get_devices('bluestore-db') if db: cmd.append('--block.db') - cmd.append(db) + least_used_db = find_least_used_utility_device(db) + cmd.append(least_used_db) elif cmp_pkgrevno('ceph', '12.1.0') >= 0 and not bluestore: cmd.append('--filestore') cmd.append(dev) if osd_journal: - least_used = find_least_used_journal(osd_journal) + least_used = find_least_used_utility_device(osd_journal) cmd.append(least_used) else: # Just provide the device - no other options