From a02132a1f95177bea20454a17bffb09d679a86f6 Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Fri, 4 Oct 2024 16:38:44 +0000 Subject: [PATCH] os/bluestore: Add 'bluefs-files' command to ceph-bluestore-tool. Modify 'bluefs files list' admin command to also print real file size. Add documentation for 'bluefs-files'. Extra: add missing documentation for 'bluefs-stats'. Signed-off-by: Adam Kupczyk --- doc/man/8/ceph-bluestore-tool.rst | 10 ++++++++++ src/os/bluestore/BlueFS.cc | 5 +++++ src/os/bluestore/bluestore_tool.cc | 23 ++++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/doc/man/8/ceph-bluestore-tool.rst b/doc/man/8/ceph-bluestore-tool.rst index 883d4dfd8f2..d1fc64c0276 100644 --- a/doc/man/8/ceph-bluestore-tool.rst +++ b/doc/man/8/ceph-bluestore-tool.rst @@ -27,6 +27,8 @@ Synopsis | **ceph-bluestore-tool** bluefs-bdev-new-db --path *osd path* --dev-target *new-device* | **ceph-bluestore-tool** bluefs-bdev-migrate --path *osd path* --dev-target *new-device* --devs-source *device1* [--devs-source *device2*] | **ceph-bluestore-tool** free-dump|free-score --path *osd path* [ --allocator block/bluefs-wal/bluefs-db/bluefs-slow ] +| **ceph-bluestore-tool** bluefs-stats --path *osd path* +| **ceph-bluestore-tool** bluefs-files --path *osd path* | **ceph-bluestore-tool** reshard --path *osd path* --sharding *new sharding* [ --sharding-ctrl *control string* ] | **ceph-bluestore-tool** show-sharding --path *osd path* | **ceph-bluestore-tool** trim --path *osd path* @@ -121,6 +123,14 @@ Commands Give a [0-1] number that represents quality of fragmentation in allocator. 0 represents case when all free space is in one chunk. 1 represents worst possible fragmentation. +:command:`bluefs-stats` --path *osd path* + + Shows summary of BlueFS occupied space with split on devices: block/db/wal and roles: wal/log/db. + +:command:`bluefs-files` --path *osd path* + + Lists all BlueFS managed files, printing name, size and space used on devices. + :command:`reshard` --path *osd path* --sharding *new sharding* [ --resharding-ctrl *control string* ] Changes sharding of BlueStore's RocksDB. Sharding is build on top of RocksDB column families. diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index e123a0a200a..cbc0b967b4e 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -161,6 +161,7 @@ private: std::string dir = d.first; for (auto &r : d.second->file_map) { f->open_object_section("file"); + f->dump_int("ino", r.second->fnode.ino); f->dump_string("name", (dir + "/" + r.first).c_str()); std::vector sizes; sizes.resize(bluefs->bdev.size()); @@ -175,6 +176,10 @@ private: f->dump_int(("dev-"+to_string(i)).c_str(), sizes[i]); } } + f->dump_int("size", r.second->fnode.size); + std::stringstream ss; + ss << r.second->fnode.mtime; + f->dump_string("mtime", ss.str()); f->close_section(); } } diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index 16f1e6434e0..c68cc9d1b42 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -1190,7 +1190,28 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } cout << std::string(out.c_str(), out.length()) << std::endl; - bluestore.cold_close(); + bluestore.cold_close(); + } else if (action == "bluefs-files") { + AdminSocket* admin_socket = g_ceph_context->get_admin_socket(); + ceph_assert(admin_socket); + validate_path(cct.get(), path, false); + BlueStore bluestore(cct.get(), path); + int r = bluestore.cold_open(); + if (r < 0) { + cerr << "error from cold_open: " << cpp_strerror(r) << std::endl; + exit(EXIT_FAILURE); + } + ceph::bufferlist in, out; + ostringstream err; + r = admin_socket->execute_command( + { "{\"prefix\": \"bluefs files list\"}" }, + in, err, &out); + if (r != 0) { + cerr << "failure querying bluefs stats: " << cpp_strerror(r) << std::endl; + exit(EXIT_FAILURE); + } + cout << std::string(out.c_str(), out.length()) << std::endl; + bluestore.cold_close(); } else if (action == "reshard") { auto get_ctrl = [&](size_t& val) { if (!resharding_ctrl.empty()) { -- 2.39.5