]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/bluefs: add inspection of bluefs files 33237/head
authorAdam Kupczyk <akupczyk@redhat.com>
Wed, 12 Feb 2020 10:38:48 +0000 (11:38 +0100)
committerAdam Kupczyk <akupczyk@redhat.com>
Tue, 28 Apr 2020 13:00:32 +0000 (15:00 +0200)
Add command "bluefs files list" that lists files in bluefs
and allows to see on which device they are located.

Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
src/os/bluestore/BlueFS.cc

index 7b5399e44d7bdee51f96bdda3b4d8c97b45bb48e..fe37909df9555985f337b51f0a64070c5b5f8480 100644 (file)
@@ -86,6 +86,9 @@ public:
                                            "Dump internal statistics for bluefs."
                                            "");
         ceph_assert(r == 0);
+       r = admin_socket->register_command("bluefs files list", hook,
+                                          "print files in bluefs");
+       ceph_assert(r == 0);
       }
     }
     return hook;
@@ -132,6 +135,33 @@ private:
       bluefs->dump_block_extents(ss);
       bluefs->dump_volume_selector(ss);
       out.append(ss);
+    } else if (command == "bluefs files list") {
+      const char* devnames[3] = {"wal","db","slow"};
+      std::lock_guard l(bluefs->lock);
+      f->open_array_section("files");
+      for (auto &d : bluefs->dir_map) {
+        std::string dir = d.first;
+        for (auto &r : d.second->file_map) {
+          f->open_object_section("file");
+          f->dump_string("name", (dir + "/" + r.first).c_str());
+          std::vector<size_t> sizes;
+          sizes.resize(bluefs->bdev.size());
+          for(auto& i : r.second->fnode.extents) {
+            sizes[i.bdev] += i.length;
+          }
+          for (size_t i = 0; i < sizes.size(); i++) {
+            if (sizes[i]>0) {
+             if (i < sizeof(devnames) / sizeof(*devnames))
+               f->dump_int(devnames[i], sizes[i]);
+             else
+               f->dump_int(("dev-"+to_string(i)).c_str(), sizes[i]);
+           }
+          }
+          f->close_section();
+        }
+      }
+      f->close_section();
+      f->flush(out);
     } else {
       errss << "Invalid command" << std::endl;
       return -ENOSYS;