From: Kefu Chai Date: Sun, 30 Jul 2017 05:07:02 +0000 (+0800) Subject: mon/OSDMonitor: assert(pg in creating_pgs.pg) in send_pg_creates() X-Git-Tag: v12.1.2~20^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8bc029b6af7d8fbbcbc84ce845157e2580557347;p=ceph-ci.git mon/OSDMonitor: assert(pg in creating_pgs.pg) in send_pg_creates() and mark OSDMonitor::send_pg_creates() a const method. See-also: http://tracker.ceph.com/issues/20785 Signed-off-by: Kefu Chai --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 2f9582ad2c9..9107dc1737e 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3253,7 +3253,7 @@ void OSDMonitor::update_creating_pgs() creating_pgs_epoch = mapping.get_epoch(); } -epoch_t OSDMonitor::send_pg_creates(int osd, Connection *con, epoch_t next) +epoch_t OSDMonitor::send_pg_creates(int osd, Connection *con, epoch_t next) const { dout(30) << __func__ << " osd." << osd << " next=" << next << " " << creating_pgs_by_osd_epoch << dendl; @@ -3277,11 +3277,12 @@ epoch_t OSDMonitor::send_pg_creates(int osd, Connection *con, epoch_t next) m = new MOSDPGCreate(creating_pgs_epoch); // Need the create time from the monitor using its clock to set // last_scrub_stamp upon pg creation. - const auto& creation = creating_pgs.pgs[pg]; - m->mkpg.emplace(pg, pg_create_t{creation.first, pg, 0}); - m->ctimes.emplace(pg, creation.second); + auto create = creating_pgs.pgs.find(pg); + assert(create != creating_pgs.pgs.end()); + m->mkpg.emplace(pg, pg_create_t{create->second.first, pg, 0}); + m->ctimes.emplace(pg, create->second.second); dout(20) << __func__ << " will create " << pg - << " at " << creation.first << dendl; + << " at " << create->second.first << dendl; } } if (!m) { diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 37742af38c3..baee6a894d1 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -451,7 +451,7 @@ protected: // the epoch when the pg mapping was calculated epoch_t creating_pgs_epoch = 0; creating_pgs_t creating_pgs; - std::mutex creating_pgs_lock; + mutable std::mutex creating_pgs_lock; creating_pgs_t update_pending_pgs(const OSDMap::Incremental& inc); void trim_creating_pgs(creating_pgs_t *creating_pgs, @@ -464,7 +464,7 @@ protected: pair get_parent_pg(pg_t pgid) const; void update_creating_pgs(); void check_pg_creates_subs(); - epoch_t send_pg_creates(int osd, Connection *con, epoch_t next); + epoch_t send_pg_creates(int osd, Connection *con, epoch_t next) const; int32_t _allocate_osd_id(int32_t* existing_id);