]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: offload dumping cache stats to the object store
authorMohamad Gebai <mgebai@suse.com>
Wed, 3 Oct 2018 19:31:20 +0000 (15:31 -0400)
committerMohamad Gebai <mgebai@suse.com>
Wed, 10 Oct 2018 15:45:51 +0000 (11:45 -0400)
Signed-off-by: Mohamad Gebai <mgebai@suse.com>
src/os/ObjectStore.h
src/os/bluestore/BlueStore.h
src/osd/OSD.cc

index 8a737e733d6580e5d2a881b1981f4930083a0b24..79303716ca5c96d14e44717c09990ad8b6c458dc 100644 (file)
@@ -1479,11 +1479,10 @@ public:
 
   virtual void get_db_statistics(Formatter *f) { }
   virtual void generate_db_histogram(Formatter *f) { }
-  virtual int flush_cache(ostream *os = NULL) { return 0; }
+  virtual int flush_cache(ostream *os = NULL) { return -1; }
   virtual void dump_perf_counters(Formatter *f) {}
-  virtual int get_cache_obj_count() {
-    return -1;
-  }
+  virtual void dump_cache_stats(Formatter *f) {}
+  virtual void dump_cache_stats(ostream& os) {}
 
   virtual string get_type() = 0;
 
index 8a4b759eb7c8af4ae345c71e10a974160c8d783b..c1dee1e5662bec806364baa6f92fa6d300966633 100644 (file)
@@ -2333,12 +2333,23 @@ public:
   int _fsck(bool deep, bool repair);
 
   void set_cache_shards(unsigned num) override;
-  int get_cache_obj_count() {
-    int count = 0;
+  void dump_cache_stats(Formatter *f) override {
+    int onode_count = 0, buffers_bytes = 0;
     for (auto i: cache_shards) {
-      count += i->_get_num_onodes();
+      onode_count += i->_get_num_onodes();
+      buffers_bytes += i->_get_buffer_bytes();
     }
-    return count;
+    f->dump_int("bluestore_onode", onode_count);
+    f->dump_int("bluestore_buffers", buffers_bytes);
+  }
+  void dump_cache_stats(ostream& ss) override {
+    int onode_count = 0, buffers_bytes = 0;
+    for (auto i: cache_shards) {
+      onode_count += i->_get_num_onodes();
+      buffers_bytes += i->_get_buffer_bytes();
+    }
+    ss << "bluestore_onode: " << onode_count;
+    ss << "bluestore_buffers: " << buffers_bytes;
   }
 
   int validate_hobject_key(const hobject_t &obj) const override {
index 3eb2140d335356f458e099d6cfd9af61eacf2d68..8fe60b8c0ebdb478b6fcf680e04bdb3e610d4524 100644 (file)
@@ -6023,8 +6023,8 @@ COMMAND("smart name=devid,type=CephString,req=False",
 COMMAND("drop cache",
         "Drop all OSD caches",
         "osd", "rw", "cli,rest")
-COMMAND("get_cache_object_count",
-        "Get OSD caches object count",
+COMMAND("get cache stats",
+        "Get OSD caches statistics",
         "osd", "r", "cli,rest")
 };
 
@@ -6524,8 +6524,7 @@ int OSD::_do_command(
     }
   }
 
-  else if (prefix == "get_cache_object_count") {
-    int store_cache_count = store->get_cache_obj_count();
+  else if (prefix == "get cache stats") {
     int obj_ctx_count = 0;
     int osd_map_count = service.map_cache.get_count();
     vector<PGRef> pgs;
@@ -6534,15 +6533,15 @@ int OSD::_do_command(
       obj_ctx_count += pg->get_cache_obj_count();
     }
     if (f) {
-      f->open_object_section("caches_object_count");
+      f->open_object_section("cache_stats");
       f->dump_int("object_ctx", obj_ctx_count);
-      f->dump_int("objectstore_onode", store_cache_count);
+      store->dump_cache_stats(f.get());
       f->dump_int("osd_map", osd_map_count);
       f->close_section();
       f->flush(ds);
     } else {
       ds << "object_ctx: " << obj_ctx_count;
-      ds << "objectstore_onode: " << store_cache_count;
+      store->dump_cache_stats(ds);
       ds << "osd_map: " << osd_map_count;
     }
   }