]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
use atomic compare and swap to avoid mutex lock 8194/head
authorhaodong <haodong.tang@intel.com>
Fri, 25 Mar 2016 02:18:18 +0000 (22:18 -0400)
committerhaodong <haodong.tang@intel.com>
Fri, 25 Mar 2016 02:18:18 +0000 (22:18 -0400)
Signed-off-by: Haodong Tang <haodong.tang@intel.com>
src/os/bluestore/KernelDevice.cc

index 6a226f97a7d8ba84d7e4ba024554af1ad174dc18..c0a344cc070c473a927c15bdf13c2c6eea3a3c43 100644 (file)
@@ -176,15 +176,12 @@ void KernelDevice::close()
 
 int KernelDevice::flush()
 {
-  // serialize flushers, so that we can avoid weird io_since_flush
-  // races (w/ multipler flushers).
-  Mutex::Locker l(flush_lock);
-  if (io_since_flush.read() == 0) {
+  bool ret = io_since_flush.compare_and_swap(1, 0);
+  if (!ret) {
     dout(10) << __func__ << " no-op (no ios since last flush)" << dendl;
     return 0;
   }
   dout(10) << __func__ << " start" << dendl;
-  io_since_flush.set(0);
   if (g_conf->bdev_inject_crash) {
     ++injecting_crash;
     // sleep for a moment to give other threads a chance to submit or