]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PG: move load_pgs cruft into read_state()
authorSage Weil <sage@redhat.com>
Sat, 16 Sep 2017 03:52:33 +0000 (23:52 -0400)
committerSage Weil <sage@redhat.com>
Fri, 6 Oct 2017 18:08:18 +0000 (13:08 -0500)
This only happens during initial load; move it there.

Also, since update_store_with_options

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc
src/osd/PG.cc
src/osd/PG.h
src/tools/ceph_objectstore_tool.cc
src/tools/rebuild_mondb.cc

index 75a020144b210efd9044f39f01e911a0c3e27ca8..5494ddccb6669d0b80cc97d29943f118e9c29133 100644 (file)
@@ -3941,38 +3941,15 @@ void OSD::load_pgs()
 
     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();
index 1dd26c0d78b12ab22316aa2d9559dfb5ad22262e..946c5147f9991810fde8950db3ce8d59f6bfdf8f 100644 (file)
@@ -3260,6 +3260,30 @@ void PG::read_state(ObjectStore *store)
   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()
@@ -5801,8 +5825,8 @@ boost::statechart::result PG::RecoveryState::Initial::react(const Load& l)
 
   // 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 >();
index 1654bd1acd6b7cc59b72143ac62f5b0bbdc2bb0a..da676e8e82f2554bfdfc26e52f5d79e4b394a37d 100644 (file)
@@ -368,6 +368,18 @@ public:
   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);
@@ -2571,14 +2583,7 @@ protected:
   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);
index e9c3ca7c760c543816e39a6a5f79511b3103f3bd..b177e5dc063fe8a18e2014f7a8b5b25d39eaa6bb 100644 (file)
@@ -3511,10 +3511,10 @@ int main(int argc, char **argv)
       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;
       }
@@ -3536,9 +3536,9 @@ int main(int argc, char **argv)
       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;
index 4225ad81a04e178083d4d9fda18d7047cd30e246..11b34b539012987ccf5211e5fb5bfdbaa627e96a 100644 (file)
@@ -370,7 +370,7 @@ int update_pgmap_pg(ObjectStore& fs, MonitorDBStore& ms)
       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;
     }