Skip to content

Commit

Permalink
Merge pull request #28126 from dillaman/wip-39427-luminous
Browse files Browse the repository at this point in the history
luminous: librbd: async open/close should free ImageCtx before issuing callback

Reviewed-by: Mykola Golub <mgolub@mirantis.com>
  • Loading branch information
yuriw committed Jun 26, 2019
2 parents 5a70216 + 585c7d2 commit 2edf4f9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
13 changes: 13 additions & 0 deletions src/librbd/io/AioCompletion.cc
Expand Up @@ -87,6 +87,13 @@ void AioCompletion::complete() {
ictx->journal->commit_io_event(journal_tid, rval);
}

if ((aio_type == AIO_TYPE_CLOSE) ||
(aio_type == AIO_TYPE_OPEN && rval < 0)) {
// must destroy ImageCtx prior to invoking callback
delete ictx;
ictx = nullptr;
}

state = AIO_STATE_CALLBACK;
if (complete_cb) {
lock.Unlock();
Expand Down Expand Up @@ -124,6 +131,12 @@ void AioCompletion::start_op(bool ignore_type) {
Mutex::Locker locker(lock);
assert(ictx != nullptr);
assert(!async_op.started());

if (aio_type == AIO_TYPE_OPEN || aio_type == AIO_TYPE_CLOSE) {
// no need to track async open/close operations
return;
}

if (state == AIO_STATE_PENDING &&
(ignore_type || aio_type != AIO_TYPE_FLUSH)) {
async_op.start_op(*ictx);
Expand Down
14 changes: 4 additions & 10 deletions src/librbd/io/AioCompletion.h
Expand Up @@ -169,16 +169,10 @@ struct AioCompletion {
int n = --ref;
lock.Unlock();
if (!n) {
if (ictx) {
if (event_notify) {
ictx->completed_reqs_lock.Lock();
m_xlist_item.remove_myself();
ictx->completed_reqs_lock.Unlock();
}
if (aio_type == AIO_TYPE_CLOSE ||
(aio_type == AIO_TYPE_OPEN && rval < 0)) {
delete ictx;
}
if (ictx != nullptr && event_notify) {
ictx->completed_reqs_lock.Lock();
m_xlist_item.remove_myself();
ictx->completed_reqs_lock.Unlock();
}
delete this;
}
Expand Down
1 change: 1 addition & 0 deletions src/tools/rbd/action/MirrorPool.cc
Expand Up @@ -330,6 +330,7 @@ class ImageRequestBase {
finalize_action();
}
m_throttle.end_op(r);
delete this;
}

};
Expand Down

0 comments on commit 2edf4f9

Please sign in to comment.