From: Laura Flores Date: Thu, 6 Feb 2025 17:55:57 +0000 (-0600) Subject: Revert "msg/async/ProtocolV[12]: unlock the `write_lock` before doing I/O" X-Git-Tag: v20.0.0~220^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3646e2448b103f901fd2a8d5e0e23a8b4ff2622e;p=ceph.git Revert "msg/async/ProtocolV[12]: unlock the `write_lock` before doing I/O" This reverts commit f07cd30733a674c3577bfa1853bd722851783b97. The PR was mistakenly merged after some regressions were found in teuthology. Signed-off-by: Laura Flores --- diff --git a/src/msg/async/ProtocolV1.cc b/src/msg/async/ProtocolV1.cc index 26c22128eb4f5..a53f6389c3101 100644 --- a/src/msg/async/ProtocolV1.cc +++ b/src/msg/async/ProtocolV1.cc @@ -222,7 +222,7 @@ void ProtocolV1::send_message(Message *m) { is_prepared = true; } - std::unique_lock l{connection->write_lock}; + std::lock_guard l(connection->write_lock); // "features" changes will change the payload encoding if (can_fast_prepare && (can_write == WriteStatus::NOWRITE || connection->get_features() != f)) { @@ -245,11 +245,6 @@ void ProtocolV1::send_message(Message *m) { << dendl; if (can_write != WriteStatus::REPLACING && !write_in_progress) { write_in_progress = true; - - /* unlock the mutex now because dispatch_event_external() may - block waiting for another mutex */ - l.unlock(); - connection->center->dispatch_event_external(connection->write_handler); } } @@ -275,14 +270,9 @@ void ProtocolV1::prepare_send_message(uint64_t features, Message *m, void ProtocolV1::send_keepalive() { ldout(cct, 10) << __func__ << dendl; - std::unique_lock l{connection->write_lock}; + std::lock_guard l(connection->write_lock); if (can_write != WriteStatus::CLOSED) { keepalive = true; - - /* unlock the mutex now because dispatch_event_external() may - block waiting for another mutex */ - l.unlock(); - connection->center->dispatch_event_external(connection->write_handler); } } diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index eeabc374e7eda..55481056c6067 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -440,7 +440,7 @@ void ProtocolV2::send_message(Message *m) { is_prepared = false; } - std::unique_lock l{connection->write_lock}; + std::lock_guard l(connection->write_lock); // "features" changes will change the payload encoding if (can_fast_prepare && (!can_write || connection->get_features() != f)) { // ensure the correctness of message encoding @@ -464,11 +464,6 @@ void ProtocolV2::send_message(Message *m) { << dendl; if (((!replacing && can_write) || state == STANDBY) && !write_in_progress) { write_in_progress = true; - - /* unlock the mutex now because dispatch_event_external() may - block waiting for another mutex */ - l.unlock(); - connection->center->dispatch_event_external(connection->write_handler); } } @@ -476,14 +471,9 @@ void ProtocolV2::send_message(Message *m) { void ProtocolV2::send_keepalive() { ldout(cct, 10) << __func__ << dendl; - std::unique_lock l{connection->write_lock}; + std::lock_guard l(connection->write_lock); if (state != CLOSED) { keepalive = true; - - /* unlock the mutex now because dispatch_event_external() may - block waiting for another mutex */ - l.unlock(); - connection->center->dispatch_event_external(connection->write_handler); } }