From: Samuel Just Date: Sun, 17 Jun 2012 23:16:42 +0000 (-0700) Subject: OSD,PG: clean up _get_or_create_pg and set interval based on msg X-Git-Tag: v0.50~109^2~2^2~37 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8079a489bd3de3dce73f977be7467ff9db4c015c;p=ceph.git OSD,PG: clean up _get_or_create_pg and set interval based on msg Previously, we set last_peering_reset based on the epoch in which the pg is created. We now pass the map from the query_epoch to the creation methods to set based on that. Signed-off-by: Samuel Just --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 9d3077f3a38e..5bfdf7d00286 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1213,7 +1213,9 @@ void OSD::_put_pool(PGPool *p) } } -PG *OSD::_open_lock_pg(pg_t pgid, bool no_lockdep_check, bool hold_map_lock) +PG *OSD::_open_lock_pg( + OSDMapRef createmap, + pg_t pgid, bool no_lockdep_check, bool hold_map_lock) { assert(osd_lock.is_locked()); @@ -1226,7 +1228,7 @@ PG *OSD::_open_lock_pg(pg_t pgid, bool no_lockdep_check, bool hold_map_lock) hobject_t logoid = make_pg_log_oid(pgid); hobject_t infooid = make_pg_biginfo_oid(pgid); if (osdmap->get_pg_type(pgid) == pg_pool_t::TYPE_REP) - pg = new ReplicatedPG(&service, osdmap, pool, pgid, logoid, infooid); + pg = new ReplicatedPG(&service, createmap, pool, pgid, logoid, infooid); else assert(0); @@ -1241,15 +1243,17 @@ PG *OSD::_open_lock_pg(pg_t pgid, bool no_lockdep_check, bool hold_map_lock) return pg; } -PG *OSD::_create_lock_pg(pg_t pgid, bool newly_created, bool hold_map_lock, - int role, vector& up, vector& acting, pg_history_t history, - pg_interval_map_t& pi, - ObjectStore::Transaction& t) +PG *OSD::_create_lock_pg( + OSDMapRef createmap, + pg_t pgid, bool newly_created, bool hold_map_lock, + int role, vector& up, vector& acting, pg_history_t history, + pg_interval_map_t& pi, + ObjectStore::Transaction& t) { assert(osd_lock.is_locked()); dout(20) << "_create_lock_pg pgid " << pgid << dendl; - PG *pg = _open_lock_pg(pgid, true, hold_map_lock); + PG *pg = _open_lock_pg(createmap, pgid, true, hold_map_lock); t.create_collection(coll_t(pgid)); @@ -1337,6 +1341,8 @@ void OSD::load_pgs() if (it->is_removal(&seq, &pgid)) { if (seq >= next_removal_seq) next_removal_seq = seq + 1; + dout(10) << "queueing coll " << *it << " for removal, seq is " + << seq << "pgid is " << pgid << dendl; boost::tuple *to_queue = new boost::tuple; to_queue->get<0>() = *it; @@ -1366,7 +1372,7 @@ void OSD::load_pgs() continue; } - PG *pg = _open_lock_pg(pgid); + PG *pg = _open_lock_pg(osdmap, pgid); // read pg state, log pg->read_state(store); @@ -1439,8 +1445,10 @@ PG *OSD::get_or_create_pg(const pg_info_t& info, pg_interval_map_t& pi, // ok, create PG locally using provided Info and History PG::RecoveryCtx rctx = create_context(); - pg = _create_lock_pg(info.pgid, create, false, role, up, acting, history, pi, - *rctx.transaction); + pg = _create_lock_pg( + get_map(epoch), + info.pgid, create, false, role, up, acting, history, pi, + *rctx.transaction); pg->handle_create(&rctx); dispatch_context(rctx, pg); @@ -3965,7 +3973,7 @@ void OSD::do_split(PG *parent, set& childpgids, ObjectStore::Transaction& history.same_interval_since = history.same_primary_since = osdmap->get_epoch(); pg_interval_map_t pi; - PG *pg = _create_lock_pg(*q, true, true, + PG *pg = _create_lock_pg(service.get_osdmap(), *q, true, true, parent->get_role(), parent->up, parent->acting, history, pi, t); children[*q] = pg; dout(10) << " child " << *pg << dendl; @@ -4207,10 +4215,11 @@ void OSD::handle_pg_create(OpRequestRef op) if (can_create_pg(pgid)) { pg_interval_map_t pi; PG::RecoveryCtx rctx = create_context(); - PG *pg = _create_lock_pg(pgid, true, false, - 0, creating_pgs[pgid].acting, creating_pgs[pgid].acting, - history, pi, - *rctx.transaction); + PG *pg = _create_lock_pg( + osdmap, pgid, true, false, + 0, creating_pgs[pgid].acting, creating_pgs[pgid].acting, + history, pi, + *rctx.transaction); creating_pgs.erase(pgid); wake_pg_waiters(pg->info.pgid); pg->handle_create(&rctx); diff --git a/src/osd/OSD.h b/src/osd/OSD.h index ff45cdd69fe3..f332f4ed944b 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -259,6 +259,10 @@ public: Mutex pg_temp_lock; map > pg_temp_wanted; void queue_want_pg_temp(pg_t pgid, vector& want); + void remove_want_pg_temp(pg_t pgid) { + Mutex::Locker l(pg_temp_lock); + pg_temp_wanted.erase(pgid); + } void send_pg_temp(); void queue_for_peering(PG *pg); @@ -693,11 +697,16 @@ protected: bool _have_pg(pg_t pgid); PG *_lookup_lock_pg(pg_t pgid); PG *_lookup_lock_pg_with_map_lock_held(pg_t pgid); - PG *_open_lock_pg(pg_t pg, bool no_lockdep_check=false, bool hold_map_lock=false); - PG *_create_lock_pg(pg_t pgid, bool newly_created, bool hold_map_lock, - int role, vector& up, vector& acting, + PG *_open_lock_pg(OSDMapRef createmap, + pg_t pg, bool no_lockdep_check=false, + bool hold_map_lock=false); + PG *_create_lock_pg(OSDMapRef createmap, + pg_t pgid, bool newly_created, + bool hold_map_lock, int role, + vector& up, vector& acting, pg_history_t history, - pg_interval_map_t& pi, ObjectStore::Transaction& t); + pg_interval_map_t& pi, + ObjectStore::Transaction& t); PG *lookup_lock_raw_pg(pg_t pgid); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index cccebf6a960f..12008f49af95 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1243,7 +1243,8 @@ void PG::activate(ObjectStore::Transaction& t, list& tfin, assert(!is_active()); // -- crash recovery? - if (pool->info.crash_replay_interval > 0 && + if (is_primary() && + pool->info.crash_replay_interval > 0 && may_need_replay(get_osdmap())) { replay_until = ceph_clock_now(g_ceph_context); replay_until += pool->info.crash_replay_interval; @@ -3852,7 +3853,7 @@ void PG::start_peering_interval(const OSDMapRef lastmap, } } // make sure we clear out any pg_temp change requests - osd->pg_temp_wanted.erase(info.pgid); + osd->remove_want_pg_temp(info.pgid); cancel_recovery(); if (acting.empty() && up.size() && up[0] == osd->whoami) { @@ -4267,6 +4268,7 @@ boost::statechart::result PG::RecoveryState::Initial::react(const MNotifyRec& no PG *pg = context< RecoveryMachine >().pg; pg->proc_replica_info(notify.from, notify.notify.info); pg->update_heartbeat_peers(); + pg->set_last_peering_reset(); return transit< Primary >(); } @@ -4288,8 +4290,6 @@ boost::statechart::result PG::RecoveryState::Initial::react(const MLogRec& i) void PG::RecoveryState::Initial::exit() { - PG *pg = context< RecoveryMachine >().pg; - pg->set_last_peering_reset(); context< RecoveryMachine >().log_exit(state_name, enter_time); } diff --git a/src/osd/PG.h b/src/osd/PG.h index be1d58d2ab36..a004b35b08a5 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1048,9 +1048,6 @@ public: typedef boost::mpl::list < boost::statechart::transition< Initialize, Reset >, boost::statechart::transition< Load, Reset >, - boost::statechart::custom_reaction< MNotifyRec >, - boost::statechart::custom_reaction< MInfoRec >, - boost::statechart::custom_reaction< MLogRec >, boost::statechart::custom_reaction< NullEvt >, boost::statechart::transition< boost::statechart::event_base, Crashed > > reactions; diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 846e40fa92ee..6bc433662361 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -282,10 +282,10 @@ bool coll_t::is_pg(pg_t& pgid, snapid_t& snap) const bool coll_t::is_removal(uint64_t *seq, pg_t *pgid) const { - if (str.substr(0, 12) != string("FORREMOVAL_")) + if (str.substr(0, 11) != string("FORREMOVAL_")) return false; - stringstream ss(str.substr(12)); + stringstream ss(str.substr(11)); ss >> *seq; char sep; ss >> sep;