Skip to content

Commit 0dc4185

Browse files
author
Alexander Indenbaum
committed
nvmeof/NVMeofGwMonitorClient: use a separate mutex for beacons
Add beacon_lock to mitigate potential beacon delays caused by slow message handling, particularly in handle_nvmeof_gw_map. Signed-off-by: Alexander Indenbaum <[email protected]>
1 parent db4959e commit 0dc4185

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/nvmeof/NVMeofGwMonitorClient.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ NVMeofGwMonitorClient::NVMeofGwMonitorClient(int argc, const char **argv) :
4343
client_messenger(Messenger::create(g_ceph_context, "async", entity_name_t::CLIENT(-1), "client", getpid())),
4444
objecter{g_ceph_context, client_messenger.get(), &monc, poolctx},
4545
client{client_messenger.get(), &monc, &objecter},
46-
timer(g_ceph_context, lock),
46+
timer(g_ceph_context, beacon_lock),
4747
orig_argc(argc),
4848
orig_argv(argv)
4949
{
@@ -193,7 +193,10 @@ int NVMeofGwMonitorClient::init()
193193
client.init();
194194
timer.init();
195195

196-
tick();
196+
{
197+
std::lock_guard bl(beacon_lock);
198+
tick();
199+
}
197200

198201
dout(10) << "Complete." << dendl;
199202
return 0;
@@ -217,7 +220,7 @@ static bool get_gw_state(const char* desc, const std::map<NvmeGroupKey, NvmeGwMo
217220

218221
void NVMeofGwMonitorClient::send_beacon()
219222
{
220-
ceph_assert(ceph_mutex_is_locked_by_me(lock));
223+
ceph_assert(ceph_mutex_is_locked_by_me(beacon_lock));
221224
gw_availability_t gw_availability = gw_availability_t::GW_CREATED;
222225
BeaconSubsystems subs;
223226
NVMeofGwClient gw_client(
@@ -295,7 +298,10 @@ void NVMeofGwMonitorClient::shutdown()
295298

296299

297300
// stop sending beacon first, I use monc to talk with monitors
298-
timer.shutdown();
301+
{
302+
std::lock_guard bl(beacon_lock);
303+
timer.shutdown();
304+
}
299305
// client uses monc and objecter
300306
client.shutdown();
301307
// Stop asio threads, so leftover events won't call into shut down

src/nvmeof/NVMeofGwMonitorClient.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class NVMeofGwMonitorClient: public Dispatcher,
6161
Client client;
6262
std::map<NvmeGroupKey, NvmeGwMonClientStates> map;
6363
ceph::mutex lock = ceph::make_mutex("NVMeofGw::lock");
64+
// allow beacons to be sent independently of handle_nvmeof_gw_map
65+
ceph::mutex beacon_lock = ceph::make_mutex("NVMeofGw::beacon_lock");
6466
SafeTimer timer;
6567

6668
int orig_argc;

0 commit comments

Comments
 (0)