From 11b5feb01d273365c32ec6419faead629fb8c20b Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Mon, 19 Aug 2019 15:51:51 +0300 Subject: [PATCH] os/bluestore: implement original allocator fragmentation inspection. Using admin socket interface: bluestore allocator fragmentation [block|bluefs-db|bluefs-wal|bluefs-slow] Signed-off-by: Igor Fedotov --- src/os/bluestore/Allocator.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/os/bluestore/Allocator.cc b/src/os/bluestore/Allocator.cc index d6f3b03696e..eb8cd26c739 100644 --- a/src/os/bluestore/Allocator.cc +++ b/src/os/bluestore/Allocator.cc @@ -34,6 +34,11 @@ public: this, "give score on allocator fragmentation (0-no fragmentation, 1-absolute fragmentation)"); ceph_assert(r == 0); + r = admin_socket->register_command(("bluestore allocator fragmentation " + name).c_str(), + ("bluestore allocator fragmentation " + name).c_str(), + this, + "give allocator fragmentation (0-no fragmentation, 1-absolute fragmentation)"); + ceph_assert(r == 0); } } } @@ -45,6 +50,8 @@ public: ceph_assert(r == 0); r = admin_socket->unregister_command(("bluestore allocator score " + name).c_str()); ceph_assert(r == 0); + r = admin_socket->unregister_command(("bluestore allocator fragmentation " + name).c_str()); + ceph_assert(r == 0); } } @@ -78,6 +85,13 @@ public: f->close_section(); f->flush(ss); delete f; + } else if (command == "bluestore allocator fragmentation " + name) { + Formatter* f = Formatter::create(format, "json-pretty", "json-pretty"); + f->open_object_section("fragmentation"); + f->dump_float("fragmentation_rating", alloc->get_fragmentation()); + f->close_section(); + f->flush(ss); + delete f; } else { ss << "Invalid command" << std::endl; r = false; -- 2.39.5