mirror of
https://github.com/ceph/ceph
synced 2025-01-29 22:43:40 +00:00
os/ObjectStore: add repair interface
Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
parent
d3dd77880a
commit
c7b7a1f04f
src
@ -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) { }
|
||||
|
||||
|
@ -82,7 +82,7 @@ int main(int argc, char **argv)
|
||||
;
|
||||
po::options_description po_positional("Positional options");
|
||||
po_positional.add_options()
|
||||
("command", po::value<string>(&action), "fsck, bluefs-export, show-label")
|
||||
("command", po::value<string>(&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);
|
||||
|
@ -2537,7 +2537,7 @@ int main(int argc, char **argv)
|
||||
("pool", po::value<string>(&pool),
|
||||
"Pool name, mandatory for apply-layout-settings if --pgid is not specified")
|
||||
("op", po::value<string>(&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<unsigned>(&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);
|
||||
|
Loading…
Reference in New Issue
Block a user