From: xie xingguo Date: Mon, 6 Jun 2016 01:53:33 +0000 (+0800) Subject: tools/cephfs: add sanity check for rados.connect() X-Git-Tag: v11.0.0~255^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=595fff7ea6082b1bac4661c6b9fc989527b64b67;p=ceph.git tools/cephfs: add sanity check for rados.connect() Which can fail. Signed-off-by: xie xingguo --- diff --git a/src/tools/cephfs/DataScan.cc b/src/tools/cephfs/DataScan.cc index bb0584a365da..9636696dbe3c 100644 --- a/src/tools/cephfs/DataScan.cc +++ b/src/tools/cephfs/DataScan.cc @@ -182,7 +182,12 @@ int DataScan::main(const std::vector &args) // specialized command that will only exist in the Jewel series, // and doesn't require the initialization of the `driver` member // that is done below. - rados.connect(); + r = rados.connect(); + if (r < 0) { + std::cerr << "couldn't connect to cluster: " << cpp_strerror(r) + << std::endl; + return r; + } // Initialize metadata_io from pool on command line if (metadata_pool_name.empty()) { @@ -231,7 +236,13 @@ int DataScan::main(const std::vector &args) } dout(4) << "connecting to RADOS..." << dendl; - rados.connect(); + r = rados.connect(); + if (r < 0) { + std::cerr << "couldn't connect to cluster: " << cpp_strerror(r) + << std::endl; + return r; + } + r = driver->init(rados, fsmap, fscid); if (r < 0) { return r; diff --git a/src/tools/cephfs/TableTool.cc b/src/tools/cephfs/TableTool.cc index 2ff020a6de67..3c4ff8c0718c 100644 --- a/src/tools/cephfs/TableTool.cc +++ b/src/tools/cephfs/TableTool.cc @@ -310,9 +310,11 @@ int TableTool::main(std::vector &argv) } dout(4) << "connecting to RADOS..." << dendl; - rados.connect(); - - + r = rados.connect(); + if (r < 0) { + derr << "couldn't connect to cluster: " << cpp_strerror(r) << dendl; + return r; + } // Require at least 3 args [args...] if (argv.size() < 3) {