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;
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)
{
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);