From fab73c3edc9f605f1811b54efb4584ea5f84a5ca Mon Sep 17 00:00:00 2001 From: Mike Ryan Date: Wed, 20 Jun 2012 14:50:04 -0700 Subject: [PATCH] obj_bencher: store per-benchmark metadata Store metadata for each benchmark run so that the objects can be efficiently removed at a later point. Signed-off-by: Mike Ryan --- src/common/obj_bencher.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc index 2f78161b8b1c6..f8a598d0be869 100644 --- a/src/common/obj_bencher.cc +++ b/src/common/obj_bencher.cc @@ -50,6 +50,20 @@ static std::string generate_object_name(int objnum, int pid = 0) return oss.str(); } +static std::string generate_metadata_name(int pid = 0) +{ + if (!pid) + pid = getpid(); + + char hostname[30]; + gethostname(hostname, sizeof(hostname)-1); + hostname[sizeof(hostname)-1] = 0; + + std::ostringstream oss; + oss << BENCH_PREFIX << "_" << hostname << "_" << pid << "_metadata"; + return oss.str(); +} + static void sanitize_object_contents (bench_data *data, int length) { memset(data->object_contents, 'z', length); } @@ -210,6 +224,9 @@ int ObjBencher::aio_bench(int operation, int secondsToRun, int concurrentios, in if (r != 0) goto out; r = sync_remove(BENCH_METADATA); + if (r != 0) goto out; + + r = sync_remove(generate_metadata_name()); } out: @@ -446,6 +463,8 @@ int ObjBencher::write_bench(int secondsToRun, int concurrentios) { ::encode(getpid(), b_write); sync_write(BENCH_METADATA, b_write, sizeof(int)*3); + sync_write(generate_metadata_name(), b_write, sizeof(int)*3); + completions_done(); return 0; -- 2.39.5