From 62ffc9aac20258d9c5723aa595633de84d3b9b86 Mon Sep 17 00:00:00 2001 From: Mohamad Gebai Date: Wed, 3 Oct 2018 15:31:20 -0400 Subject: [PATCH] osd: offload dumping cache stats to the object store Signed-off-by: Mohamad Gebai --- src/os/ObjectStore.h | 7 +++---- src/os/bluestore/BlueStore.h | 19 +++++++++++++++---- src/osd/OSD.cc | 13 ++++++------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 8a737e733d658..79303716ca5c9 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -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; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 8a4b759eb7c8a..c1dee1e5662be 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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 { diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 3eb2140d33535..8fe60b8c0ebdb 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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 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; } } -- 2.39.5