]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: {Mutex,Cond} -> ceph::{mutex,condition_variable}
authorSage Weil <sage@redhat.com>
Wed, 10 Oct 2018 17:58:33 +0000 (12:58 -0500)
committerSage Weil <sage@redhat.com>
Sun, 14 Oct 2018 17:10:20 +0000 (12:10 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/bluestore/KernelDevice.cc
src/os/bluestore/KernelDevice.h
src/os/bluestore/NVMEDevice.cc
src/os/bluestore/NVMEDevice.h
src/os/bluestore/PMEMDevice.cc
src/os/bluestore/PMEMDevice.h

index a70aa0eff38e73260951fa9725fcfc3d452f8d52..2be713c06d8261db7a3633aa99f55d98ca817b19 100644 (file)
@@ -3440,7 +3440,7 @@ void BlueStore::Collection::split_cache(
 
 void *BlueStore::MempoolThread::entry()
 {
-  Mutex::Locker l(lock);
+  std::unique_lock l(lock);
 
   std::list<PriorityCache::PriCache *> caches;
   caches.push_back(store->db);
@@ -3485,9 +3485,9 @@ void *BlueStore::MempoolThread::entry()
     interval_stats_trim = false;
 
     store->_update_cache_logger();
-    utime_t wait;
-    wait += store->cct->_conf->bluestore_cache_trim_interval;
-    cond.WaitInterval(lock, wait);
+    auto wait = ceph::make_timespan(
+      store->cct->_conf->bluestore_cache_trim_interval);
+    cond.wait_for(l, wait);
   }
   stop = false;
   return NULL;
index 938c3b39c064ccc98374c98c1272f43d61b6989e..c45ac8651f1ddf4827a3f766d4c710fc0f8ef46d 100644 (file)
@@ -1974,8 +1974,8 @@ private:
   public:
     BlueStore *store;
 
-    Cond cond;
-    Mutex lock;
+    ceph::condition_variable cond;
+    ceph::mutex lock = ceph::make_mutex("BlueStore::MempoolThread::lock");
     bool stop = false;
     uint64_t autotune_cache_size = 0;
 
@@ -2077,7 +2077,6 @@ private:
   public:
     explicit MempoolThread(BlueStore *s)
       : store(s),
-       lock("BlueStore::MempoolThread::lock"),
         meta_cache(MetaCache(s)),
         data_cache(DataCache(s)) {}
 
@@ -2087,10 +2086,10 @@ private:
       create("bstore_mempool");
     }
     void shutdown() {
-      lock.Lock();
+      lock.lock();
       stop = true;
-      cond.Signal();
-      lock.Unlock();
+      cond.notify_all();
+      lock.unlock();
       join();
     }
 
index 243d0f6f8cd25f0e943ad4cd5c63125b39e96b8c..999394e7eb39981f8fa157bc5c7971961fd8fa89 100644 (file)
@@ -37,7 +37,6 @@ KernelDevice::KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, ai
     fd_direct(-1),
     fd_buffered(-1),
     aio(false), dio(false),
-    debug_lock("KernelDevice::debug_lock"),
     aio_queue(cct->_conf->bdev_aio_max_queue_depth),
     discard_callback(d_cb),
     discard_callback_priv(d_cbpriv),
@@ -576,7 +575,7 @@ void KernelDevice::_aio_log_start(
   dout(20) << __func__ << " 0x" << std::hex << offset << "~" << length
           << std::dec << dendl;
   if (cct->_conf->bdev_debug_inflight_ios) {
-    Mutex::Locker l(debug_lock);
+    std::lock_guard l(debug_lock);
     if (debug_inflight.intersects(offset, length)) {
       derr << __func__ << " inflight overlap of 0x"
           << std::hex
@@ -619,7 +618,7 @@ void KernelDevice::_aio_log_finish(
   dout(20) << __func__ << " " << aio << " 0x"
           << std::hex << offset << "~" << length << std::dec << dendl;
   if (cct->_conf->bdev_debug_inflight_ios) {
-    Mutex::Locker l(debug_lock);
+    std::lock_guard l(debug_lock);
     debug_inflight.erase(offset, length);
   }
 }
index 2e9463fcc63f38929bb02f4c11a83776b7a9000f..229d5a8ad5ad929daff5cc1d80684cbf0ef5dd01 100644 (file)
@@ -19,8 +19,8 @@
 
 #include "include/types.h"
 #include "include/interval_set.h"
-#include "common/Mutex.h"
-#include "common/Cond.h"
+#include "common/Thread.h"
+#include "include/utime.h"
 
 #include "aio.h"
 #include "BlockDevice.h"
@@ -35,7 +35,7 @@ class KernelDevice : public BlockDevice {
 
   std::string devname;  ///< kernel dev name (/sys/block/$devname), if any
 
-  Mutex debug_lock;
+  ceph::mutex debug_lock = ceph::make_mutex("KernelDevice::debug_lock");
   interval_set<uint64_t> debug_inflight;
 
   std::atomic<bool> io_since_flush = {false};
index aecadb6e8c42b4636a891a2d485b431a317db73b..19b91f7a6d1935d71ba8006b33876da473b4cd93 100644 (file)
@@ -481,7 +481,7 @@ class NVMEManager {
   };
 
  private:
-  Mutex lock;
+  ceph::mutex lock = ceph::make_mutex("NVMEManager::lock");
   bool init = false;
   std::vector<SharedDriverData*> shared_driver_datas;
   std::thread dpdk_thread;
@@ -490,11 +490,10 @@ class NVMEManager {
   std::list<ProbeContext*> probe_queue;
 
  public:
-  NVMEManager()
-      : lock("NVMEDevice::NVMEManager::lock") {}
+  NVMEManager() {}
   int try_get(const spdk_nvme_transport_id& trid, SharedDriverData **driver);
   void register_ctrlr(const spdk_nvme_transport_id& trid, spdk_nvme_ctrlr *c, SharedDriverData **driver) {
-    ceph_assert(lock.is_locked());
+    ceph_assert(ceph_mutex_is_locked(lock));
     spdk_nvme_ns *ns;
     int num_ns = spdk_nvme_ctrlr_get_num_ns(c);
     ceph_assert(num_ns >= 1);
@@ -547,7 +546,7 @@ static void attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
 
 int NVMEManager::try_get(const spdk_nvme_transport_id& trid, SharedDriverData **driver)
 {
-  Mutex::Locker l(lock);
+  std::lock_guard l(lock);
   for (auto &&it : shared_driver_datas) {
     if (it->is_equal(trid)) {
       *driver = it;
index 81911512ccfb28b03d9160d783d6cdbc81ab6061..b0eba9e57c5b5dc608cb18fa2ed65b2ee24ec5d3 100644 (file)
@@ -27,8 +27,6 @@
 
 #include "include/interval_set.h"
 #include "common/ceph_time.h"
-#include "common/Mutex.h"
-#include "common/Cond.h"
 #include "BlockDevice.h"
 
 enum class IOCommand {
index a472751a3931a4e1491904921af2ef8673618630..5bfa44a9d987f52924c6ef1030832c1ba63dd65b 100644 (file)
@@ -36,7 +36,6 @@
 PMEMDevice::PMEMDevice(CephContext *cct, aio_callback_t cb, void *cbpriv)
   : BlockDevice(cct, cb, cbpriv),
     fd(-1), addr(0),
-    debug_lock("PMEMDevice::debug_lock"),
     injecting_crash(0)
 {
 }
index a0f869b866e974cce2da1c020072dd4cfaf6f200..1d681668ae00c187e0c4a2de514456df142256e6 100644 (file)
@@ -29,7 +29,7 @@ class PMEMDevice : public BlockDevice {
   char *addr; //the address of mmap
   std::string path;
 
-  Mutex debug_lock;
+  ceph::mutex debug_lock = ceph::make_mutex("PMEMDevice::debug_lock");
   interval_set<uint64_t> debug_inflight;
 
   std::atomic_int injecting_crash;