]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/bench/rbd_backend.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
3 #include "rbd_backend.h"
4 #include <boost/tuple/tuple.hpp>
6 typedef boost::tuple
<Context
*, Context
*> arg_type
;
8 void on_complete(void *completion
, void *_arg
) {
9 arg_type
*arg
= static_cast<arg_type
*>(_arg
);
10 librbd::RBD::AioCompletion
*comp
=
11 static_cast<librbd::RBD::AioCompletion
*>(completion
);
12 ssize_t r
= comp
->get_return_value();
14 arg
->get
<0>()->complete(0);
16 arg
->get
<1>()->complete(0);
21 void RBDBackend::write(
25 Context
*on_write_applied
,
28 bufferlist
&bl_non_const
= const_cast<bufferlist
&>(bl
);
29 ceph::shared_ptr
<librbd::Image
> image
= (*m_images
)[oid
];
30 void *arg
= static_cast<void *>(new arg_type(on_commit
, on_write_applied
));
31 librbd::RBD::AioCompletion
*completion
=
32 new librbd::RBD::AioCompletion(arg
, on_complete
);
33 int r
= image
->aio_write(offset
, (size_t) bl_non_const
.length(),
34 bl_non_const
, completion
);
38 void RBDBackend::read(
43 Context
*on_read_complete
)
45 ceph::shared_ptr
<librbd::Image
> image
= (*m_images
)[oid
];
46 void *arg
= static_cast<void *>(new arg_type(on_read_complete
, NULL
));
47 librbd::RBD::AioCompletion
*completion
=
48 new librbd::RBD::AioCompletion(arg
, on_complete
);
49 int r
= image
->aio_read(offset
, (size_t) length
, *bl
, completion
);