]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: data_allocate_pct: allocate percentage
authorJonas Pfefferle <pepperjo@japf.ch>
Thu, 25 Mar 2021 11:55:47 +0000 (12:55 +0100)
committerJonas Pfefferle <pepperjo@japf.ch>
Thu, 3 Jun 2021 07:28:35 +0000 (09:28 +0200)
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 <pepperjo@japf.ch>
src/ceph-volume/ceph_volume/devices/lvm/batch.py

index 40c0fea4eec148d03715346bcbf552a8bd211662..94ab26888ea67d571573798f52d5b220f73e22ee 100644 (file)
@@ -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,