Skip to content

Commit e33c5a3

Browse files
authored
Merge pull request ceph#58591 from idryomov/wip-aio-completion-prep-for-atomic-wait
librbd: fix inconsistency between AioCompletion is_complete() and wait_for_complete() Reviewed-by: N Balachandran <[email protected]> Reviewed-by: Ramana Raja <[email protected]>
2 parents 8914b25 + f6e65ed commit e33c5a3

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

src/librbd/io/AioCompletion.cc

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,15 @@ void AioCompletion::complete() {
9797
}
9898
}
9999

100-
state = AIO_STATE_CALLBACK;
101100
if (complete_cb) {
102101
if (external_callback) {
103102
complete_external_callback();
104103
} else {
105104
complete_cb(rbd_comp, complete_arg);
106-
complete_event_socket();
107-
notify_callbacks_complete();
105+
mark_complete_and_notify();
108106
}
109107
} else {
110-
complete_event_socket();
111-
notify_callbacks_complete();
108+
mark_complete_and_notify();
112109
}
113110

114111
tracepoint(librbd, aio_complete_exit);
@@ -240,7 +237,7 @@ void AioCompletion::complete_request(ssize_t r)
240237

241238
bool AioCompletion::is_complete() {
242239
tracepoint(librbd, aio_is_complete_enter, this);
243-
bool done = (this->state != AIO_STATE_PENDING);
240+
bool done = (this->state == AIO_STATE_COMPLETE);
244241
tracepoint(librbd, aio_is_complete_exit, done);
245242
return done;
246243
}
@@ -259,21 +256,18 @@ void AioCompletion::complete_external_callback() {
259256
// from multiple librbd-internal threads.
260257
boost::asio::dispatch(ictx->asio_engine->get_api_strand(), [this]() {
261258
complete_cb(rbd_comp, complete_arg);
262-
complete_event_socket();
263-
notify_callbacks_complete();
259+
mark_complete_and_notify();
264260
put();
265261
});
266262
}
267263

268-
void AioCompletion::complete_event_socket() {
264+
void AioCompletion::mark_complete_and_notify() {
265+
state = AIO_STATE_COMPLETE;
266+
269267
if (ictx != nullptr && event_notify && ictx->event_socket.is_valid()) {
270268
ictx->event_socket_completions.push(this);
271269
ictx->event_socket.notify();
272270
}
273-
}
274-
275-
void AioCompletion::notify_callbacks_complete() {
276-
state = AIO_STATE_COMPLETE;
277271

278272
{
279273
std::unique_lock<std::mutex> locker(lock);

src/librbd/io/AioCompletion.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ namespace io {
4040
struct AioCompletion {
4141
typedef enum {
4242
AIO_STATE_PENDING = 0,
43-
AIO_STATE_CALLBACK,
4443
AIO_STATE_COMPLETE,
4544
} aio_state_t;
4645

@@ -180,8 +179,7 @@ struct AioCompletion {
180179
private:
181180
void queue_complete();
182181
void complete_external_callback();
183-
void complete_event_socket();
184-
void notify_callbacks_complete();
182+
void mark_complete_and_notify();
185183
};
186184

187185
class C_AioRequest : public Context {

0 commit comments

Comments
 (0)