From 2fb26b24b3621ec885c9641c31480c74719eac4b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 16 Aug 2018 12:22:57 -0500 Subject: [PATCH] osd: make project_pg_history handle concurrent osdmap publish The class's osdmap may be updated while we are in our loop. Pass it in explicitly instead. Fixes: http://tracker.ceph.com/issues/26970 Signed-off-by: Sage Weil (cherry picked from commit cfe6ca82ed800e81e286396b5b7783ca299325f0) Correction to this commit required because of separating it from very large pull request. Needed to include part of 4bc01379bbf946d2f5963dcca6b071914117ce4a which changed endmap from const OSDMap& to const OSDMapRef&. --- src/osd/OSD.cc | 8 +++++--- src/osd/OSD.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 2a2cee1121dc..e15bbdb51b11 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4205,18 +4205,19 @@ void OSD::build_initial_pg_history( * and same_primary_since. */ bool OSD::project_pg_history(spg_t pgid, pg_history_t& h, epoch_t from, + const OSDMapRef& endmap, const vector& currentup, int currentupprimary, const vector& currentacting, int currentactingprimary) { dout(15) << "project_pg_history " << pgid - << " from " << from << " to " << osdmap->get_epoch() + << " from " << from << " to " << endmap->get_epoch() << ", start " << h << dendl; epoch_t e; - for (e = osdmap->get_epoch(); + for (e = endmap->get_epoch(); e > from; e--) { // verify during intermediate epoch (e-1) @@ -4251,7 +4252,7 @@ bool OSD::project_pg_history(spg_t pgid, pg_history_t& h, epoch_t from, } // split? if (pgid.is_split(oldmap->get_pg_num(pgid.pool()), - osdmap->get_pg_num(pgid.pool()), + endmap->get_pg_num(pgid.pool()), 0) && e > h.same_interval_since) { h.same_interval_since = e; } @@ -8618,6 +8619,7 @@ void OSD::handle_pg_query_nopg(const MQuery& q) pg_history_t history = q.query.history; bool valid_history = project_pg_history( pgid, history, q.query.epoch_sent, + osdmap, up, up_primary, acting, acting_primary); if (!valid_history || diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 1739c84e55f5..4aa9ae6aeb64 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1878,6 +1878,7 @@ protected: /// project pg history from from to now bool project_pg_history( spg_t pgid, pg_history_t& h, epoch_t from, + const OSDMapRef& endmap, const vector& lastup, int lastupprimary, const vector& lastacting, -- 2.47.3