]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: move new pg initialization into PG::info()
authorSage Weil <sage.weil@dreamhost.com>
Mon, 13 Feb 2012 04:32:25 +0000 (20:32 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Mon, 13 Feb 2012 04:48:21 +0000 (20:48 -0800)
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 <sage.weil@dreamhost.com>
src/osd/OSD.cc
src/osd/PG.cc
src/osd/PG.h

index 70f3bd3ae31594b2df6060593c76a63227048838..e760c6a164d4794e036c96e2fb7ee8ba0fb21d09 100644 (file)
@@ -1100,25 +1100,14 @@ PG *OSD::_create_lock_new_pg(pg_t pgid, vector<int>& 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;
index 73e52d4663506c32eea317c76da89e2731bd4382..a619ea103e38d000ce48d4d07b3f396d105bef4f 100644 (file)
@@ -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<int>& newup, vector<int>& 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)
 {
index d262859f0641752afe37635b529016d8e9d73484..5632af5d246e472bcdb136c3be2c02e7dca92206 100644 (file)
@@ -1302,6 +1302,9 @@ public:
 
   bool  is_empty() const { return info.last_update == eversion_t(0,0); }
 
+  void init(int role, vector<int>& up, vector<int>& acting, pg_history_t& history,
+           ObjectStore::Transaction *t);
+
   // pg on-disk state
   void write_info(ObjectStore::Transaction& t);
   void write_log(ObjectStore::Transaction& t);