break;
} else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
usage();
- exit(0);
+ return EXIT_SUCCESS;
} else if (ceph_argparse_witharg(args, i, &val, "-d", "--decompile", (char*)NULL)) {
infn = val;
decompile = true;
} else if (ceph_argparse_witharg(args, i, &add_item, err, "--add_item", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
if (i == args.end()) {
cerr << "expecting additional argument to --add-item" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
add_weight = atof(*i);
i = args.erase(i);
if (i == args.end()) {
cerr << "expecting additional argument to --add-item" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
add_name.assign(*i);
i = args.erase(i);
update_item = true;
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
if (i == args.end()) {
cerr << "expecting additional argument to --update-item" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
add_weight = atof(*i);
i = args.erase(i);
if (i == args.end()) {
cerr << "expecting additional argument to --update-item" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
add_name.assign(*i);
i = args.erase(i);
std::string type(val);
if (i == args.end()) {
cerr << "expecting additional argument to --loc" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
std::string name(*i);
i = args.erase(i);
tester.set_output_csv(true);
} else if (ceph_argparse_flag(args, i, "--help-output", (char*)NULL)) {
data_analysis_usage();
- exit(0);
+ return EXIT_SUCCESS;
} else if (ceph_argparse_witharg(args, i, &val, "--output-name", (char*)NULL)) {
std::string name(val);
if (i == args.end()) {
cerr << "expecting additional argument to --output-name" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
else {
tester.set_output_data_file_name(name + "-");
reweight_name = val;
if (i == args.end()) {
cerr << "expecting additional argument to --reweight-item" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
reweight_weight = atof(*i);
i = args.erase(i);
} else if (ceph_argparse_witharg(args, i, &num_osds, err, "--num_osds", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
} else if (ceph_argparse_witharg(args, i, &x, err, "--num_rep", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
tester.set_num_rep(x);
} else if (ceph_argparse_witharg(args, i, &x, err, "--max_x", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
tester.set_max_x(x);
} else if (ceph_argparse_witharg(args, i, &x, err, "--min_x", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
tester.set_min_x(x);
} else if (ceph_argparse_witharg(args, i, &z, err, "--pool_id", (char*)NULL)) {
if (!err.str().empty()) {
- cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ cerr << err.str() << std::endl;
+ return EXIT_FAILURE;
}
tester.set_pool_id(z);
} else if (ceph_argparse_witharg(args, i, &x, err, "--x", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
tester.set_x(x);
} else if (ceph_argparse_witharg(args, i, &x, err, "--max_rule", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
tester.set_max_rule(x);
} else if (ceph_argparse_witharg(args, i, &x, err, "--min_rule", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
tester.set_min_rule(x);
} else if (ceph_argparse_witharg(args, i, &x, err, "--rule", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
tester.set_rule(x);
} else if (ceph_argparse_witharg(args, i, &x, err, "--ruleset", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
tester.set_ruleset(x);
} else if (ceph_argparse_witharg(args, i, &x, err, "--batches", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
tester.set_batches(x);
} else if (ceph_argparse_witharg(args, i, &y, err, "--mark-down-ratio", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
tester.set_device_down_ratio(y);
} else if (ceph_argparse_witharg(args, i, &y, err, "--mark-down-bucket-ratio", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
tester.set_bucket_down_ratio(y);
} else if (ceph_argparse_witharg(args, i, &tmp, err, "--weight", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
int dev = tmp;
if (i == args.end()) {
cerr << "expecting additional argument to --weight" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
float f = atof(*i);
i = args.erase(i);
if (decompile + compile + build > 1) {
cerr << "cannot specify more than one of compile, decompile, and build" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
if (!check && !compile && !decompile && !build && !test && !reweight && !adjust && !tree &&
add_item < 0 && full_location < 0 &&
remove_name.empty() && reweight_name.empty()) {
cerr << "no action specified; -h for help" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
if ((!build) && (!args.empty())) {
cerr << "unrecognized arguments: " << args << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
else {
if ((args.size() % 3) != 0U) {
cerr << "remaining args: " << args << std::endl;
cerr << "layers must be specified with 3-tuples of (name, buckettype, size)"
<< std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
for (size_t j = 0; j < args.size(); j += 3) {
layer_t l;
if (infn == "-") {
if (isatty(STDIN_FILENO)) {
cerr << "stdin must not be from a tty" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
r = get_fd_data(STDIN_FILENO, bl);
if (r < 0) {
cerr << "error reading data from STDIN" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
} else {
r = bl.read_file(infn.c_str(), &error);
if (r < 0) {
cerr << me << ": error reading '" << infn << "': "
<< error << std::endl;
- exit(1);
+ return EXIT_FAILURE;
}
}
bufferlist::iterator p = bl.begin();
crush.decode(p);
} catch(...) {
cerr << me << ": unable to decode " << infn << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
}
cc.enable_unsafe_tunables();
int r = cc.compile(in, srcfn.c_str());
if (r < 0)
- exit(1);
+ return EXIT_FAILURE;
modified = true;
}
if (build) {
if (layers.empty()) {
cerr << me << ": must specify at least one layer" << std::endl;
- exit(1);
+ return EXIT_FAILURE;
}
crush.create();
}
if (buckettype < 0) {
cerr << "unknown bucket type '" << l.buckettype << "'" << std::endl;
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
// build items
}
if (OSDMap::build_simple_crush_rulesets(g_ceph_context, crush, root, &cerr))
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
modified = true;
}
o.open(outfn.c_str(), ios::out | ios::binary | ios::trunc);
if (!o.is_open()) {
cerr << me << ": error writing '" << outfn << "'" << std::endl;
- exit(1);
+ return EXIT_FAILURE;
}
cc.decompile(o);
o.close();
tester.check_overlapped_rules();
if (max_id >= 0) {
if (!tester.check_name_maps(max_id)) {
- exit(1);
+ return EXIT_FAILURE;
}
}
}
int r = tester.test();
if (r < 0)
- exit(1);
+ return EXIT_FAILURE;
}
// output ---
int r = bl.write_file(outfn.c_str());
if (r < 0) {
cerr << me << ": error writing '" << outfn << "': " << cpp_strerror(r) << std::endl;
- exit(1);
+ return EXIT_FAILURE;
}
if (verbose)
cout << "wrote crush map to " << outfn << std::endl;