]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: use PG::init() for newly local (but not created) PGs
authorSage Weil <sage.weil@dreamhost.com>
Mon, 13 Feb 2012 04:35:14 +0000 (20:35 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Mon, 13 Feb 2012 04:48:21 +0000 (20:48 -0800)
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 <sage.weil@dreamhost.com>
src/osd/OSD.cc
src/osd/OSD.h

index e760c6a164d4794e036c96e2fb7ee8ba0fb21d09..070861fac278f3e1d75122dbeabfc845b4697106 100644 (file)
@@ -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<int>& 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++;
index 7656bc69ca9797bec237aab02b8508d2c8e1e5fe..2eff15d72e661ad7380d387d8ffb81af4530e9a0 100644 (file)
@@ -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<int>& 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);