]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
nvmeof/NVMeofGwMonitorClient: use a separate mutex for beacons
authorAlexander Indenbaum <aindenba@redhat.com>
Mon, 5 Aug 2024 09:50:27 +0000 (09:50 +0000)
committerAlexander Indenbaum <aindenba@redhat.com>
Sun, 25 Aug 2024 12:51:50 +0000 (12:51 +0000)
Add beacon_lock to mitigate potential beacon delays caused by slow message
handling, particularly in handle_nvmeof_gw_map.

Signed-off-by: Alexander Indenbaum <aindenba@redhat.com>
src/nvmeof/NVMeofGwMonitorClient.cc
src/nvmeof/NVMeofGwMonitorClient.h

index fc4358f07d4d7888e2ef81da3f5a860eb207541e..ce3328aec5167cfd7b32b4052d8adf00186cd2aa 100644 (file)
@@ -43,7 +43,7 @@ NVMeofGwMonitorClient::NVMeofGwMonitorClient(int argc, const char **argv) :
   client_messenger(Messenger::create(g_ceph_context, "async", entity_name_t::CLIENT(-1), "client", getpid())),
   objecter{g_ceph_context, client_messenger.get(), &monc, poolctx},
   client{client_messenger.get(), &monc, &objecter},
-  timer(g_ceph_context, lock),
+  timer(g_ceph_context, beacon_lock),
   orig_argc(argc),
   orig_argv(argv)
 {
@@ -193,7 +193,10 @@ int NVMeofGwMonitorClient::init()
   client.init();
   timer.init();
 
-  tick();
+  {
+    std::lock_guard bl(beacon_lock);
+    tick();
+  }
 
   dout(10) << "Complete." << dendl;
   return 0;
@@ -217,7 +220,7 @@ static bool get_gw_state(const char* desc, const std::map<NvmeGroupKey, NvmeGwMo
 
 void NVMeofGwMonitorClient::send_beacon()
 {
-  ceph_assert(ceph_mutex_is_locked_by_me(lock));
+  ceph_assert(ceph_mutex_is_locked_by_me(beacon_lock));
   gw_availability_t gw_availability = gw_availability_t::GW_CREATED;
   BeaconSubsystems subs;
   NVMeofGwClient gw_client(
@@ -295,7 +298,10 @@ void NVMeofGwMonitorClient::shutdown()
 
 
   // stop sending beacon first, I use monc to talk with monitors
-  timer.shutdown();
+  {
+    std::lock_guard bl(beacon_lock);
+    timer.shutdown();
+  }
   // client uses monc and objecter
   client.shutdown();
   // Stop asio threads, so leftover events won't call into shut down
index 5bcca91eb4a0a1567c82a059ae58502a592575ea..6dd167e4e5802a3ccfdaad24e7092f394cfad36e 100644 (file)
@@ -61,6 +61,8 @@ protected:
   Client client;
   std::map<NvmeGroupKey, NvmeGwMonClientStates> map;
   ceph::mutex lock = ceph::make_mutex("NVMeofGw::lock");
+  // allow beacons to be sent independently of handle_nvmeof_gw_map
+  ceph::mutex beacon_lock = ceph::make_mutex("NVMeofGw::beacon_lock");
   SafeTimer timer;
 
   int orig_argc;