]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: do not alter the "created" epoch of a pg
authorKefu Chai <kchai@redhat.com>
Thu, 27 Apr 2017 20:47:18 +0000 (04:47 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 27 Apr 2017 22:25:49 +0000 (06:25 +0800)
Fixes: http://tracker.ceph.com/issues/19787
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/OSDMonitor.cc

index 212195ffd1fadb2f7e43fab8bfd4428e2154d492..cf069c6b4b052e067f585e3d6ff0b32abdb04d20 100644 (file)
@@ -3192,7 +3192,7 @@ void OSDMonitor::update_creating_pgs()
   for (auto& pg : creating_pgs.pgs) {
     int acting_primary = -1;
     auto pgid = pg.first;
-    auto& created = pg.second.first;
+    auto mapped = pg.second.first;
     mapping.get(pgid, nullptr, nullptr, nullptr, &acting_primary);
     // check the previous creating_pgs, look for the target to whom the pg was
     // previously mapped
@@ -3200,15 +3200,14 @@ void OSDMonitor::update_creating_pgs()
       const auto last_acting_primary = pgs_by_epoch.first;
       for (auto& pgs: pgs_by_epoch.second) {
        if (pgs.second.count(pgid)) {
-         if (last_acting_primary != acting_primary) {
+         if (last_acting_primary == acting_primary) {
+           mapped = pgs.first;
+         } else {
            dout(20) << __func__ << " " << pgid << " "
                     << " acting_primary:" << last_acting_primary
                     << " -> " << acting_primary << dendl;
            // note epoch if the target of the create message changed.
-           // creating_pgs is updated here instead of in
-           // scan_for_creating_pgs() because we don't have the updated pg
-           // mapping by then.
-           created = mapping.get_epoch();
+           mapped = mapping.get_epoch();
           }
           break;
         }
@@ -3216,7 +3215,7 @@ void OSDMonitor::update_creating_pgs()
     }
     dout(10) << __func__ << " will instruct osd." << acting_primary
             << " to create " << pgid << dendl;
-    new_pgs_by_osd_epoch[acting_primary][created].insert(pgid);
+    new_pgs_by_osd_epoch[acting_primary][mapped].insert(pgid);
   }
   creating_pgs_by_osd_epoch = std::move(new_pgs_by_osd_epoch);
   creating_pgs_epoch = mapping.get_epoch();