]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: make save osdmap accessor for OSDShard
authorSage Weil <sage@redhat.com>
Tue, 20 Feb 2018 21:20:39 +0000 (15:20 -0600)
committerSage Weil <sage@redhat.com>
Wed, 4 Apr 2018 13:26:56 +0000 (08:26 -0500)
The advance_pg needs to get the shard osdmap without racing against
consume_map().

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

index a18dd24312c319b27a6330a01ddd2dd3b7541941..b3e89cd3d8642b5d973306b8dfa7e29bf08eb4fa 100644 (file)
@@ -8796,7 +8796,7 @@ void OSD::dequeue_peering_evt(
   ThreadPool::TPHandle& handle)
 {
   PG::RecoveryCtx rctx = create_context();
-  auto curmap = sdata->osdmap;
+  auto curmap = sdata->get_osdmap();
   epoch_t need_up_thru = 0, same_interval_since = 0;
   if (!pg) {
     if (const MQuery *q = dynamic_cast<const MQuery*>(evt->evt.get())) {
@@ -9281,8 +9281,12 @@ void OSDShard::consume_map(
   set<spg_t> *new_children)
 {
   Mutex::Locker l(sdata_op_ordering_lock);
-  OSDMapRef old_osdmap = std::move(osdmap);
-  osdmap = new_osdmap;
+  OSDMapRef old_osdmap;
+  {
+    Mutex::Locker l(osdmap_lock);
+    old_osdmap = std::move(osdmap);
+    osdmap = new_osdmap;
+  }
   dout(10) << new_osdmap->get_epoch()
            << " (was " << (old_osdmap ? old_osdmap->get_epoch() : 0) << ")"
           << dendl;
index 85d5daaf25d8fe31e9a5ca94b1a696f5de586d1e..658e8a317390bd890d4ceaa65a6a7714e3bd12e8 100644 (file)
@@ -1064,8 +1064,15 @@ struct OSDShard {
   string sdata_op_ordering_lock_name;
   Mutex sdata_op_ordering_lock;   ///< protects all members below
 
+  string osdmap_lock_name;
+  Mutex osdmap_lock;
   OSDMapRef osdmap;
 
+  OSDMapRef get_osdmap() {
+    Mutex::Locker l(osdmap_lock);
+    return osdmap;
+  }
+
   /// map of slots for each spg_t.  maintains ordering of items dequeued
   /// from pqueue while _process thread drops shard lock to acquire the
   /// pg lock.  stale slots are removed by consume_map.
@@ -1141,6 +1148,8 @@ struct OSDShard {
       sdata_op_ordering_lock_name(shard_name + "::sdata_op_ordering_lock"),
       sdata_op_ordering_lock(sdata_op_ordering_lock_name.c_str(), false, true,
                             false, cct),
+      osdmap_lock_name(shard_name + "::osdmap_lock"),
+      osdmap_lock(osdmap_lock_name.c_str(), false, false) {
     if (opqueue == io_queue::weightedpriority) {
       pqueue = std::make_unique<
        WeightedPriorityQueue<OpQueueItem,uint64_t>>(