]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/BaseMgrModule: run MonCommandCompletion on the finisher 27619/head
authorSage Weil <sage@redhat.com>
Thu, 18 Apr 2019 18:10:15 +0000 (13:10 -0500)
committerSage Weil <sage@redhat.com>
Fri, 19 Apr 2019 14:09:36 +0000 (09:09 -0500)
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 <sage@redhat.com>
src/mgr/ActivePyModules.cc
src/mgr/ActivePyModules.h
src/mgr/BaseMgrModule.cc

index f4fc0c173fc131d6ee1e5a0e767d58f861b7d403..d5520c310e983138205bce38ef79e4e1add591fa 100644 (file)
@@ -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();
 }
 
index 758f94f06478cf815639bb6c916ea41b5d0a6eee..b3feb0be4e64cc155a9b9e713eb68adcd6c02a8e 100644 (file)
@@ -47,6 +47,9 @@ class ActivePyModules
   Objecter &objecter;
   Client   &client;
   Finisher &finisher;
+public:
+  Finisher cmd_finisher;
+private:
   DaemonServer &server;
   PyModuleRegistry &py_module_registry;
 
index ab252daa89ea8f037f5c4fc43e0e115c29fbf47d..e636db068e7d3748831bf10cc6cb76e8cf4cbcfb 100644 (file)
@@ -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 {