From 9e492f2a2217ee94670e9e0d6cf28e4b7bff5ad0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 7 Sep 2017 18:20:27 -0400 Subject: [PATCH] ceph-bluestore-tool: add 'bluefs-bdev-sizes' command Show bdev sizes vs owned extents. Signed-off-by: Sage Weil --- src/os/bluestore/BlueFS.cc | 10 ++++++++++ src/os/bluestore/BlueFS.h | 2 ++ src/os/bluestore/bluestore_tool.cc | 21 ++++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 33561406c37..e3ffff2600f 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -255,6 +255,16 @@ void BlueFS::dump_perf_counters(Formatter *f) f->close_section(); } +void BlueFS::dump_block_extents(ostream& out) +{ + for (unsigned i = 0; i < MAX_BDEV; ++i) { + if (!bdev[i]) { + continue; + } + out << i << " : size 0x" << std::hex << bdev[i]->get_size() + << " : own 0x" << block_all[i] << std::dec << "\n"; + } +} void BlueFS::get_usage(vector> *usage) { diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 1b38a6ab1d4..36b41b451bb 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -342,6 +342,8 @@ public: void get_usage(vector> *usage); // [ ...] void dump_perf_counters(Formatter *f); + void dump_block_extents(ostream& out); + /// get current extents that we own for given block device int get_block_extents(unsigned id, interval_set *extents); diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index cb9e5378175..ee4ba5839a5 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -139,7 +139,7 @@ int main(int argc, char **argv) ; po::options_description po_positional("Positional options"); po_positional.add_options() - ("command", po::value(&action), "fsck, repair, bluefs-export, show-label") + ("command", po::value(&action), "fsck, repair, bluefs-export, bluefs-bdev-sizes, show-label") ; po::options_description po_all("All options"); po_all.add(po_options).add(po_positional); @@ -207,6 +207,20 @@ int main(int argc, char **argv) } } } + if (action == "bluefs-bdev-sizes") { + if (path.empty()) { + cerr << "must specify bluestore path" << std::endl; + exit(EXIT_FAILURE); + } + cout << "infering bluefs devices from bluestore path" << std::endl; + for (auto fn : {"block", "block.wal", "block.db"}) { + string p = path + "/" + fn; + struct stat st; + if (::stat(p.c_str(), &st) == 0) { + devs.push_back(p); + } + } + } vector args; for (auto& i : ceph_option_strings) { @@ -253,6 +267,11 @@ int main(int argc, char **argv) jf.close_section(); jf.flush(cout); } + else if (action == "bluefs-bdev-sizes") { + BlueFS *fs = open_bluefs(cct.get(), path, devs); + fs->dump_block_extents(cout); + delete fs; + } else if (action == "bluefs-export") { BlueFS *fs = open_bluefs(cct.get(), path, devs); -- 2.39.5