Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvmeof/NVMeofGwMonitorClient: use a separate mutex for beacons #59053

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading