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: v15.1.0~1222^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f504e2d1e7fe3ee3797fa0f5402be1a1763087ef;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 --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index fbd231c0611..a6c8c16922f 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -7860,10 +7860,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" || @@ -8371,6 +8382,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_t::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;