Skip to content

Commit ed082db

Browse files
committed
librbd: fold complete_event_socket() into notify_callbacks_complete()
Since commit 50694f7 ("librbd: fix race condition with AIO completion callbacks"), the former is always called before the latter. Move event socket notification code into notify_callbacks_complete() and rename it to mark_complete_and_notify(). Signed-off-by: Ilya Dryomov <[email protected]>
1 parent d526572 commit ed082db

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/librbd/io/AioCompletion.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,10 @@ void AioCompletion::complete() {
103103
complete_external_callback();
104104
} else {
105105
complete_cb(rbd_comp, complete_arg);
106-
complete_event_socket();
107-
notify_callbacks_complete();
106+
mark_complete_and_notify();
108107
}
109108
} else {
110-
complete_event_socket();
111-
notify_callbacks_complete();
109+
mark_complete_and_notify();
112110
}
113111

114112
tracepoint(librbd, aio_complete_exit);
@@ -259,20 +257,17 @@ void AioCompletion::complete_external_callback() {
259257
// from multiple librbd-internal threads.
260258
boost::asio::dispatch(ictx->asio_engine->get_api_strand(), [this]() {
261259
complete_cb(rbd_comp, complete_arg);
262-
complete_event_socket();
263-
notify_callbacks_complete();
260+
mark_complete_and_notify();
264261
put();
265262
});
266263
}
267264

268-
void AioCompletion::complete_event_socket() {
265+
void AioCompletion::mark_complete_and_notify() {
269266
if (ictx != nullptr && event_notify && ictx->event_socket.is_valid()) {
270267
ictx->event_socket_completions.push(this);
271268
ictx->event_socket.notify();
272269
}
273-
}
274270

275-
void AioCompletion::notify_callbacks_complete() {
276271
state = AIO_STATE_COMPLETE;
277272

278273
{

src/librbd/io/AioCompletion.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ struct AioCompletion {
180180
private:
181181
void queue_complete();
182182
void complete_external_callback();
183-
void complete_event_socket();
184-
void notify_callbacks_complete();
183+
void mark_complete_and_notify();
185184
};
186185

187186
class C_AioRequest : public Context {

0 commit comments

Comments
 (0)