summaryrefslogtreecommitdiffstats
path: root/src/librbd
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2024-07-20 11:05:47 +0200
committerGitHub <noreply@github.com>2024-07-20 11:05:47 +0200
commite33c5a39ee2c68d685ad5d66c1a9d8b745996667 (patch)
tree0601f3a036cec75ff6abdd3c95f80160ca1e3669 /src/librbd
parentMerge pull request #58180 from guojidan/format (diff)
parentlibrbd: get rid of AIO_STATE_CALLBACK in AioCompletion (diff)
downloadceph-e33c5a39ee2c68d685ad5d66c1a9d8b745996667.tar.xz
ceph-e33c5a39ee2c68d685ad5d66c1a9d8b745996667.zip
Merge pull request #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 <nibalach@redhat.com> Reviewed-by: Ramana Raja <rraja@redhat.com>
Diffstat (limited to 'src/librbd')
-rw-r--r--src/librbd/io/AioCompletion.cc20
-rw-r--r--src/librbd/io/AioCompletion.h4
2 files changed, 8 insertions, 16 deletions
diff --git a/src/librbd/io/AioCompletion.cc b/src/librbd/io/AioCompletion.cc
index c04b80770f9..5452edf5fd3 100644
--- a/src/librbd/io/AioCompletion.cc
+++ b/src/librbd/io/AioCompletion.cc
@@ -97,18 +97,15 @@ void AioCompletion::complete() {
}
}
- state = AIO_STATE_CALLBACK;
if (complete_cb) {
if (external_callback) {
complete_external_callback();
} else {
complete_cb(rbd_comp, complete_arg);
- complete_event_socket();
- notify_callbacks_complete();
+ mark_complete_and_notify();
}
} else {
- complete_event_socket();
- notify_callbacks_complete();
+ mark_complete_and_notify();
}
tracepoint(librbd, aio_complete_exit);
@@ -240,7 +237,7 @@ void AioCompletion::complete_request(ssize_t r)
bool AioCompletion::is_complete() {
tracepoint(librbd, aio_is_complete_enter, this);
- bool done = (this->state != AIO_STATE_PENDING);
+ bool done = (this->state == AIO_STATE_COMPLETE);
tracepoint(librbd, aio_is_complete_exit, done);
return done;
}
@@ -259,21 +256,18 @@ void AioCompletion::complete_external_callback() {
// from multiple librbd-internal threads.
boost::asio::dispatch(ictx->asio_engine->get_api_strand(), [this]() {
complete_cb(rbd_comp, complete_arg);
- complete_event_socket();
- notify_callbacks_complete();
+ mark_complete_and_notify();
put();
});
}
-void AioCompletion::complete_event_socket() {
+void AioCompletion::mark_complete_and_notify() {
+ state = AIO_STATE_COMPLETE;
+
if (ictx != nullptr && event_notify && ictx->event_socket.is_valid()) {
ictx->event_socket_completions.push(this);
ictx->event_socket.notify();
}
-}
-
-void AioCompletion::notify_callbacks_complete() {
- state = AIO_STATE_COMPLETE;
{
std::unique_lock<std::mutex> locker(lock);
diff --git a/src/librbd/io/AioCompletion.h b/src/librbd/io/AioCompletion.h
index 4ae93fe36d2..d98055878cd 100644
--- a/src/librbd/io/AioCompletion.h
+++ b/src/librbd/io/AioCompletion.h
@@ -40,7 +40,6 @@ namespace io {
struct AioCompletion {
typedef enum {
AIO_STATE_PENDING = 0,
- AIO_STATE_CALLBACK,
AIO_STATE_COMPLETE,
} aio_state_t;
@@ -180,8 +179,7 @@ struct AioCompletion {
private:
void queue_complete();
void complete_external_callback();
- void complete_event_socket();
- void notify_callbacks_complete();
+ void mark_complete_and_notify();
};
class C_AioRequest : public Context {