]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-bluestore-tool: add 'bluefs-bdev-sizes' command
authorSage Weil <sage@redhat.com>
Thu, 7 Sep 2017 22:20:27 +0000 (18:20 -0400)
committerSage Weil <sage@redhat.com>
Thu, 14 Sep 2017 16:15:01 +0000 (12:15 -0400)
Show bdev sizes vs owned extents.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h
src/os/bluestore/bluestore_tool.cc

index 33561406c3764c62d0845416cdadda4132c07b9f..e3ffff2600fda6a50cd02af695ca79de6a4422bd 100644 (file)
@@ -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<pair<uint64_t,uint64_t>> *usage)
 {
index 1b38a6ab1d493840046c58a8bcdb0c7ff547f920..36b41b451bbe5a66168e35794ee0033dd5c498f4 100644 (file)
@@ -342,6 +342,8 @@ public:
   void get_usage(vector<pair<uint64_t,uint64_t>> *usage); // [<free,total> ...]
   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<uint64_t> *extents);
 
index cb9e5378175da615e664ad01fcc97b4203177717..ee4ba5839a599864e4a9b71bd4f229f0c0b6f029 100644 (file)
@@ -139,7 +139,7 @@ int main(int argc, char **argv)
     ;
   po::options_description po_positional("Positional options");
   po_positional.add_options()
-    ("command", po::value<string>(&action), "fsck, repair, bluefs-export, show-label")
+    ("command", po::value<string>(&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<const char*> 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);