diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 03c1270859a8f8..5be9dff93878e6 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -68,6 +68,9 @@ class BlueFS::SocketHook : public AdminSocketHook { "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; @@ -112,6 +115,33 @@ class BlueFS::SocketHook : public AdminSocketHook { } else if (command == "bluestore bluefs stats") { bluefs->dump_block_extents(ss); bluefs->dump_volume_selector(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 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 { ss << "Invalid command" << std::endl; return -ENOSYS;