mirror of
https://github.com/ceph/ceph
synced 2025-03-29 23:09:47 +00:00
test/omap_bench: s/Mutex/ceph::mutex/
Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
bfb8c741cd
commit
816709cda7
@ -14,7 +14,7 @@
|
||||
#include "include/rados/librados.hpp"
|
||||
#include "include/Context.h"
|
||||
#include "common/ceph_context.h"
|
||||
#include "common/Mutex.h"
|
||||
#include "common/ceph_mutex.h"
|
||||
#include "common/Cond.h"
|
||||
#include "include/utime.h"
|
||||
#include "global/global_context.h"
|
||||
@ -127,9 +127,9 @@ int OmapBench::setup(int argc, const char** argv) {
|
||||
//Writer functions
|
||||
Writer::Writer(OmapBench *omap_bench) : ob(omap_bench) {
|
||||
stringstream name;
|
||||
ob->data_lock.Lock();
|
||||
ob->data_lock.lock();
|
||||
name << omap_bench->prefix << ++(ob->data.started_ops);
|
||||
ob->data_lock.Unlock();
|
||||
ob->data_lock.unlock();
|
||||
oid = name.str();
|
||||
}
|
||||
void Writer::start_time() {
|
||||
@ -168,9 +168,9 @@ void AioWriter::set_aioc(librados::callback_t complete,
|
||||
void OmapBench::aio_is_safe(rados_completion_t c, void *arg) {
|
||||
AioWriter *aiow = reinterpret_cast<AioWriter *>(arg);
|
||||
aiow->stop_time();
|
||||
Mutex * data_lock = &aiow->ob->data_lock;
|
||||
Mutex * thread_is_free_lock = &aiow->ob->thread_is_free_lock;
|
||||
Cond * thread_is_free = &aiow->ob->thread_is_free;
|
||||
ceph::mutex * data_lock = &aiow->ob->data_lock;
|
||||
ceph::mutex * thread_is_free_lock = &aiow->ob->thread_is_free_lock;
|
||||
ceph::condition_variable* thread_is_free = &aiow->ob->thread_is_free;
|
||||
int &busythreads_count = aiow->ob->busythreads_count;
|
||||
o_bench_data &data = aiow->ob->data;
|
||||
int INCREMENT = aiow->ob->increment;
|
||||
@ -181,7 +181,7 @@ void OmapBench::aio_is_safe(rados_completion_t c, void *arg) {
|
||||
}
|
||||
double time = aiow->get_time();
|
||||
delete aiow;
|
||||
data_lock->Lock();
|
||||
data_lock->lock();
|
||||
data.avg_latency = (data.avg_latency * data.completed_ops + time)
|
||||
/ (data.completed_ops + 1);
|
||||
data.completed_ops++;
|
||||
@ -197,12 +197,12 @@ void OmapBench::aio_is_safe(rados_completion_t c, void *arg) {
|
||||
data.mode.first = time/INCREMENT;
|
||||
data.mode.second = data.freq_map[time/INCREMENT];
|
||||
}
|
||||
data_lock->Unlock();
|
||||
data_lock->unlock();
|
||||
|
||||
thread_is_free_lock->Lock();
|
||||
thread_is_free_lock->lock();
|
||||
busythreads_count--;
|
||||
thread_is_free->Signal();
|
||||
thread_is_free_lock->Unlock();
|
||||
thread_is_free->notify_all();
|
||||
thread_is_free_lock->unlock();
|
||||
}
|
||||
|
||||
string OmapBench::random_string(int len) {
|
||||
@ -369,16 +369,13 @@ int OmapBench::test_write_objects_in_parallel(omap_generator_t omap_gen) {
|
||||
comp = NULL;
|
||||
AioWriter *this_aio_writer;
|
||||
|
||||
Mutex::Locker l(thread_is_free_lock);
|
||||
std::unique_lock l{thread_is_free_lock};
|
||||
for (int i = 0; i < objects; i++) {
|
||||
ceph_assert(busythreads_count <= threads);
|
||||
//wait for a writer to be free
|
||||
if (busythreads_count == threads) {
|
||||
int err = thread_is_free.Wait(thread_is_free_lock);
|
||||
thread_is_free.wait(l);
|
||||
ceph_assert(busythreads_count < threads);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
//set up the write
|
||||
@ -400,10 +397,7 @@ int OmapBench::test_write_objects_in_parallel(omap_generator_t omap_gen) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
while(busythreads_count > 0) {
|
||||
thread_is_free.Wait(thread_is_free_lock);
|
||||
}
|
||||
|
||||
thread_is_free.wait(l, [this] { return busythreads_count <= 0;});
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#ifndef OMAP_BENCH_HPP_
|
||||
#define OMAP_BENCH_HPP_
|
||||
|
||||
#include "common/Mutex.h"
|
||||
#include "common/ceph_mutex.h"
|
||||
#include "common/Cond.h"
|
||||
#include "include/rados/librados.hpp"
|
||||
#include <string>
|
||||
@ -87,9 +87,11 @@ protected:
|
||||
omap_generator_t omap_generator;
|
||||
|
||||
//aio things
|
||||
Cond thread_is_free;
|
||||
Mutex thread_is_free_lock;
|
||||
Mutex data_lock;
|
||||
ceph::condition_variable thread_is_free;
|
||||
ceph::mutex thread_is_free_lock =
|
||||
ceph::make_mutex("OmapBench::thread_is_free_lock");
|
||||
ceph::mutex data_lock =
|
||||
ceph::make_mutex("OmapBench::data_lock");
|
||||
int busythreads_count;
|
||||
librados::callback_t comp;
|
||||
librados::callback_t safe;
|
||||
@ -111,8 +113,6 @@ public:
|
||||
OmapBench()
|
||||
: test(&OmapBench::test_write_objects_in_parallel),
|
||||
omap_generator(generate_uniform_omap),
|
||||
thread_is_free_lock("OmapBench::thread_is_free_lock"),
|
||||
data_lock("OmapBench::data_lock"),
|
||||
busythreads_count(0),
|
||||
comp(NULL), safe(aio_is_safe),
|
||||
pool_name("rbd"),
|
||||
|
Loading…
Reference in New Issue
Block a user