diff options
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/ceph-client-debug.cc | 5 | ||||
-rw-r--r-- | src/tools/ceph_authtool.cc | 5 | ||||
-rw-r--r-- | src/tools/ceph_conf.cc | 6 | ||||
-rw-r--r-- | src/tools/ceph_kvstore_tool.cc | 2 | ||||
-rw-r--r-- | src/tools/ceph_monstore_tool.cc | 2 | ||||
-rw-r--r-- | src/tools/ceph_objectstore_tool.cc | 63 | ||||
-rw-r--r-- | src/tools/ceph_osdomap_tool.cc | 2 | ||||
-rw-r--r-- | src/tools/cephfs/cephfs-data-scan.cc | 3 | ||||
-rw-r--r-- | src/tools/cephfs/cephfs-journal-tool.cc | 3 | ||||
-rw-r--r-- | src/tools/cephfs/cephfs-table-tool.cc | 3 | ||||
-rw-r--r-- | src/tools/crushtool.cc | 5 | ||||
-rw-r--r-- | src/tools/monmaptool.cc | 5 | ||||
-rw-r--r-- | src/tools/osdmaptool.cc | 5 | ||||
-rw-r--r-- | src/tools/rados/rados.cc | 3 | ||||
-rw-r--r-- | src/tools/rbd/rbd.cc | 3 | ||||
-rw-r--r-- | src/tools/rbd_mirror/main.cc | 7 | ||||
-rw-r--r-- | src/tools/rbd_nbd/rbd-nbd.cc | 5 |
17 files changed, 68 insertions, 59 deletions
diff --git a/src/tools/ceph-client-debug.cc b/src/tools/ceph-client-debug.cc index a84cadcf69d..a6ab88d84f6 100644 --- a/src/tools/ceph-client-debug.cc +++ b/src/tools/ceph-client-debug.cc @@ -85,8 +85,9 @@ int main(int argc, const char **argv) argv_to_vec(argc, argv, args); env_to_vec(args); - global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, - CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, + CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); common_init_finish(g_ceph_context); diff --git a/src/tools/ceph_authtool.cc b/src/tools/ceph_authtool.cc index d7c3724c908..db6b63d1418 100644 --- a/src/tools/ceph_authtool.cc +++ b/src/tools/ceph_authtool.cc @@ -63,8 +63,9 @@ int main(int argc, const char **argv) map<string,bufferlist> caps; std::string fn; - global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, - CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, + CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); bool gen_key = false; bool gen_print_key = false; diff --git a/src/tools/ceph_conf.cc b/src/tools/ceph_conf.cc index f047e7ca87c..7a50c138e60 100644 --- a/src/tools/ceph_conf.cc +++ b/src/tools/ceph_conf.cc @@ -153,6 +153,12 @@ int main(int argc, const char **argv) global_pre_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON, CINIT_FLAG_NO_DAEMON_ACTIONS); + std::unique_ptr<CephContext, + std::function<void(CephContext*)> > cct_deleter{ + g_ceph_context, + [](CephContext *p) {p->put();} + }; + g_conf->apply_changes(NULL); g_conf->complain_about_parse_errors(g_ceph_context); diff --git a/src/tools/ceph_kvstore_tool.cc b/src/tools/ceph_kvstore_tool.cc index 61d545ece96..751bf106c70 100644 --- a/src/tools/ceph_kvstore_tool.cc +++ b/src/tools/ceph_kvstore_tool.cc @@ -230,7 +230,7 @@ int main(int argc, const char *argv[]) argv_to_vec(argc, argv, args); env_to_vec(args); - global_init( + auto cct = global_init( NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); common_init_finish(g_ceph_context); diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index 5198ebf5d35..c39f6a2111b 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -787,7 +787,7 @@ int main(int argc, char **argv) { ceph_options.push_back(i->c_str()); } - global_init( + auto cct = global_init( &def_args, ceph_options, CEPH_ENTITY_TYPE_MON, CODE_ENVIRONMENT_UTILITY, 0); common_init_finish(g_ceph_context); diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index e2636d202f4..d5ce63a98c1 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -319,13 +319,6 @@ static int get_fd_data(int fd, bufferlist &bl) return 0; } -void myexit(int ret) -{ - if (g_ceph_context) - g_ceph_context->put(); - exit(ret); -} - int get_log(ObjectStore *fs, __u8 struct_ver, coll_t coll, spg_t pgid, const pg_info_t &info, PGLog::IndexedLog &log, pg_missing_t &missing) @@ -2378,12 +2371,12 @@ int main(int argc, char **argv) po::include_positional); } catch(po::error &e) { std::cerr << e.what() << std::endl; - myexit(1); + return 1; } if (vm.count("help")) { usage(desc); - myexit(1); + return 1; } if (!vm.count("debug")) { @@ -2444,7 +2437,7 @@ int main(int argc, char **argv) !(op == "dump-journal" && type == "filestore")) { cerr << "Must provide --data-path" << std::endl; usage(desc); - myexit(1); + return 1; } if (type == "filestore" && !vm.count("journal-path")) { jpath = dpath + "/journal"; @@ -2452,29 +2445,29 @@ int main(int argc, char **argv) if (!vm.count("op") && !vm.count("object")) { cerr << "Must provide --op or object command..." << std::endl; usage(desc); - myexit(1); + return 1; } if (op != "list" && vm.count("op") && vm.count("object")) { cerr << "Can't specify both --op and object command syntax" << std::endl; usage(desc); - myexit(1); + return 1; } if (op == "apply-layout-settings" && !(vm.count("pool") ^ vm.count("pgid"))) { cerr << "apply-layout-settings requires either --pool or --pgid" << std::endl; usage(desc); - myexit(1); + return 1; } if (op != "list" && vm.count("object") && !vm.count("objcmd")) { cerr << "Invalid syntax, missing command" << std::endl; usage(desc); - myexit(1); + return 1; } if (op == "fuse" && mountpoint.length() == 0) { cerr << "Missing fuse mountpoint" << std::endl; usage(desc); - myexit(1); + return 1; } outistty = isatty(STDOUT_FILENO); @@ -2483,7 +2476,7 @@ int main(int argc, char **argv) if (!vm.count("file") || file == "-") { if (outistty) { cerr << "stdout is a tty and no --file filename specified" << std::endl; - myexit(1); + return 1; } file_fd = STDOUT_FILENO; } else { @@ -2493,7 +2486,7 @@ int main(int argc, char **argv) if (!vm.count("file") || file == "-") { if (isatty(STDIN_FILENO)) { cerr << "stdin is a tty and no --file filename specified" << std::endl; - myexit(1); + return 1; } file_fd = STDIN_FILENO; } else { @@ -2506,16 +2499,16 @@ int main(int argc, char **argv) if (vm.count("file") && file_fd == fd_none && !dry_run) { cerr << "--file option only applies to import, export, " << "get-osdmap, set-osdmap, get-inc-osdmap or set-inc-osdmap" << std::endl; - myexit(1); + return 1; } if (file_fd != fd_none && file_fd < 0) { string err = string("file: ") + file; perror(err.c_str()); - myexit(1); + return 1; } - global_init( + auto cct = global_init( NULL, ceph_options, CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_UTILITY_NODOUT, 0); //CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); @@ -2538,7 +2531,7 @@ int main(int argc, char **argv) formatter = Formatter::create(format); if (formatter == NULL) { cerr << "unrecognized format: " << format << std::endl; - myexit(1); + return 1; } // Special handling for filestore journal, so we can dump it without mounting @@ -2547,10 +2540,10 @@ int main(int argc, char **argv) if (ret < 0) { cerr << "journal-path: " << jpath << ": " << cpp_strerror(ret) << std::endl; - myexit(1); + return 1; } formatter->flush(cout); - myexit(0); + return 0; } //Verify that data-path really exists @@ -2558,40 +2551,40 @@ int main(int argc, char **argv) if (::stat(dpath.c_str(), &st) == -1) { string err = string("data-path: ") + dpath; perror(err.c_str()); - myexit(1); + return 1; } if (pgidstr.length() && !pgid.parse(pgidstr.c_str())) { cerr << "Invalid pgid '" << pgidstr << "' specified" << std::endl; - myexit(1); + return 1; } ObjectStore *fs = ObjectStore::create(g_ceph_context, type, dpath, jpath, flags); if (fs == NULL) { cerr << "Unable to create store of type " << type << std::endl; - myexit(1); + return 1; } if (op == "fsck" || op == "fsck-deep") { int r = fs->fsck(op == "fsck-deep"); if (r < 0) { cerr << "fsck failed: " << cpp_strerror(r) << std::endl; - myexit(1); + return 1; } if (r > 0) { cerr << "fsck found " << r << " errors" << std::endl; - myexit(1); + return 1; } cout << "fsck found no errors" << std::endl; - exit(0); + return 0; } if (op == "mkfs") { int r = fs->mkfs(); if (r < 0) { cerr << "fsck failed: " << cpp_strerror(r) << std::endl; - myexit(1); + return 1; } - myexit(0); + return 0; } ObjectStore::Sequencer *osr = new ObjectStore::Sequencer(__func__); @@ -2602,7 +2595,7 @@ int main(int argc, char **argv) } else { cerr << "Mount failed with '" << cpp_strerror(ret) << "'" << std::endl; } - myexit(1); + return 1; } if (op == "fuse") { @@ -2612,12 +2605,12 @@ int main(int argc, char **argv) int r = fuse.main(); if (r < 0) { cerr << "failed to mount fuse: " << cpp_strerror(r) << std::endl; - myexit(1); + return 1; } #else cerr << "fuse support not enabled" << std::endl; #endif - myexit(0); + return 0; } vector<coll_t> ls; @@ -3328,5 +3321,5 @@ out: if (ret < 0) ret = 1; - myexit(ret); + return ret; } diff --git a/src/tools/ceph_osdomap_tool.cc b/src/tools/ceph_osdomap_tool.cc index ffb45288393..0fb6d98a1f1 100644 --- a/src/tools/ceph_osdomap_tool.cc +++ b/src/tools/ceph_osdomap_tool.cc @@ -64,7 +64,7 @@ int main(int argc, char **argv) { ceph_options.push_back(i->c_str()); } - global_init( + auto cct = global_init( &def_args, ceph_options, CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_UTILITY, 0); common_init_finish(g_ceph_context); diff --git a/src/tools/cephfs/cephfs-data-scan.cc b/src/tools/cephfs/cephfs-data-scan.cc index 5e9c05a0717..dcf83bbfd1c 100644 --- a/src/tools/cephfs/cephfs-data-scan.cc +++ b/src/tools/cephfs/cephfs-data-scan.cc @@ -14,7 +14,8 @@ int main(int argc, const char **argv) argv_to_vec(argc, argv, args); env_to_vec(args); - global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, 0); common_init_finish(g_ceph_context); DataScan data_scan; diff --git a/src/tools/cephfs/cephfs-journal-tool.cc b/src/tools/cephfs/cephfs-journal-tool.cc index e9083a5acf5..2764feb0fcb 100644 --- a/src/tools/cephfs/cephfs-journal-tool.cc +++ b/src/tools/cephfs/cephfs-journal-tool.cc @@ -27,7 +27,8 @@ int main(int argc, const char **argv) argv_to_vec(argc, argv, args); env_to_vec(args); - global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, 0); common_init_finish(g_ceph_context); JournalTool jt; diff --git a/src/tools/cephfs/cephfs-table-tool.cc b/src/tools/cephfs/cephfs-table-tool.cc index 749de6f84d6..ef09df49473 100644 --- a/src/tools/cephfs/cephfs-table-tool.cc +++ b/src/tools/cephfs/cephfs-table-tool.cc @@ -14,7 +14,8 @@ int main(int argc, const char **argv) argv_to_vec(argc, argv, args); env_to_vec(args); - global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, 0); common_init_finish(g_ceph_context); TableTool tt; diff --git a/src/tools/crushtool.cc b/src/tools/crushtool.cc index d4bc24fc1d8..19b970aed1a 100644 --- a/src/tools/crushtool.cc +++ b/src/tools/crushtool.cc @@ -271,8 +271,9 @@ int main(int argc, const char **argv) // only parse arguments from CEPH_ARGS, if in the environment vector<const char *> env_args; env_to_vec(env_args); - global_init(NULL, env_args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, - CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); + auto cct = global_init(NULL, env_args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, + CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); int x; diff --git a/src/tools/monmaptool.cc b/src/tools/monmaptool.cc index 274f67c0c28..b600f5a5393 100644 --- a/src/tools/monmaptool.cc +++ b/src/tools/monmaptool.cc @@ -183,8 +183,9 @@ int main(int argc, const char **argv) list<string> rm; list<feature_op_t> features; - global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, - CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, + CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); std::string val; for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) { diff --git a/src/tools/osdmaptool.cc b/src/tools/osdmaptool.cc index a0190753860..8df5c3c3be4 100644 --- a/src/tools/osdmaptool.cc +++ b/src/tools/osdmaptool.cc @@ -45,8 +45,9 @@ int main(int argc, const char **argv) argv_to_vec(argc, argv, args); env_to_vec(args); - global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, - CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, + CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); const char *me = argv[0]; diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index 99a55ba82e2..d611ed7b25a 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -3548,7 +3548,8 @@ int main(int argc, const char **argv) } } - global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, 0); common_init_finish(g_ceph_context); std::vector<const char*>::iterator i; diff --git a/src/tools/rbd/rbd.cc b/src/tools/rbd/rbd.cc index bfa18d345b6..c81faf83696 100644 --- a/src/tools/rbd/rbd.cc +++ b/src/tools/rbd/rbd.cc @@ -13,7 +13,8 @@ int main(int argc, const char **argv) argv_to_vec(argc, argv, args); env_to_vec(args); - global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, 0); rbd::Shell shell; return shell.execute(args); diff --git a/src/tools/rbd_mirror/main.cc b/src/tools/rbd_mirror/main.cc index 0bdafe87675..a423555eac9 100644 --- a/src/tools/rbd_mirror/main.cc +++ b/src/tools/rbd_mirror/main.cc @@ -35,9 +35,9 @@ int main(int argc, const char **argv) env_to_vec(args); argv_to_vec(argc, argv, args); - global_init(nullptr, args, CEPH_ENTITY_TYPE_CLIENT, - CODE_ENVIRONMENT_DAEMON, - CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); + auto cct = global_init(nullptr, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_DAEMON, + CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); for (auto i = args.begin(); i != args.end(); ++i) { if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) { @@ -80,7 +80,6 @@ int main(int argc, const char **argv) shutdown_async_signal_handler(); delete mirror; - g_ceph_context->put(); return r < 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/src/tools/rbd_nbd/rbd-nbd.cc b/src/tools/rbd_nbd/rbd-nbd.cc index 74c269e74af..029d21656c8 100644 --- a/src/tools/rbd_nbd/rbd-nbd.cc +++ b/src/tools/rbd_nbd/rbd-nbd.cc @@ -754,8 +754,9 @@ static int rbd_nbd(int argc, const char *argv[]) argv_to_vec(argc, argv, args); env_to_vec(args); - global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON, - CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_DAEMON, + CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); g_ceph_context->_conf->set_val_or_die("pid_file", ""); std::vector<const char*>::iterator i; |