]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: implement original allocator fragmentation inspection.
authorIgor Fedotov <ifedotov@suse.com>
Mon, 19 Aug 2019 12:51:51 +0000 (15:51 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Mon, 19 Aug 2019 12:51:51 +0000 (15:51 +0300)
Using admin socket interface: bluestore allocator fragmentation
[block|bluefs-db|bluefs-wal|bluefs-slow]

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/os/bluestore/Allocator.cc

index d6f3b03696e7ef0c464d93486ba8d39e080304b2..eb8cd26c7398196ad3f03e9f476be4e78a986944 100644 (file)
@@ -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;