]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: pass pgid, osdmap and msgr to PG's ctor
authorKefu Chai <kchai@redhat.com>
Fri, 22 Feb 2019 08:16:58 +0000 (16:16 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 20 Mar 2019 06:54:07 +0000 (14:54 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/osd.cc
src/crimson/osd/pg.cc
src/crimson/osd/pg.h

index cb163a1119ebd9044bdaca3086bdf11841d40743..bb3acbae39b4877877e235c89610cee3b35d957d 100644 (file)
@@ -337,10 +337,16 @@ seastar::future<Ref<PG>> OSD::load_pg(spg_t pgid)
       // pool was deleted; grab final pg_pool_t off disk.
       return meta_coll->load_final_pool_info(pgid.pool());
     }
-  }).then([this](pg_pool_t&& pool, string&& name, ec_profile_t&& ec_profile) {
-    Ref<PG> pg{new PG{std::move(pool),
+  }).then([pgid, this](pg_pool_t&& pool,
+                       string&& name,
+                       ec_profile_t&& ec_profile) {
+    Ref<PG> pg{new PG{pgid,
+                      pg_shard_t{whoami, pgid.shard},
+                      std::move(pool),
                       std::move(name),
-                      std::move(ec_profile)}};
+                      std::move(ec_profile),
+                      osdmap,
+                      cluster_msgr}};
     return seastar::make_ready_future<Ref<PG>>(std::move(pg));
   });
 }
index bc7b8c2d8a7a2e844ff4b0f4190b2913f56e6de6..d256eb8b46d5536f5a4b638b708c06c6c872ba81 100644 (file)
@@ -1,6 +1,30 @@
 #include "pg.h"
 
-PG::PG(pg_pool_t&& pool, std::string&& name, ec_profile_t&& ec_profile)
+#include "osd/OSDMap.h"
+
+
+PG::PG(spg_t pgid,
+       pg_shard_t pg_shard,
+       pg_pool_t&& pool,
+       std::string&& name,
+       ec_profile_t&& ec_profile,
+       cached_map_t osdmap,
+       ceph::net::Messenger* msgr)
+  : pgid{pgid},
+    whoami{pg_shard},
+    pool{std::move(pool)},
+    osdmap{osdmap},
+    msgr{msgr}
 {
   // TODO
 }
+
+epoch_t PG::get_osdmap_epoch() const
+{
+  return osdmap->get_epoch();
+}
+
+pg_shard_t PG::get_whoami() const
+{
+  return whoami;
+}
index 4bb672f4b08af56d57891dbd7339763b9270beee..05dc8028cb4bd90246cc5602029cd93238a665b1 100644 (file)
@@ -5,17 +5,41 @@
 
 #include <boost/intrusive_ptr.hpp>
 #include <boost/smart_ptr/intrusive_ref_counter.hpp>
+#include <boost/smart_ptr/local_shared_ptr.hpp>
 #include <seastar/core/future.hh>
 
 #include "osd/osd_types.h"
 
 template<typename T> using Ref = boost::intrusive_ptr<T>;
+class OSDMap;
+
+namespace ceph::net {
+  class Messenger;
+}
 
 class PG : public boost::intrusive_ref_counter<
   PG,
   boost::thread_unsafe_counter>
 {
   using ec_profile_t = std::map<std::string,std::string>;
+  using cached_map_t = boost::local_shared_ptr<OSDMap>;
+
 public:
-  PG(pg_pool_t&& pool, std::string&& name, ec_profile_t&& ec_profile);
+  PG(spg_t pgid,
+     pg_shard_t pg_shard,
+     pg_pool_t&& pool,
+     std::string&& name,
+     ec_profile_t&& ec_profile,
+     cached_map_t osdmap,
+     ceph::net::Messenger* msgr);
+
+  epoch_t get_osdmap_epoch() const;
+  pg_shard_t get_whoami() const;
+
+private:
+  const spg_t pgid;
+  pg_shard_t whoami;
+  pg_pool_t pool;
+  cached_map_t osdmap;
+  ceph::net::Messenger* msgr = nullptr;
 };