Merge pull request #36324 from dillaman/wip-46737

librbd: ensure image cannot be closed until in-flight IO callbacks complete

Reviewed-by: Mykola Golub <mgolub@suse.com>
This commit is contained in:
Mykola Golub 2020-07-30 15:04:10 +03:00 committed by GitHub
commit a760349344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,14 +111,6 @@ void AioCompletion::complete() {
notify_callbacks_complete();
}
if (image_dispatcher_ctx != nullptr) {
image_dispatcher_ctx->complete(rval);
}
// note: possible for image to be closed after op marked finished
if (async_op.started()) {
async_op.finish_op();
}
tracepoint(librbd, aio_complete_exit);
}
@ -283,8 +275,19 @@ void AioCompletion::complete_event_socket() {
void AioCompletion::notify_callbacks_complete() {
state = AIO_STATE_COMPLETE;
std::unique_lock<std::mutex> locker(lock);
cond.notify_all();
{
std::unique_lock<std::mutex> locker(lock);
cond.notify_all();
}
if (image_dispatcher_ctx != nullptr) {
image_dispatcher_ctx->complete(rval);
}
// note: possible for image to be closed after op marked finished
if (async_op.started()) {
async_op.finish_op();
}
}
} // namespace io