]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Fix WBThrottle thread disappear problem 994/head
authorHaomai Wang <haomaiwang@gmail.com>
Thu, 26 Dec 2013 03:20:52 +0000 (11:20 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Thu, 26 Dec 2013 03:33:05 +0000 (11:33 +0800)
New ceph_osd.cc code did ObjectStore init work before global_init_daemonize(),
and WBThrottle thread is created when objectstore constructed. So after
daemon(), WBThrottle thread won't exist in new process. It will result in
deadlock.

When "cur_ios" which is member of WBThrottle hits hard limit, there exists two
ways to decrease "cur_ios". The first is WBThrottle thread which is dead if
deamonize, another is SyncThread. SyncThread will block at op_tp.pause()
because thread in op_tp(threadpool) block at
wbthrottle.throttle(FileStore::doop). So no thread will continue process jobs
in filestore layer and all threads is waiting.

Fix #7062 (http://tracker.ceph.com/issues/7062)

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/os/FileStore.cc
src/os/WBThrottle.cc
src/os/WBThrottle.h

index 6a6c668eb00c52cb9a651bb8c50000ef2cf1e6b2..22db6002db556c92f37d1e2bec3a54b20bac303b 100644 (file)
@@ -1403,6 +1403,7 @@ int FileStore::mount()
     }
   }
 
+  wbthrottle.start();
   sync_thread.create();
 
   ret = journal_replay(initial_op_seq);
@@ -1420,6 +1421,8 @@ int FileStore::mount()
     lock.Unlock();
     sync_thread.join();
 
+    wbthrottle.stop();
+
     goto close_current_fd;
   }
 
@@ -1469,6 +1472,7 @@ int FileStore::umount()
   sync_cond.Signal();
   lock.Unlock();
   sync_thread.join();
+  wbthrottle.stop();
   op_tp.stop();
 
   journal_stop();
index c5fb49505c55ffbf06c3360c4bd75754045e412b..0354ceb8ccefcff15efe692b1e2428255be48adc 100644 (file)
@@ -10,7 +10,7 @@ WBThrottle::WBThrottle(CephContext *cct) :
   cur_ios(0), cur_size(0),
   cct(cct),
   logger(NULL),
-  stopping(false),
+  stopping(true),
   lock("WBThrottle::lock", false, true, false, cct),
   fs(XFS)
 {
@@ -34,20 +34,33 @@ WBThrottle::WBThrottle(CephContext *cct) :
     logger->set(i, 0);
 
   cct->_conf->add_observer(this);
-  create();
 }
 
 WBThrottle::~WBThrottle() {
   assert(cct);
+  cct->get_perfcounters_collection()->remove(logger);
+  delete logger;
+  cct->_conf->remove_observer(this);
+}
+
+void WBThrottle::start()
+{
+  {
+    Mutex::Locker l(lock);
+    stopping = false;
+  }
+  create();
+}
+
+void WBThrottle::stop()
+{
   {
     Mutex::Locker l(lock);
     stopping = true;
     cond.Signal();
   }
+
   join();
-  cct->get_perfcounters_collection()->remove(logger);
-  delete logger;
-  cct->_conf->remove_observer(this);
 }
 
 const char** WBThrottle::get_tracked_conf_keys() const
index e418cf98d2a7f8f2da9f13ce822737b00baa4eec..b78123267508e127b5747df5f72448f1b345f4fa 100644 (file)
@@ -134,6 +134,7 @@ public:
   WBThrottle(CephContext *cct);
   ~WBThrottle();
 
+  void stop();
   /// Set fs as XFS or BTRFS
   void set_fs(FS new_fs) {
     Mutex::Locker l(lock);