Skip to content

Commit 30d66ff

Browse files
committed
common: drop stack singleton object of temp messenger for foreground ceph daemons
During the initialization, OSD needs to create a temporary messenger to read config db from the ceph-mon. This temporary messenger will need to create async messenger threads according to the local/default value of "ms_async_op_threads" . If this option is not specified in ceph.conf, it will by default create 3 threads, then use these threads to read config db from ceph-mon. Those threads are associated to a stack singletion object. Now here is the difference between OSD running in foreground and background: a. In background mode, this singleton object will be dropped before forking the child process in function notify_pre_fork, then the new ms_async_op_threads fetched from mon config db will be used to create later messenger threads, this is what we want. b. In foreground mode, this singleton object will not be dropped and will be reused by all later messengers, thus the number of threads doesn't change. Fixes: https://tracker.ceph.com/issues/71401 Signed-off-by: dongdong tao <[email protected]>
1 parent ed87297 commit 30d66ff

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/common/ceph_context.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,19 @@ CryptoHandler *CephContext::get_crypto_handler(int type)
10261026
}
10271027
}
10281028

1029+
void CephContext::drop_temp_messenger_obj()
1030+
{
1031+
auto i = associated_objs.begin();
1032+
while (i != associated_objs.end()) {
1033+
if (i->first.first.find("AsyncMessenger::NetworkStack") != std::string::npos) {
1034+
i = associated_objs.erase(i);
1035+
break;
1036+
} else {
1037+
++i;
1038+
}
1039+
}
1040+
}
1041+
10291042
void CephContext::notify_pre_fork()
10301043
{
10311044
{

src/common/ceph_context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ class CephContext {
272272
_fork_watchers.push_back(w);
273273
}
274274

275+
void drop_temp_messenger_obj();
275276
void notify_pre_fork();
276277
void notify_post_fork();
277278

src/global/global_init.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ int global_init_prefork(CephContext *cct)
469469
chown_path(conf->pid_file, cct->get_set_uid(), cct->get_set_gid(),
470470
cct->get_set_uid_string(), cct->get_set_gid_string());
471471
}
472-
472+
cct->drop_temp_messenger_obj();
473473
return -1;
474474
}
475475

0 commit comments

Comments
 (0)