]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor : Fix pool set taget_size_bytes 31740/head
authorPrashant D <pdhange@redhat.com>
Thu, 3 Oct 2019 01:21:55 +0000 (21:21 -0400)
committerNathan Cutler <ncutler@suse.com>
Tue, 19 Nov 2019 15:54:07 +0000 (16:54 +0100)
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>
(cherry picked from commit f504e2d1e7fe3ee3797fa0f5402be1a1763087ef)

Conflicts:
    src/mon/OSDMonitor.cc
- osdmap.require_osd_release < CEPH_RELEASE_NAUTILUS

src/mon/OSDMonitor.cc

index 799e57f0fd5ad6b4a36498ea3c9831a55a1af302..12ec853f2fed215450a7d8a996855308b57dda58 100644 (file)
@@ -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<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" ||
@@ -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;