From: Sage Weil Date: Thu, 7 Sep 2017 16:27:35 +0000 (-0400) Subject: os/ObjectStore: add repair interface X-Git-Tag: v13.0.1~902^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c7b7a1f04f78fa62890c567d0ca53874c8d75eb7;p=ceph.git os/ObjectStore: add repair interface Signed-off-by: Sage Weil --- diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index cde284b6fbc5..8bc7de06b713 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -1534,6 +1534,9 @@ public: virtual int fsck(bool deep) { return -EOPNOTSUPP; } + virtual int repair(bool deep) { + return -EOPNOTSUPP; + } virtual void set_cache_shards(unsigned num) { } diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index c7c134051b6e..abac6ef994fb 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -82,7 +82,7 @@ int main(int argc, char **argv) ; po::options_description po_positional("Positional options"); po_positional.add_options() - ("command", po::value(&action), "fsck, bluefs-export, show-label") + ("command", po::value(&action), "fsck, repair, bluefs-export, show-label") ; po::options_description po_all("All options"); po_all.add(po_options).add(po_positional); @@ -112,7 +112,7 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } - if (action == "fsck") { + if (action == "fsck" || action == "repair") { if (path.empty()) { cerr << "must specify bluestore path" << std::endl; exit(EXIT_FAILURE); @@ -164,10 +164,15 @@ int main(int argc, char **argv) cout << "action " << action << std::endl; if (action == "fsck" || - action == "fsck-deep") { + action == "repair") { validate_path(cct.get(), path, false); BlueStore bluestore(cct.get(), path); - int r = bluestore.fsck(fsck_deep); + int r; + if (action == "fsck") { + r = bluestore.fsck(fsck_deep); + } else { + r = bluestore.repair(fsck_deep); + } if (r < 0) { cerr << "error from fsck: " << cpp_strerror(r) << std::endl; exit(EXIT_FAILURE); diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 143881966691..334068559337 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -2537,7 +2537,7 @@ int main(int argc, char **argv) ("pool", po::value(&pool), "Pool name, mandatory for apply-layout-settings if --pgid is not specified") ("op", po::value(&op), - "Arg is one of [info, log, remove, mkfs, fsck, fuse, dup, export, export-remove, import, list, fix-lost, list-pgs, rm-past-intervals, dump-journal, dump-super, meta-list, " + "Arg is one of [info, log, remove, mkfs, fsck, repair, fuse, dup, export, export-remove, import, list, fix-lost, list-pgs, rm-past-intervals, dump-journal, dump-super, meta-list, " "get-osdmap, set-osdmap, get-inc-osdmap, set-inc-osdmap, mark-complete, apply-layout-settings, update-mon-db]") ("epoch", po::value(&epoch), "epoch# for get-osdmap and get-inc-osdmap, the current epoch in use if not specified") @@ -2802,6 +2802,19 @@ int main(int argc, char **argv) cout << "fsck found no errors" << std::endl; return 0; } + if (op == "repair" || op == "repair-deep") { + int r = fs->repair(op == "repair-deep"); + if (r < 0) { + cerr << "repair failed: " << cpp_strerror(r) << std::endl; + return 1; + } + if (r > 0) { + cerr << "repair found " << r << " errors" << std::endl; + return 1; + } + cout << "repair found no errors" << std::endl; + return 0; + } if (op == "mkfs") { if (fsid.length()) { uuid_d f; @@ -2814,7 +2827,7 @@ int main(int argc, char **argv) } int r = fs->mkfs(); if (r < 0) { - cerr << "fsck failed: " << cpp_strerror(r) << std::endl; + cerr << "mkfs failed: " << cpp_strerror(r) << std::endl; return 1; } return 0; @@ -3218,7 +3231,7 @@ int main(int argc, char **argv) // If not an object command nor any of the ops handled below, then output this usage // before complaining about a bad pgid if (!vm.count("objcmd") && op != "export" && op != "export-remove" && op != "info" && op != "log" && op != "rm-past-intervals" && op != "mark-complete") { - cerr << "Must provide --op (info, log, remove, mkfs, fsck, export, export-remove, import, list, fix-lost, list-pgs, rm-past-intervals, dump-journal, dump-super, meta-list, " + cerr << "Must provide --op (info, log, remove, mkfs, fsck, repair, export, export-remove, import, list, fix-lost, list-pgs, rm-past-intervals, dump-journal, dump-super, meta-list, " "get-osdmap, set-osdmap, get-inc-osdmap, set-inc-osdmap, mark-complete)" << std::endl; usage(desc);