]> 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>
Sat, 25 Jul 2020 10:55:22 +0000 (13:55 +0300)
Using admin socket interface: bluestore allocator fragmentation
[block|bluefs-db|bluefs-wal|bluefs-slow]

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(cherry picked from commit 11b5feb01d273365c32ec6419faead629fb8c20b)

src/os/bluestore/Allocator.cc

index 507203f0e7f633fa567683eb05bb8dd1fd785449..25cb331880a534ecf1e525145256efbb5343918c 100644 (file)
@@ -35,6 +35,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);
       }
     }
   }
@@ -46,6 +51,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);
     }
   }
 
@@ -79,6 +86,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;