]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix pg split/merge prime during startup 26492/head
authorSage Weil <sage@redhat.com>
Mon, 18 Feb 2019 21:30:32 +0000 (15:30 -0600)
committerSage Weil <sage@redhat.com>
Mon, 18 Feb 2019 21:30:42 +0000 (15:30 -0600)
The priming of split/merge targets may modify pg_slots, an unordered_map,
which means our iterator may become invalid.  Put PGs in a temporary set
and use that instead.

Fixes: http://tracker.ceph.com/issues/36304
Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc

index 9fb35ff88132a764fe31e48585d8a295a0e42bba..47745b48d9d0f683f02ac08f6da04aed79b14550 100644 (file)
@@ -3101,12 +3101,17 @@ int OSD::init()
   service.max_oldest_map = superblock.oldest_map;
 
   for (auto& shard : shards) {
+    // put PGs in a temporary set because we may modify pg_slots
+    // unordered_map below.
+    set<PGRef> pgs;
     for (auto& i : shard->pg_slots) {
       PGRef pg = i.second->pg;
       if (!pg) {
        continue;
       }
-
+      pgs.insert(pg);
+    }
+    for (auto pg : pgs) {
       pg->lock();
       set<pair<spg_t,epoch_t>> new_children;
       set<pair<spg_t,epoch_t>> merge_pgs;