From 9e0aaa49a842135b289fca3b1b47ea13f7a1271c Mon Sep 17 00:00:00 2001 From: Jonas Pfefferle Date: Thu, 25 Mar 2021 12:55:47 +0100 Subject: [PATCH] ceph-volume: data_allocate_pct: allocate percentage Add data-allocate-pct to ceph-volume lvm batch to allow to only allocate a certain percentage of a drive, e.g. to reduce wear leveling impact on SSDs. Signed-off-by: Jonas Pfefferle --- src/ceph-volume/ceph_volume/devices/lvm/batch.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/batch.py b/src/ceph-volume/ceph_volume/devices/lvm/batch.py index 40c0fea4eec..94ab26888ea 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/batch.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/batch.py @@ -1,6 +1,7 @@ import argparse from collections import namedtuple import json +import math import logging from textwrap import dedent from ceph_volume import terminal, decorators @@ -53,7 +54,7 @@ def get_physical_osds(devices, args): data_slots = args.osds_per_device if args.data_slots: data_slots = max(args.data_slots, args.osds_per_device) - rel_data_size = 1.0 / data_slots + rel_data_size = args.data_allocate_fraction / data_slots mlogger.debug('relative data size: {}'.format(rel_data_size)) ret = [] for dev in devices: @@ -269,6 +270,17 @@ class Batch(object): ' if more slots then osds-per-device are specified, slots' 'will stay unoccupied'), ) + def data_allocate_fraction(pct): + pct_float = float(pct) + if math.isnan(pct_float) or pct_float == 0.0 or pct_float < 0.0 or pct_float > 1.0: + raise argparse.ArgumentTypeError('Percentage not in (0,1.0]') + return pct_float + parser.add_argument( + '--data-allocate-fraction', + type=data_allocate_fraction, + help='Fraction to allocate from data device (0,1.0]', + default=1.0 + ) parser.add_argument( '--block-db-size', type=disk.Size.parse, -- 2.39.5