From: Sage Weil Date: Fri, 1 Mar 2019 17:00:55 +0000 (-0600) Subject: mgr/BaseMgrModule: drop GIL for ceph_send_command X-Git-Tag: v14.1.1~77^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F26723%2Fhead;p=ceph.git mgr/BaseMgrModule: drop GIL for ceph_send_command Otherwise, we can easily deadlock, since other bits of the code hold the objecter lock and then take the GIL. Fixes: http://tracker.ceph.com/issues/38537 Signed-off-by: Sage Weil --- diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 9976733c9267..f7aff7fe07bd 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -139,6 +139,9 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) MonCommandCompletion *command_c = new MonCommandCompletion(self->py_modules, completion, tag, PyThreadState_Get()); + + PyThreadState *tstate = PyEval_SaveThread(); + if (std::string(type) == "mon") { // Wait for the latest OSDMap after each command we send to @@ -170,6 +173,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) delete command_c; string msg("invalid osd_id: "); msg.append("\"").append(name).append("\""); + PyEval_RestoreThread(tstate); PyErr_SetString(PyExc_ValueError, msg.c_str()); return nullptr; } @@ -194,6 +198,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) if (r != 0) { string msg("failed to send command to mds: "); msg.append(cpp_strerror(r)); + PyEval_RestoreThread(tstate); PyErr_SetString(PyExc_RuntimeError, msg.c_str()); return nullptr; } @@ -203,6 +208,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) delete command_c; string msg("invalid pgid: "); msg.append("\"").append(name).append("\""); + PyEval_RestoreThread(tstate); PyErr_SetString(PyExc_ValueError, msg.c_str()); return nullptr; } @@ -216,15 +222,18 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) &command_c->outbl, &command_c->outs, command_c); + PyEval_RestoreThread(tstate); return nullptr; } else { delete command_c; string msg("unknown service type: "); msg.append(type); + PyEval_RestoreThread(tstate); PyErr_SetString(PyExc_ValueError, msg.c_str()); return nullptr; } + PyEval_RestoreThread(tstate); Py_RETURN_NONE; }