From: Igor Fedotov Date: Mon, 20 Jan 2020 23:20:47 +0000 (+0300) Subject: tools/ceph-[objectstore|bluestore]-tool: fix reporting on repaired warnings X-Git-Tag: v15.1.0~51^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2605c375d531d092ae455468dd5180778ba7fd4f;p=ceph.git tools/ceph-[objectstore|bluestore]-tool: fix reporting on repaired warnings Signed-off-by: Igor Fedotov --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 0b3865e86d46..e23b5b83bb99 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 e9a904502ee7..66b5a796dde2 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 b534e0ab317b..9422ad239ebe 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") {