From: Xiubo Li Date: Tue, 31 Mar 2020 09:09:45 +0000 (-0400) Subject: Client: make sure the Finisher's mutex lock not held during it being distructed X-Git-Tag: v14.2.10~48^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8a6573638073b5f41475f28eb5c96a5fd3c113e2;p=ceph.git Client: make sure the Finisher's mutex lock not held during it being distructed 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 (cherry picked from commit fbff4ee153f17da51c3b6675eb0616f2b2062f5e) Conflicts: src/client/Client.cc - nautilus uses client_lock.Lock()/client_lock.Unlock() instead of std::lock_guard in a code block --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 95b1e6719c72..bbffeb8199e6 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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(); } @@ -474,10 +471,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(); client_lock.Lock(); ceph_assert(!initialized); @@ -14562,8 +14569,7 @@ StandaloneClient::~StandaloneClient() int StandaloneClient::init() { - timer.init(); - objectcacher->start(); + _pre_init(); objecter->init(); client_lock.Lock(); diff --git a/src/client/Client.h b/src/client/Client.h index c2218a250ccf..4905d78cacd2 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -952,6 +952,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