Merge pull request #30204 from tchaikov/wip-test-aio-completion-release

test/librados: free AioCompletion using AioCompletion::release()

Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Kefu Chai 2019-11-25 00:59:25 +08:00 committed by GitHub
commit 0847955aa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 339 additions and 571 deletions

View File

@ -191,6 +191,7 @@ inline namespace v14_2_0 {
struct CEPH_RADOS_API AioCompletion {
AioCompletion(AioCompletionImpl *pc_) : pc(pc_) {}
~AioCompletion();
int set_complete_callback(void *cb_arg, callback_t cb);
int set_safe_callback(void *cb_arg, callback_t cb)
__attribute__ ((deprecated));
@ -211,6 +212,7 @@ inline namespace v14_2_0 {
struct CEPH_RADOS_API PoolAsyncCompletion {
PoolAsyncCompletion(PoolAsyncCompletionImpl *pc_) : pc(pc_) {}
~PoolAsyncCompletion();
int set_callback(void *cb_arg, callback_t cb);
int wait();
bool is_complete();

View File

@ -3026,6 +3026,7 @@ extern "C" int _rados_aio_unlock(rados_ioctx_t io, const char *o, const char *na
librados::IoCtx ctx;
librados::IoCtx::from_rados_ioctx_t(io, ctx);
librados::AioCompletionImpl *comp = (librados::AioCompletionImpl*)completion;
comp->get();
librados::AioCompletion c(comp);
int retval = ctx.aio_unlock(o, name, cookie, &c);
tracepoint(librados, rados_aio_unlock_exit, retval);

View File

@ -960,6 +960,12 @@ uint32_t librados::NObjectIterator::get_pg_hash_position() const
const librados::NObjectIterator librados::NObjectIterator::__EndObjectIterator(NULL);
///////////////////////////// PoolAsyncCompletion //////////////////////////////
librados::PoolAsyncCompletion::PoolAsyncCompletion::~PoolAsyncCompletion()
{
auto c = reinterpret_cast<PoolAsyncCompletionImpl *>(pc);
c->release();
}
int librados::PoolAsyncCompletion::PoolAsyncCompletion::set_callback(void *cb_arg,
rados_callback_t cb)
{
@ -987,12 +993,16 @@ int librados::PoolAsyncCompletion::PoolAsyncCompletion::get_return_value()
void librados::PoolAsyncCompletion::PoolAsyncCompletion::release()
{
PoolAsyncCompletionImpl *c = (PoolAsyncCompletionImpl *)pc;
c->release();
delete this;
}
///////////////////////////// AioCompletion //////////////////////////////
librados::AioCompletion::AioCompletion::~AioCompletion()
{
auto c = reinterpret_cast<AioCompletionImpl *>(pc);
c->release();
}
int librados::AioCompletion::AioCompletion::set_complete_callback(void *cb_arg, rados_callback_t cb)
{
AioCompletionImpl *c = (AioCompletionImpl *)pc;
@ -1073,8 +1083,6 @@ uint64_t librados::AioCompletion::AioCompletion::get_version64()
void librados::AioCompletion::AioCompletion::release()
{
AioCompletionImpl *c = (AioCompletionImpl *)pc;
c->release();
delete this;
}

File diff suppressed because it is too large Load Diff

View File

@ -345,9 +345,13 @@ extern "C" int rados_wait_for_latest_osdmap(rados_t cluster) {
namespace librados {
void AioCompletion::release() {
AioCompletionImpl *c = reinterpret_cast<AioCompletionImpl *>(pc);
AioCompletion::~AioCompletion()
{
auto c = reinterpret_cast<AioCompletionImpl *>(pc);
c->release();
}
void AioCompletion::release() {
delete this;
}