#include "tools/rbd/Utils.h"
#include "common/errno.h"
#include "common/strtol.h"
-#include "common/Cond.h"
-#include "common/Mutex.h"
+#include "common/ceph_mutex.h"
+#include "include/types.h"
#include "global/signal_handler.h"
#include <iostream>
#include <boost/accumulators/accumulators.hpp>
}
}
-io_type_t get_io_type(string io_type_string) {
+io_type_t get_io_type(std::string io_type_string) {
if (io_type_string == "read")
return IO_TYPE_READ;
else if (io_type_string == "write")
struct rbd_bencher {
librbd::Image *image;
- Mutex lock;
- Cond cond;
+ ceph::mutex lock = ceph::make_mutex("rbd_bencher::lock");
+ ceph::condition_variable cond;
int in_flight;
io_type_t io_type;
uint64_t io_size;
explicit rbd_bencher(librbd::Image *i, io_type_t io_type, uint64_t io_size)
: image(i),
- lock("rbd_bencher::lock"),
in_flight(0),
io_type(io_type),
io_size(io_size)
void start_io(int max, uint64_t off, uint64_t len, int op_flags, bool read_flag)
{
{
- Mutex::Locker l(lock);
+ std::lock_guard l{lock};
in_flight++;
}
}
int wait_for(int max, bool interrupt_on_terminating) {
- Mutex::Locker l(lock);
+ std::unique_lock l{lock};
while (in_flight > max && !(terminating && interrupt_on_terminating)) {
- utime_t dur;
- dur.set_from_double(.2);
- cond.WaitInterval(lock, dur);
+ cond.wait_for(l, 200ms);
}
return terminating ? -EINTR : 0;
//cout << "complete " << c << std::endl;
int ret = c->get_return_value();
if (b->io_type == IO_TYPE_WRITE && ret != 0) {
- cout << "write error: " << cpp_strerror(ret) << std::endl;
+ std::cout << "write error: " << cpp_strerror(ret) << std::endl;
exit(ret < 0 ? -ret : ret);
} else if (b->io_type == IO_TYPE_READ && (unsigned int)ret != b->io_size) {
cout << "read error: " << cpp_strerror(ret) << std::endl;
exit(ret < 0 ? -ret : ret);
}
- b->lock.Lock();
+ b->lock.lock();
b->in_flight--;
- b->cond.Signal();
- b->lock.Unlock();
+ b->cond.notify_all();
+ b->lock.unlock();
c->release();
delete bc;
}
#include "tools/rbd/ArgumentTypes.h"
#include "tools/rbd/Shell.h"
#include "tools/rbd/Utils.h"
+#include "common/ceph_mutex.h"
+#include "common/config_proxy.h"
#include "common/errno.h"
+#include "global/global_context.h"
#include <iostream>
#include <boost/program_options.hpp>
-#include "common/Cond.h"
-#include "common/Mutex.h"
namespace rbd {
namespace action {
struct thick_provision_writer {
librbd::Image *image;
- Mutex lock;
- Cond cond;
+ ceph::mutex lock = ceph::make_mutex("thick_provision_writer::lock");
+ ceph::condition_variable cond;
bufferlist bl;
uint64_t chunk_size;
const int block_size;
// Constructor
explicit thick_provision_writer(librbd::Image *i, librbd::ImageOptions &o)
: image(i),
- lock("thick_provision_writer::lock"),
block_size(512) // 512 Bytes
{
// If error cases occur, the code is aborted, because
int start_io(uint64_t write_offset)
{
{
- Mutex::Locker l(lock);
+ std::lock_guard l{lock};
io_status.in_flight++;
if (io_status.in_flight > concurr) {
io_status.in_flight--;
int r;
r = image->aio_writesame(write_offset, chunk_size, bl, c, LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL);
if (r < 0) {
- Mutex::Locker l(lock);
+ std::lock_guard l{lock};
io_status.io_error = r;
}
return r;
}
int wait_for(uint64_t max) {
- Mutex::Locker l(lock);
+ std::unique_lock l{lock};
int r = io_status.io_error;
while (io_status.in_flight > max) {
- utime_t dur;
- dur.set_from_double(.2);
- cond.WaitInterval(lock, dur);
+ cond.wait_for(l, 200ms);
}
return r;
}
thick_provision_writer *tc = static_cast<thick_provision_writer *>(pc);
int r = ac->get_return_value();
- tc->lock.Lock();
+ tc->lock.lock();
if (r < 0 && tc->io_status.io_error >= 0) {
tc->io_status.io_error = r;
}
tc->io_status.in_flight--;
- tc->cond.Signal();
- tc->lock.Unlock();
+ tc->cond.notify_all();
+ tc->lock.unlock();
ac->release();
}