]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/osd_type: check if pool is gone during check_new_interval() 10859/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 25 Aug 2016 02:53:18 +0000 (10:53 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Mon, 29 Aug 2016 05:34:46 +0000 (13:34 +0800)
In is_new_interval() we'll return true if the relevant pool
does not exist in the lastmap, which means theoretically
we could access violation here if we always suppose the pool
did exist in the lastmap.

This PR add a check to make sure that the above case
does not happen.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/osd/osd_types.cc
src/test/osd/types.cc

index 79c5db829e9a41246fe49ee8edd7a39b3abaafe7..e3ab3f470d0b03f3f43184d7e7bbc6408f538ebd 100644 (file)
@@ -3123,6 +3123,7 @@ bool pg_interval_t::check_new_interval(
       if (*p != CRUSH_ITEM_NONE)
        ++num_acting;
 
+    assert(lastmap->get_pools().count(pgid.pool()));
     const pg_pool_t& old_pg_pool = lastmap->get_pools().find(pgid.pool())->second;
     set<pg_shard_t> old_acting_shards;
     old_pg_pool.convert_to_pg_shards(old_acting, &old_acting_shards);
index a2a853f2fdd5ce55ba30219914ebf62fb92db97a..419c637177bc3540c747c158d5e8e34db22873ab 100644 (file)
@@ -191,40 +191,6 @@ TEST(pg_interval_t, check_new_interval)
     ASSERT_TRUE(past_intervals.empty());
   }
 
-  //
-  // pool did not exist in the old osdmap
-  //
-  {
-    ceph::shared_ptr<OSDMap> lastmap(new OSDMap());
-    lastmap->set_max_osd(10);
-    lastmap->set_state(osd_id, CEPH_OSD_EXISTS);
-    lastmap->set_epoch(epoch);
-
-    map<epoch_t, pg_interval_t> past_intervals;
-
-    ASSERT_TRUE(past_intervals.empty());
-    ASSERT_TRUE(pg_interval_t::check_new_interval(old_primary,
-                                                 new_primary,
-                                                 old_acting,
-                                                 new_acting,
-                                                 old_up_primary,
-                                                 new_up_primary,
-                                                 old_up,
-                                                 new_up,
-                                                 same_interval_since,
-                                                 last_epoch_clean,
-                                                 osdmap,
-                                                 lastmap,
-                                                 pgid,
-                                                  recoverable.get(),
-                                                 &past_intervals));
-    ASSERT_EQ((unsigned int)1, past_intervals.size());
-    ASSERT_EQ(same_interval_since, past_intervals[same_interval_since].first);
-    ASSERT_EQ(osdmap->get_epoch() - 1, past_intervals[same_interval_since].last);
-    ASSERT_EQ(osd_id, past_intervals[same_interval_since].acting[0]);
-    ASSERT_EQ(osd_id, past_intervals[same_interval_since].up[0]);
-  }
-
   //
   // The acting set has changed
   //