From: Sage Weil Date: Thu, 30 Mar 2017 20:32:31 +0000 (-0400) Subject: ceph-bluestore-tool: accept bluestore base path X-Git-Tag: v12.0.2~185^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a87267f1648bb5f76890005c456414e60597e778;p=ceph.git ceph-bluestore-tool: accept bluestore base path Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index 7ae4fd6b1bc81..6174ed55e0083 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -29,10 +29,12 @@ int main(int argc, char **argv) { string out_dir; vector devs; + string path; string action; po::options_description po_options("Options"); po_options.add_options() ("help,h", "produce help message") + ("path", po::value(&path), "bluestore path") ("out-dir", po::value(&out_dir), "output directory") ("dev", po::value>(&devs), "device(s)") ; @@ -68,9 +70,26 @@ int main(int argc, char **argv) return 1; } - if (devs.empty()) { - cerr << "must specify one or more device(s)" << std::endl; - exit(1); + if (action == "fsck") { + if (path.empty()) { + cerr << "must specify bluestore path" << std::endl; + exit(1); + } + } + if (action == "bluefs-export" || + action == "show-label") { + if (devs.empty() && path.empty()) { + cerr << "must specify bluestore path *or* raw device(s)" << std::endl; + exit(1); + } + 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; @@ -103,7 +122,7 @@ int main(int argc, char **argv) jf.close_section(); jf.flush(cout); } - if (action == "bluefs-export") { + else if (action == "bluefs-export") { if (out_dir.empty()) { cerr << "must specify out-dir to export bluefs" << std::endl; exit(1); @@ -201,6 +220,9 @@ int main(int argc, char **argv) } } fs.umount(); + } else { + cerr << "unrecognized action " << action << std::endl; + return 1; } return 0;