Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/bluestore/bluefs: add inspection of bluefs files #33237

Merged
merged 1 commit into from
May 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/os/bluestore/BlueFS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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;
Expand Down Expand Up @@ -132,6 +135,33 @@ class BlueFS::SocketHook : public AdminSocketHook {
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]);
aclamk marked this conversation as resolved.
Show resolved Hide resolved
}
}
f->close_section();
}
}
f->close_section();
f->flush(out);
} else {
errss << "Invalid command" << std::endl;
return -ENOSYS;
Expand Down