From: Prashant D Date: Thu, 3 Oct 2019 01:21:55 +0000 (-0400) Subject: mon/OSDMonitor : Fix pool set taget_size_bytes X-Git-Tag: v14.2.8~20^2~76^2~4^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=77040ae242cf8792e29ac75444ce8c62b00342b9;p=ceph.git mon/OSDMonitor : Fix pool set taget_size_bytes When setting target_size_bytes for pool, prepare command fail to parse values appended with valid units like M, G, T etc. Fixes : https://tracker.ceph.com/issues/42108 Signed-off-by: Prashant D (cherry picked from commit f504e2d1e7fe3ee3797fa0f5402be1a1763087ef) Conflicts: src/mon/OSDMonitor.cc - osdmap.require_osd_release < CEPH_RELEASE_NAUTILUS --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 799e57f0fd5..12ec853f2fe 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -7500,10 +7500,21 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap, int64_t uf = 0; // micro-f cmd_getval(cct, cmdmap, "val", val); - // parse string as both int and float; different fields use different types. - n = strict_strtoll(val.c_str(), 10, &interr); - f = strict_strtod(val.c_str(), &floaterr); - uf = llrintl(f * (double)1000000.0); + // create list of properties that use SI units + std::set si_items = {}; + // create list of properties that use IEC units + std::set iec_items = {"target_size_bytes"}; + + if (si_items.count(var)) { + n = strict_si_cast(val.c_str(), &interr); + } else if (iec_items.count(var)) { + n = strict_iec_cast(val.c_str(), &interr); + } else { + // parse string as both int and float; different fields use different types. + n = strict_strtoll(val.c_str(), 10, &interr); + f = strict_strtod(val.c_str(), &floaterr); + uf = llrintl(f * (double)1000000.0); + } if (!p.is_tier() && (var == "hit_set_type" || var == "hit_set_period" || @@ -8014,6 +8025,16 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap, return -EINVAL; } } + } else if (var == "target_size_bytes") { + if (interr.length()) { + ss << "error parsing unit value '" << val << "': " << interr; + return -EINVAL; + } + if (osdmap.require_osd_release < CEPH_RELEASE_NAUTILUS) { + ss << "must set require_osd_release to nautilus or " + << "later before setting target_size_bytes"; + return -EINVAL; + } } else if (var == "pg_num_min") { if (interr.length()) { ss << "error parsing int value '" << val << "': " << interr;