This only happens during initial load; move it there.
Also, since update_store_with_options
Signed-off-by: Sage Weil <sage@redhat.com>
service.init_splits_between(pg->pg_id, pg->get_osdmap(), osdmap);
- // generate state for PG's current mapping
- int primary, up_primary;
- vector<int> acting, up;
- pg->get_osdmap()->pg_to_up_acting_osds(
- pgid.pgid, &up, &up_primary, &acting, &primary);
- pg->init_primary_up_acting(
- up,
- acting,
- up_primary,
- primary);
- int role = OSDMap::calc_pg_role(whoami, pg->acting);
- if (pg->pool.info.is_replicated() || role == pg->pg_whoami.shard)
- pg->set_role(role);
- else
- pg->set_role(-1);
-
pg->reg_next_scrub();
- PG::RecoveryCtx rctx(0, 0, 0, 0, 0, 0);
- pg->handle_loaded(&rctx);
-
- dout(10) << "load_pgs loaded " << *pg << " " << pg->pg_log.get_log() << dendl;
- if (pg->pg_log.is_dirty()) {
- ObjectStore::Transaction t;
- pg->write_if_dirty(t);
- store->apply_transaction(pg->osr.get(), std::move(t));
- }
+ dout(10) << __func__ << " loaded " << *pg << " " << pg->pg_log.get_log()
+ << dendl;
pg->unlock();
}
{
RWLock::RLocker l(pg_map_lock);
- dout(0) << "load_pgs opened " << pg_map.size() << " pgs" << dendl;
+ dout(0) << __func__ << " opened " << pg_map.size() << " pgs" << dendl;
}
build_past_intervals_parallel();
if (info_struct_v < latest_struct_v) {
upgrade(store);
}
+
+ // initialize current mapping
+ {
+ int primary, up_primary;
+ vector<int> acting, up;
+ get_osdmap()->pg_to_up_acting_osds(
+ pg_id.pgid, &up, &up_primary, &acting, &primary);
+ init_primary_up_acting(
+ up,
+ acting,
+ up_primary,
+ primary);
+ int rr = OSDMap::calc_pg_role(osd->whoami, acting);
+ if (pool.info.is_replicated() || rr == pg_whoami.shard)
+ set_role(rr);
+ else
+ set_role(-1);
+ }
+
+ PG::RecoveryCtx rctx(0, 0, 0, 0, 0, new ObjectStore::Transaction);
+ handle_loaded(&rctx);
+ write_if_dirty(*rctx.transaction);
+ store->apply_transaction(osr.get(), std::move(*rctx.transaction));
+ delete rctx.transaction;
}
void PG::log_weirdness()
// do we tell someone we're here?
pg->send_notify = (!pg->is_primary());
- pg->update_store_with_options();
+ pg->update_store_with_options();
pg->update_store_on_load();
return transit< Reset >();
void read_state(ObjectStore *store);
static int peek_map_epoch(ObjectStore *store, spg_t pgid, epoch_t *pepoch);
+ static int get_latest_struct_v() {
+ return latest_struct_v;
+ }
+ static int get_compat_struct_v() {
+ return compat_struct_v;
+ }
+ static int read_info(
+ ObjectStore *store, spg_t pgid, const coll_t &coll,
+ pg_info_t &info, PastIntervals &past_intervals,
+ __u8 &);
+ static bool _has_removal_flag(ObjectStore *store, spg_t pgid);
+
void rm_backoff(BackoffRef b);
void scrub(epoch_t queued, ThreadPool::TPHandle &handle);
void trim_log();
std::string get_corrupt_pg_log_name() const;
-public:
- static int read_info(
- ObjectStore *store, spg_t pgid, const coll_t &coll,
- pg_info_t &info, PastIntervals &past_intervals,
- __u8 &);
- static bool _has_removal_flag(ObjectStore *store, spg_t pgid);
-protected:
void update_snap_map(
const vector<pg_log_entry_t> &log_entries,
ObjectStore::Transaction& t);
ObjectStore::Transaction tran;
ObjectStore::Transaction *t = &tran;
- if (struct_ver < PG::compat_struct_v) {
+ if (struct_ver < PG::get_compat_struct_v()) {
cerr << "Can't remove past-intervals, version mismatch " << (int)struct_ver
- << " (pg) < compat " << (int)PG::compat_struct_v << " (tool)"
- << std::endl;
+ << " (pg) < compat " << (int)PG::get_compat_struct_v() << " (tool)"
+ << std::endl;
ret = -EFAULT;
goto out;
}
ObjectStore::Transaction tran;
ObjectStore::Transaction *t = &tran;
- if (struct_ver < PG::compat_struct_v) {
+ if (struct_ver < PG::get_compat_struct_v()) {
cerr << "Can't mark-complete, version mismatch " << (int)struct_ver
- << " (pg) < compat " << (int)PG::compat_struct_v << " (tool)"
+ << " (pg) < compat " << (int)PG::get_compat_struct_v() << " (tool)"
<< std::endl;
ret = 1;
goto out;
cerr << "failed to read_info: " << cpp_strerror(r) << std::endl;
return r;
}
- if (struct_v < PG::cur_struct_v) {
+ if (struct_v < PG::get_latest_struct_v()) {
cerr << "incompatible pg_info: v" << struct_v << std::endl;
return -EINVAL;
}