Skip to content

Commit 74925d7

Browse files
committed
src/ceph_osd, osd: Implement running benchmark during OSD creation
The changeset implements the following: 1. Adds an option called "--run-benchmark" to the ceph-osd process to enable running the existing osd benchmark during the creation of the OSD but before it's added to the cluster. If the option is specified, the benchmark is run just after 'mkfs' is performed on the OSD. 2. A separate OSDBenchTest class is created that can be instantiated when the benchmark is needed to be run. The class has interfaces to perform precheck, prefill, run the actual randwrite test and do the cleanup. It also has interfaces to extract the metrics. The new class in used where applicable and maintains the existing behavior of the "bench" command. 3. The vstart.sh script is modified to run the benchmark and store the results for each OSD in ceph.conf. This currently prevents the execution of the existing benchmark during the OSD boot-up. Signed-off-by: Sridhar Seshasayee <[email protected]> Fixes: https://tracker.ceph.com/issues/71941
1 parent dde7f4a commit 74925d7

File tree

4 files changed

+600
-154
lines changed

4 files changed

+600
-154
lines changed

src/ceph_osd.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static void usage()
113113
<< " --debug_osd <N> set debug level (e.g. 10)\n"
114114
<< " --get-device-fsid PATH\n"
115115
<< " get OSD fsid for the given block device\n"
116+
<< " --run-benchmark run a throughput benchmark test against the OSD and dump the result\n"
116117
<< std::endl;
117118
generic_server_usage();
118119
}
@@ -151,6 +152,7 @@ int main(int argc, const char **argv)
151152
bool get_cluster_fsid = false;
152153
bool get_journal_fsid = false;
153154
bool get_device_fsid = false;
155+
bool run_benchmark = false;
154156
string device_path;
155157
std::string dump_pg_log;
156158
std::string osdspec_affinity;
@@ -190,6 +192,8 @@ int main(int argc, const char **argv)
190192
} else if (ceph_argparse_witharg(args, i, &device_path,
191193
"--get-device-fsid", (char*)NULL)) {
192194
get_device_fsid = true;
195+
} else if (ceph_argparse_flag(args, i, "--run-benchmark", (char*)NULL)) {
196+
run_benchmark = true;
193197
} else {
194198
++i;
195199
}
@@ -380,6 +384,23 @@ int main(int argc, const char **argv)
380384
if (mkkey) {
381385
forker.exit(0);
382386
}
387+
// Run a benchmark if specified
388+
if (run_benchmark) {
389+
store->mount();
390+
tl::expected<std::string, int> res =
391+
OSD::run_osd_bench(g_ceph_context, store.get());
392+
if (!res.has_value()) {
393+
int ret = res.error();
394+
derr << TEXT_RED << " ** ERROR: error running benchmark: "
395+
<< cpp_strerror(ret) << TEXT_NORMAL << dendl;
396+
cerr << " ** ERROR: error running benchmark: "
397+
<< cpp_strerror(ret) << std::endl;
398+
forker.exit(ret);
399+
}
400+
cout << res.value() << std::endl;
401+
store->umount();
402+
forker.exit(0);
403+
}
383404
if (mkjournal) {
384405
common_init_finish(g_ceph_context);
385406
int err = store->mkjournal();

0 commit comments

Comments
 (0)