Skip to content

Commit

Permalink
nvmeof/NVMeofGwMonitorClient: use a separate mutex for beacons
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Indenbaum <[email protected]>
  • Loading branch information
Alexander Indenbaum committed Aug 15, 2024
1 parent be941ad commit 4ed4cdc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/nvmeof/NVMeofGwMonitorClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/nvmeof/NVMeofGwMonitorClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class NVMeofGwMonitorClient: public Dispatcher,
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;
Expand Down

0 comments on commit 4ed4cdc

Please sign in to comment.