Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luminous: librbd: async open/close should free ImageCtx before issuing callback #28126

Merged
merged 2 commits into from Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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