From: Sage Weil Date: Mon, 13 Feb 2012 04:35:14 +0000 (-0800) Subject: osd: use PG::init() for newly local (but not created) PGs X-Git-Tag: v0.43~93^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=04f175f818abaab38b7d83a099a3587d0fa85d28;p=ceph.git osd: use PG::init() for newly local (but not created) PGs Use the helper for PGs that are newly instantiated on the local OSD. This fixes the initialization of pg->info.stats.{up,acting,mapping_epoch}. We also get rid of a premature (and useless) write_info/log, which has bad information (and is soon after followed by the real/good one). Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index e760c6a164d4..070861fac278 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1065,28 +1065,6 @@ PG *OSD::_open_lock_pg(pg_t pgid, bool no_lockdep_check) return pg; } - -PG *OSD::_create_lock_pg(pg_t pgid, ObjectStore::Transaction& t) -{ - assert(osd_lock.is_locked()); - dout(10) << "_create_lock_pg " << pgid << dendl; - - if (pg_map.count(pgid)) - dout(0) << "_create_lock_pg on " << pgid << ", already have " << *pg_map[pgid] << dendl; - - // open - PG *pg = _open_lock_pg(pgid); - - // create collection - assert(!store->collection_exists(coll_t(pgid))); - t.create_collection(coll_t(pgid)); - - pg->write_info(t); - pg->write_log(t); - - return pg; -} - PG *OSD::_create_lock_new_pg(pg_t pgid, vector& acting, ObjectStore::Transaction& t, pg_history_t history) { @@ -1255,15 +1233,15 @@ PG *OSD::get_or_create_pg(const pg_info_t& info, epoch_t epoch, int from, int& c if (create) { pg = _create_lock_new_pg(info.pgid, acting, **pt, history); } else { - pg = _create_lock_pg(info.pgid, **pt); - pg->acting.swap(acting); - pg->up.swap(up); - pg->set_role(role); - pg->info.history = history; - reg_last_pg_scrub(pg->info.pgid, pg->info.history.last_scrub_stamp); + pg = _open_lock_pg(info.pgid); + + // create collection + assert(!store->collection_exists(coll_t(info.pgid))); + (*pt)->create_collection(coll_t(info.pgid)); + + pg->init(role, up, acting, history, *pt); + pg->clear_primary_state(); // yep, notably, set hml=false - pg->write_info(**pt); - pg->write_log(**pt); } created++; diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 7656bc69ca97..2eff15d72e66 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -443,10 +443,8 @@ protected: bool _have_pg(pg_t pgid); PG *_lookup_lock_pg(pg_t pgid); PG *_open_lock_pg(pg_t pg, bool no_lockdep_check=false); // create new PG (in memory) - PG *_create_lock_pg(pg_t pg, ObjectStore::Transaction& t); // create new PG PG *_create_lock_new_pg(pg_t pgid, vector& acting, ObjectStore::Transaction& t, pg_history_t history); - //void _remove_unlock_pg(PG *pg); // remove from store and memory PG *lookup_lock_raw_pg(pg_t pgid);