]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/: make heap properties settable via admin socket 7512/head
authorSamuel Just <sjust@redhat.com>
Wed, 20 Jan 2016 22:54:51 +0000 (14:54 -0800)
committerSamuel Just <sjust@redhat.com>
Wed, 20 Jan 2016 22:54:51 +0000 (14:54 -0800)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/osd/OSD.cc
src/perfglue/disabled_heap_profiler.cc
src/perfglue/heap_profiler.cc
src/perfglue/heap_profiler.h

index 23328b5746a6fa7ee5eb67804eba6faee3c26a94..1685839aa18daff2ff35edeb4a17ad8d3f1ef9c6 100644 (file)
@@ -1781,6 +1781,30 @@ bool OSD::asok_command(string command, cmdmap_t& cmdmap, string format,
     f->close_section();
   } else if (command == "get_latest_osdmap") {
     get_latest_osdmap();
+  } else if (command == "set_heap_property") {
+    string property;
+    int64_t value = 0;
+    string error;
+    bool success = false;
+    if (!cmd_getval(cct, cmdmap, "property", property)) {
+      error = "unable to get property";
+      success = false;
+    } else if (!cmd_getval(cct, cmdmap, "value", value)) {
+      error = "unable to get value";
+      success = false;
+    } else if (value < 0) {
+      error = "negative value not allowed";
+      success = false;
+    } else if (!ceph_heap_set_numeric_property(property.c_str(), (size_t)value)) {
+      error = "invalid property";
+      success = false;
+    } else {
+      success = true;
+    }
+    f->open_object_section("result");
+    f->dump_string("error", error);
+    f->dump_bool("success", success);
+    f->close_section();
   } else if (command == "get_heap_property") {
     string property;
     size_t value = 0;
@@ -2089,6 +2113,14 @@ void OSD::final_init()
                                     "the mon");
   assert(r == 0);
 
+  r = admin_socket->register_command("set_heap_property",
+                                    "set_heap_property " \
+                                    "name=property,type=CephString " \
+                                    "name=value,type=CephInt",
+                                    asok_hook,
+                                    "update malloc extension heap property");
+  assert(r == 0);
+
   r = admin_socket->register_command("get_heap_property",
                                     "get_heap_property " \
                                     "name=property,type=CephString",
@@ -2408,6 +2440,7 @@ int OSD::shutdown()
   cct->get_admin_socket()->unregister_command("dump_watchers");
   cct->get_admin_socket()->unregister_command("dump_reservations");
   cct->get_admin_socket()->unregister_command("get_latest_osdmap");
+  cct->get_admin_socket()->unregister_command("set_heap_property");
   cct->get_admin_socket()->unregister_command("get_heap_property");
   delete asok_hook;
   asok_hook = NULL;
index 64a2939098a18cf94e03f9d1cb9ed4ac63d952ec..238ab4ad83c7305344b3ae9b5ef8e2eda15596b7 100644 (file)
@@ -34,5 +34,10 @@ bool ceph_heap_get_numeric_property(const char *property, size_t *value)
   return false;
 }
 
+bool ceph_heap_set_numeric_property(const char *property, size_t value)
+{
+  return false;
+}
+
 void ceph_heap_profiler_handle_command(const std::vector<std::string>& cmd,
                                        ostream& out) { return; }
index a2eeaf1195aa1b9c55c5a3941f8ea0d3dcb0c3af..685b4be5738098cea5675d5638e8d8a57e3b37e8 100644 (file)
@@ -67,6 +67,14 @@ bool ceph_heap_get_numeric_property(
     value);
 }
 
+bool ceph_heap_set_numeric_property(
+  const char *property, size_t value)
+{
+  return MallocExtension::instance()->SetNumericProperty(
+    property,
+    value);
+}
+
 bool ceph_heap_profiler_running()
 {
 #ifdef HAVE_LIBTCMALLOC
index 36bc8c18e814a0c4a6ffe79543c8f94674f43cfd..75fba8ac338204d140b56a4196f8a45f350c9ec9 100644 (file)
@@ -45,6 +45,8 @@ void ceph_heap_profiler_dump(const char *reason);
 
 bool ceph_heap_get_numeric_property(const char *property, size_t *value);
 
+bool ceph_heap_set_numeric_property(const char *property, size_t value);
+
 void ceph_heap_profiler_handle_command(const std::vector<std::string> &cmd,
                                        ostream& out);