From: xie xingguo Date: Thu, 25 Aug 2016 02:53:18 +0000 (+0800) Subject: osd/osd_type: check if pool is gone during check_new_interval() X-Git-Tag: v11.0.1~249^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=db1cab82aa3ac258cf4e3ce7b756764fbad0310b;p=ceph.git osd/osd_type: check if pool is gone during check_new_interval() 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 --- diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 79c5db829e9a..e3ab3f470d0b 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -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 old_acting_shards; old_pg_pool.convert_to_pg_shards(old_acting, &old_acting_shards); diff --git a/src/test/osd/types.cc b/src/test/osd/types.cc index a2a853f2fdd5..419c637177bc 100644 --- a/src/test/osd/types.cc +++ b/src/test/osd/types.cc @@ -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 lastmap(new OSDMap()); - lastmap->set_max_osd(10); - lastmap->set_state(osd_id, CEPH_OSD_EXISTS); - lastmap->set_epoch(epoch); - - map 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 //