]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: spinlock -> std::mutex 14269/head
authorSage Weil <sage@redhat.com>
Fri, 31 Mar 2017 13:33:19 +0000 (09:33 -0400)
committerSage Weil <sage@redhat.com>
Fri, 31 Mar 2017 13:33:19 +0000 (09:33 -0400)
I think spinlock is dangerous here: we're doing semi-unbounded
work (decode).  Also seemingly innocuous code like dout macros
take mutexes.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 543338bdf3d59673485cc04ed6c34023231264f5..6fa5e8de4be7fa52bfd0770c8a5666d13d081aff 100644 (file)
@@ -245,7 +245,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap)
     bufferlist bl;
     mon->store->get(OSD_PG_CREATING_PREFIX, "creating", bl);
     auto p = bl.begin();
-    std::lock_guard<Spinlock> l(creating_pgs_lock);
+    std::lock_guard<std::mutex> l(creating_pgs_lock);
     creating_pgs.decode(p);
     dout(7) << __func__ << " loading creating_pgs e" << creating_pgs.last_scan_epoch << dendl;
   }
@@ -1043,7 +1043,7 @@ OSDMonitor::update_pending_creatings(const OSDMap::Incremental& inc)
 {
   creating_pgs_t pending_creatings;
   {
-    std::lock_guard<Spinlock> l(creating_pgs_lock);
+    std::lock_guard<std::mutex> l(creating_pgs_lock);
     pending_creatings = creating_pgs;
   }
   if (pending_creatings.last_scan_epoch > inc.epoch) {
@@ -1477,7 +1477,7 @@ version_t OSDMonitor::get_trim_to()
 {
   if (mon->monmap->get_required_features().contains_all(
         ceph::features::mon::FEATURE_LUMINOUS)) {
-    std::lock_guard<Spinlock> l(creating_pgs_lock);
+    std::lock_guard<std::mutex> l(creating_pgs_lock);
     if (!creating_pgs.pgs.empty()) {
       return 0;
     }
@@ -3234,7 +3234,7 @@ void OSDMonitor::scan_for_creating_pgs(const map<int64_t,pg_pool_t>& pools,
 void OSDMonitor::update_creating_pgs()
 {
   creating_pgs_by_osd_epoch.clear();
-  std::lock_guard<Spinlock> l(creating_pgs_lock);
+  std::lock_guard<std::mutex> l(creating_pgs_lock);
   for (const auto& pg : creating_pgs.pgs) {
     int acting_primary = -1;
     auto pgid = pg.first;
index d7c4b64ee302319596693f7ac33d14066de92a23..b02067ac5f24e9b2e3b0d2809d73e644a121c87b 100644 (file)
@@ -432,7 +432,7 @@ private:
   // the epoch when the pg mapping was calculated
   epoch_t creating_pgs_epoch = 0;
   creating_pgs_t creating_pgs;
-  Spinlock creating_pgs_lock;
+  std::mutex creating_pgs_lock;
 
   creating_pgs_t update_pending_creatings(const OSDMap::Incremental& inc);
   void trim_creating_pgs(creating_pgs_t *creating_pgs, const PGMap& pgm);