]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Client: make sure the Finisher's mutex lock not held during it being distructed
authorXiubo Li <xiubli@redhat.com>
Tue, 31 Mar 2020 09:09:45 +0000 (05:09 -0400)
committerXiubo Li <xiubli@redhat.com>
Wed, 1 Apr 2020 00:43:10 +0000 (20:43 -0400)
The objecter_finisher is already started in Client::Client(), but
in the failure path when initializing and starting the Client object,
we may not get a chance to call the Client::shutdown() to stop the
Finisher thread, which maybe still holding the mutex lock in it. Then
when destrucing the Finisher object the pthread_mutex_destroy() will
fail.

This fix will delay the objecter_finisher thread to start in ::init()
until we're ready to call Client::shutdown on any errors instead.

Fixes: https://tracker.ceph.com/issues/44389
Signed-off-by: Xiubo Li <xiubli@redhat.com>
src/client/Client.cc
src/client/Client.h

index 84fcf91d0d926ca5fa9a84c508daf260024cb361..09caf4247cb73dcb7814f037893c27c70427ea03 100644 (file)
@@ -303,9 +303,6 @@ Client::Client(Messenger *m, MonClient *mc, Objecter *objecter_)
                                  cct->_conf->client_oc_target_dirty,
                                  cct->_conf->client_oc_max_dirty_age,
                                  true));
-  objecter_finisher.start();
-  filer.reset(new Filer(objecter, &objecter_finisher));
-  objecter->enable_blacklist_events();
 }
 
 
@@ -473,10 +470,20 @@ void Client::dump_status(Formatter *f)
   }
 }
 
-int Client::init()
+void Client::_pre_init()
 {
   timer.init();
+
+  objecter_finisher.start();
+  filer.reset(new Filer(objecter, &objecter_finisher));
+  objecter->enable_blacklist_events();
+
   objectcacher->start();
+}
+
+int Client::init()
+{
+  _pre_init();
   {
     std::lock_guard l{client_lock};
     ceph_assert(!initialized);
@@ -14603,8 +14610,7 @@ StandaloneClient::~StandaloneClient()
 
 int StandaloneClient::init()
 {
-  timer.init();
-  objectcacher->start();
+  _pre_init();
   objecter->init();
 
   client_lock.lock();
index 0ec989db2672b881b9f18c1e4d78804016a41441..7b6eef99d07b9daac2e0e8b072ee504ef539cbc7 100644 (file)
@@ -953,6 +953,8 @@ protected:
 
   void _close_sessions();
 
+  void _pre_init();
+
   /**
    * The basic housekeeping parts of init (perf counters, admin socket)
    * that is independent of how objecters/monclient/messengers are