From cefa55b288b40e17ade9875493dd94de52ac22bf Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 12 Feb 2012 20:32:25 -0800 Subject: [PATCH] osd: move new pg initialization into PG::info() Move initialization of misc elements of the new pg from OSD.cc to a PG method. No change in functionality. Signed-off-by: Sage Weil --- src/osd/OSD.cc | 15 ++------------- src/osd/PG.cc | 33 +++++++++++++++++++++++++++++++++ src/osd/PG.h | 3 +++ 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 70f3bd3ae315..e760c6a164d4 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1100,25 +1100,14 @@ PG *OSD::_create_lock_new_pg(pg_t pgid, vector& acting, ObjectStore::Transa assert(!store->collection_exists(coll_t(pgid))); t.create_collection(coll_t(pgid)); - pg->set_role(0); - pg->acting.swap(acting); - pg->up = pg->acting; - pg->info.history = history; /* This is weird, but all the peering code needs last_epoch_start * to be less than same_interval_since. Make it so! * This is easier to deal with if you remember that the PG, while * now created in memory, still hasn't peered and started -- and * the map epoch could change before that happens! */ - pg->info.history.last_epoch_started = history.epoch_created - 1; + history.last_epoch_started = history.epoch_created - 1; - pg->info.stats.up = pg->up; - pg->info.stats.acting = pg->acting; - pg->info.stats.mapping_epoch = pg->info.history.same_interval_since; - - pg->write_info(t); - pg->write_log(t); - - reg_last_pg_scrub(pg->info.pgid, pg->info.history.last_scrub_stamp); + pg->init(0, acting, acting, history, &t); dout(7) << "_create_lock_new_pg " << *pg << dendl; return pg; diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 73e52d466350..a619ea103e38 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1733,6 +1733,39 @@ void PG::clear_stats() osd->pg_stat_queue_dequeue(this); } +/** + * initialize a newly instantiated pg + * + * Initialize PG state, as when a PG is initially created, or when it + * is first instantiated on the current node. + * + * @param role our role/rank + * @param newup up set + * @param newacting acting set + * @param history pg history + * @param t transaction to write out our new state in + */ +void PG::init(int role, vector& newup, vector& newacting, pg_history_t& history, + ObjectStore::Transaction *t) +{ + dout(10) << "init role " << role << " up " << up << " acting " << acting + << " history " << history << dendl; + + set_role(role); + acting = newacting; + up = newup; + + info.history = history; + + info.stats.up = up; + info.stats.acting = acting; + info.stats.mapping_epoch = info.history.same_interval_since; + + osd->reg_last_pg_scrub(info.pgid, info.history.last_scrub_stamp); + + write_info(*t); + write_log(*t); +} void PG::write_info(ObjectStore::Transaction& t) { diff --git a/src/osd/PG.h b/src/osd/PG.h index d262859f0641..5632af5d246e 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1302,6 +1302,9 @@ public: bool is_empty() const { return info.last_update == eversion_t(0,0); } + void init(int role, vector& up, vector& acting, pg_history_t& history, + ObjectStore::Transaction *t); + // pg on-disk state void write_info(ObjectStore::Transaction& t); void write_log(ObjectStore::Transaction& t); -- 2.47.3