From 2605c375d531d092ae455468dd5180778ba7fd4f Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Tue, 21 Jan 2020 02:20:47 +0300 Subject: [PATCH] tools/ceph-[objectstore|bluestore]-tool: fix reporting on repaired warnings Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueStore.cc | 7 ++++++- src/os/bluestore/bluestore_tool.cc | 4 ++-- src/tools/ceph_objectstore_tool.cc | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 0b3865e86d4..e23b5b83bb9 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -8820,7 +8820,12 @@ out_scan: << repaired << " repaired, " << (errors + warnings - (int)repaired) << " remaining in " << duration << " seconds" << dendl; - return errors - (int)repaired; + + // In non-repair mode we should return error count only as + // it indicates if store status is OK. + // In repair mode both errors and warnings are taken into account + // since repaired counter relates to them both. + return repair ? errors + warnings - (int)repaired : errors; } /// methods to inject various errors fsck can repair diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index e9a904502ee..66b5a796dde 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -431,10 +431,10 @@ int main(int argc, char **argv) r = bluestore.quick_fix(); } if (r < 0) { - cerr << "error from fsck: " << cpp_strerror(r) << std::endl; + cerr << action << " failed: " << cpp_strerror(r) << std::endl; exit(EXIT_FAILURE); } else if (r > 0) { - cerr << action << " found " << r << " error(s)" << std::endl; + cerr << action << " status: remaining " << r << " error(s) and warning(s)" << std::endl; exit(EXIT_FAILURE); } else { cout << action << " success" << std::endl; diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index b534e0ab317..9422ad239eb 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -3520,10 +3520,10 @@ int main(int argc, char **argv) return 1; } if (r > 0) { - cerr << "fsck found " << r << " errors" << std::endl; + cerr << "fsck status: " << r << " remaining error(s) and warning(s)" << std::endl; return 1; } - cout << "fsck found no errors" << std::endl; + cout << "fsck success" << std::endl; return 0; } if (op == "repair" || op == "repair-deep") { @@ -3533,10 +3533,10 @@ int main(int argc, char **argv) return 1; } if (r > 0) { - cerr << "repair found " << r << " errors" << std::endl; + cerr << "repair status: " << r << " remaining error(s) and warning(s)" << std::endl; return 1; } - cout << "repair found no errors" << std::endl; + cout << "repair success" << std::endl; return 0; } if (op == "mkfs") { -- 2.39.5