]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor : Fix pool set taget_size_bytes 30701/head
authorPrashant D <pdhange@redhat.com>
Thu, 3 Oct 2019 01:21:55 +0000 (21:21 -0400)
committerPrashant D <pdhange@redhat.com>
Mon, 7 Oct 2019 11:06:45 +0000 (07:06 -0400)
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 <pdhange@redhat.com>
src/mon/OSDMonitor.cc

index fbd231c06119dac28f07d3133b6b171760761036..a6c8c16922f366bd2220d6a667ba9b8075b0dc2a 100644 (file)
@@ -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<std::string> si_items = {};
+  // create list of properties that use IEC units
+  std::set<std::string> iec_items = {"target_size_bytes"};
+
+  if (si_items.count(var)) {
+    n = strict_si_cast<int64_t>(val.c_str(), &interr);
+  } else if (iec_items.count(var)) {
+    n = strict_iec_cast<int64_t>(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;