From 95f25ce092b2f17a4941e81464a8bf9a37585455 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 9 Jan 2014 20:36:13 -0800 Subject: [PATCH] mon/OSDMonitor: allow new pool policy fields to be set Signed-off-by: Sage Weil --- qa/workunits/cephtool/test.sh | 12 ++++++++++ src/mon/MonCommands.h | 2 +- src/mon/OSDMonitor.cc | 45 ++++++++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 33245f63de91a..f2117ac9806f8 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -398,6 +398,18 @@ ceph osd pool set rbd hit_set_period 123 ceph osd pool set rbd hit_set_count 12 ceph osd pool set rbd hit_set_fpp .01 +ceph osd pool set rbd target_max_objects 123 +ceph osd pool set rbd target_max_bytes 123456 +ceph osd pool set rbd cache_target_dirty_ratio .123 +expect_false ceph osd pool set rbd cache_target_dirty_ratio -.2 +expect_false ceph osd pool set rbd cache_target_dirty_ratio 1.1 +ceph osd pool set rbd cache_target_full_ratio .123 +ceph osd pool set rbd cache_target_full_ratio 1.0 +ceph osd pool set rbd cache_target_full_ratio 0 +expect_false ceph osd pool set rbd cache_target_full_ratio 1.1 +ceph osd pool set rbd cache_min_flush_age 123 +ceph osd pool set rbd cache_min_evict_age 234 + ceph osd pool get rbd crush_ruleset | grep 'crush_ruleset: 0' ceph osd thrash 10 diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index bc7921794fb33..219229467aeec 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -528,7 +528,7 @@ COMMAND("osd pool get " \ "get pool parameter ", "osd", "r", "cli,rest") COMMAND("osd pool set " \ "name=pool,type=CephPoolname " \ - "name=var,type=CephChoices,strings=size|min_size|crash_replay_interval|pg_num|pgp_num|crush_ruleset|hashpspool|hit_set_type|hit_set_period|hit_set_count|hit_set_fpp|debug_fake_ec_pool " \ + "name=var,type=CephChoices,strings=size|min_size|crash_replay_interval|pg_num|pgp_num|crush_ruleset|hashpspool|hit_set_type|hit_set_period|hit_set_count|hit_set_fpp|debug_fake_ec_pool||target_max_bytes|target_max_objects|cache_target_dirty_ratio|cache_target_full_ratio|cache_min_flush_age|cache_min_evict_age " \ "name=val,type=CephString", \ "set pool parameter to ", "osd", "rw", "cli,rest") // 'val' is a CephString because it can include a unit. Perhaps diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index c3359859b90e2..e0bef1f76f91e 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3229,7 +3229,50 @@ int OSDMonitor::prepare_command_pool_set(map &cmdmap, if (val == "true" || (interr.empty() && n == 1)) { p.flags |= pg_pool_t::FLAG_DEBUG_FAKE_EC_POOL; } - ss << " pool " << pool << " set debug_fake_ec_pool"; + } else if (var == "target_max_objects") { + if (interr.length()) { + ss << "error parsing int '" << val << "': " << interr; + return -EINVAL; + } + p.target_max_objects = n; + } else if (var == "target_max_bytes") { + if (interr.length()) { + ss << "error parsing int '" << val << "': " << interr; + return -EINVAL; + } + p.target_max_bytes = n; + } else if (var == "cache_target_dirty_ratio") { + if (floaterr.length()) { + ss << "error parsing float '" << val << "': " << floaterr; + return -EINVAL; + } + if (f < 0 || f > 1.0) { + ss << "value must be in the range 0..1"; + return -ERANGE; + } + p.cache_target_dirty_ratio_micro = f * 1000000; + } else if (var == "cache_target_full_ratio") { + if (floaterr.length()) { + ss << "error parsing float '" << val << "': " << floaterr; + return -EINVAL; + } + if (f < 0 || f > 1.0) { + ss << "value must be in the range 0..1"; + return -ERANGE; + } + p.cache_target_full_ratio_micro = n; + } else if (var == "cache_min_flush_age") { + if (interr.length()) { + ss << "error parsing int '" << val << "': " << interr; + return -EINVAL; + } + p.cache_min_flush_age = n; + } else if (var == "cache_min_evict_age") { + if (interr.length()) { + ss << "error parsing int '" << val << "': " << interr; + return -EINVAL; + } + p.cache_min_evict_age = n; } else { ss << "unrecognized variable '" << var << "'"; return -EINVAL; -- 2.39.5