#include <boost/scope_exit.hpp>
#include <boost/scoped_ptr.hpp>
#include <errno.h>
+#include <fcntl.h>
#include <iostream>
#include <memory>
#include <sstream>
in_flight(0)
{ }
- bool start_write(int max, uint64_t off, uint64_t len, bufferlist& bl)
+ bool start_write(int max, uint64_t off, uint64_t len, bufferlist& bl,
+ int op_flags)
{
{
Mutex::Locker l(lock);
}
librbd::RBD::AioCompletion *c =
new librbd::RBD::AioCompletion((void *)this, rbd_bencher_completion);
- image->aio_write(off, len, bl, c);
+ image->aio_write2(off, len, bl, c, op_flags);
//cout << "start " << c << " at " << off << "~" << len << std::endl;
return true;
}
uint64_t cur_ios = 0;
uint64_t cur_off = 0;
+ int op_flags;
+ if (pattern == "rand") {
+ op_flags = LIBRADOS_OP_FLAG_FADVISE_RANDOM;
+ } else {
+ op_flags = LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL;
+ }
+
printf(" SEC OPS OPS/SEC BYTES/SEC\n");
uint64_t off;
for (off = 0; off < io_bytes; ) {
b.wait_for(io_threads - 1);
i = 0;
while (i < io_threads && off < io_bytes &&
- b.start_write(io_threads, thread_offset[i], io_size, bl)) {
+ b.start_write(io_threads, thread_offset[i], io_size, bl, op_flags)) {
++i;
++ios;
off += io_size;
m_fd(fd)
{
m_throttle.start_op();
- int r = image.aio_read(offset, length, m_bufferlist, m_aio_completion);
+
+ int op_flags = LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL |
+ LIBRADOS_OP_FLAG_FADVISE_NOCACHE;
+ int r = image.aio_read2(offset, length, m_bufferlist, m_aio_completion,
+ op_flags);
if (r < 0) {
cerr << "rbd: error requesting read from source image" << std::endl;
m_throttle.end_op(r);
if (fd < 0) {
return -errno;
}
+ posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
}
MyProgressContext pc("Exporting image");
if (exists) {
// read block
bl.clear();
- r = ec->image->read(ofs, len, bl);
+ r = ec->image->read2(ofs, len, bl, LIBRADOS_OP_FLAG_FADVISE_NOCACHE);
if (r < 0)
return r;
r = bl.write_fd(ec->fd);
{
m_throttle.start_op();
- int r = image.aio_write(m_offset, m_bufferlist.length(), m_bufferlist,
- m_aio_completion);
+ int op_flags = LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL |
+ LIBRADOS_OP_FLAG_FADVISE_NOCACHE;
+ int r = image.aio_write2(m_offset, m_bufferlist.length(), m_bufferlist,
+ m_aio_completion, op_flags);
if (r < 0) {
cerr << "rbd: error requesting write to destination image" << std::endl;
m_throttle.end_op(r);
assert(bdev_size >= 0);
size = (uint64_t) bdev_size;
}
+
+ posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
}
r = do_create(rbd, io_ctx, imgname, size, order, format, features, 0, 0);
if (r < 0) {
bufferlist data;
data.append(bp);
dout(2) << " write " << off << "~" << len << dendl;
- image.write(off, len, data);
+ image.write2(off, len, data, LIBRADOS_OP_FLAG_FADVISE_NOCACHE);
} else {
dout(2) << " zero " << off << "~" << len << dendl;
image.discard(off, len);