From: Sage Weil Date: Thu, 18 Apr 2019 18:10:15 +0000 (-0500) Subject: mgr/BaseMgrModule: run MonCommandCompletion on the finisher X-Git-Tag: v15.1.0~2889^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F27619%2Fhead;p=ceph.git mgr/BaseMgrModule: run MonCommandCompletion on the finisher The completion takes the ActivePyModules::lock, but the caller may be holding an internal lock for Objecter and/or MonClient. Avoid deadlock by putting the completion on our finisher. Signed-off-by: Sage Weil --- diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index f4fc0c173fc1..d5520c310e98 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -46,9 +46,11 @@ ActivePyModules::ActivePyModules(PyModuleConfig &module_config_, : module_config(module_config_), daemon_state(ds), cluster_state(cs), monc(mc), clog(clog_), audit_clog(audit_clog_), objecter(objecter_), client(client_), finisher(f), + cmd_finisher(g_ceph_context, "cmd_finisher", "cmdfin"), server(server), py_module_registry(pmr), lock("ActivePyModules") { store_cache = std::move(store_data); + cmd_finisher.start(); } ActivePyModules::~ActivePyModules() = default; @@ -434,6 +436,9 @@ void ActivePyModules::shutdown() lock.Lock(); } + cmd_finisher.wait_for_empty(); + cmd_finisher.stop(); + modules.clear(); } diff --git a/src/mgr/ActivePyModules.h b/src/mgr/ActivePyModules.h index 758f94f06478..b3feb0be4e64 100644 --- a/src/mgr/ActivePyModules.h +++ b/src/mgr/ActivePyModules.h @@ -47,6 +47,9 @@ class ActivePyModules Objecter &objecter; Client &client; Finisher &finisher; +public: + Finisher cmd_finisher; +private: DaemonServer &server; PyModuleRegistry &py_module_registry; diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index ab252daa89ea..e636db068e7d 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -165,7 +165,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) {}, &command_c->outbl, &command_c->outs, - c); + new C_OnFinisher(c, &self->py_modules->cmd_finisher)); } else if (std::string(type) == "osd") { std::string err; uint64_t osd_id = strict_strtoll(name, 10, &err); @@ -186,7 +186,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) &tid, &command_c->outbl, &command_c->outs, - command_c); + new C_OnFinisher(command_c, &self->py_modules->cmd_finisher)); } else if (std::string(type) == "mds") { int r = self->py_modules->get_client().mds_command( name, @@ -194,7 +194,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) {}, &command_c->outbl, &command_c->outs, - command_c); + new C_OnFinisher(command_c, &self->py_modules->cmd_finisher)); if (r != 0) { string msg("failed to send command to mds: "); msg.append(cpp_strerror(r)); @@ -221,7 +221,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) &tid, &command_c->outbl, &command_c->outs, - command_c); + new C_OnFinisher(command_c, &self->py_modules->cmd_finisher)); PyEval_RestoreThread(tstate); return nullptr; } else {