]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: s/FuturizedStore*/FuturizedStore&/ in OSDMeta and PGMeta's ctors 42388/head
authorKefu Chai <kchai@redhat.com>
Mon, 19 Jul 2021 01:17:29 +0000 (09:17 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 19 Jul 2021 01:56:28 +0000 (09:56 +0800)
since we always pass a valid store reference to these ctors, there is no
reason to use a pointer. let's use a reference instead.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/osd.cc
src/crimson/osd/osd_meta.cc
src/crimson/osd/osd_meta.h
src/crimson/osd/pg.cc
src/crimson/osd/pg_meta.cc
src/crimson/osd/pg_meta.h

index 17acd6f01a91eafbf81b84f224cca28d9f319ec2..d8927475b6deddc7da8f7333a3ade4b71fe95c74 100644 (file)
@@ -170,7 +170,7 @@ seastar::future<> OSD::_write_superblock()
   return store.open_collection(coll_t::meta()).then([this] (auto ch) {
     if (ch) {
       // if we already have superblock, check if it matches
-      meta_coll = make_unique<OSDMeta>(ch, &store);
+      meta_coll = make_unique<OSDMeta>(ch, store);
       return meta_coll->load_superblock().then([this](OSDSuperblock&& sb) {
         if (sb.cluster_fsid != superblock.cluster_fsid) {
           logger().error("provided cluster fsid {} != superblock's {}",
@@ -191,7 +191,7 @@ seastar::future<> OSD::_write_superblock()
         superblock.cluster_fsid,
         superblock.osd_fsid);
       return store.create_new_collection(coll_t::meta()).then([this] (auto ch) {
-        meta_coll = make_unique<OSDMeta>(ch , &store);
+        meta_coll = make_unique<OSDMeta>(chstore);
         ceph::os::Transaction t;
         meta_coll->create(t);
         meta_coll->store_superblock(t, superblock);
@@ -253,7 +253,7 @@ seastar::future<> OSD::start()
   }).then([this] {
     return store.open_collection(coll_t::meta());
   }).then([this](auto ch) {
-    meta_coll = make_unique<OSDMeta>(ch, &store);
+    meta_coll = make_unique<OSDMeta>(ch, store);
     return meta_coll->load_superblock();
   }).then([this](OSDSuperblock&& sb) {
     superblock = std::move(sb);
@@ -618,7 +618,7 @@ seastar::future<Ref<PG>> OSD::load_pg(spg_t pgid)
 {
   logger().debug("{}: {}", __func__, pgid);
 
-  return seastar::do_with(PGMeta(&store, pgid), [] (auto& pg_meta) {
+  return seastar::do_with(PGMeta(store, pgid), [](auto& pg_meta) {
     return pg_meta.get_epoch();
   }).then([this](epoch_t e) {
     return get_map(e);
index 9b9215f5b61660839aa1f9ff99fe48aceafea665..02a7675b433b0a34f30af5d8e79bd148ca8e73f8 100644 (file)
@@ -25,9 +25,9 @@ void OSDMeta::store_map(ceph::os::Transaction& t,
 
 seastar::future<bufferlist> OSDMeta::load_map(epoch_t e)
 {
-  return store->read(coll,
-                     osdmap_oid(e), 0, 0,
-                     CEPH_OSD_OP_FLAG_FADVISE_WILLNEED).handle_error(
+  return store.read(coll,
+                    osdmap_oid(e), 0, 0,
+                    CEPH_OSD_OP_FLAG_FADVISE_WILLNEED).handle_error(
     read_errorator::all_same_way([e] {
       throw std::runtime_error(fmt::format("read gave enoent on {}",
                                            osdmap_oid(e)));
@@ -44,7 +44,7 @@ void OSDMeta::store_superblock(ceph::os::Transaction& t,
 
 seastar::future<OSDSuperblock> OSDMeta::load_superblock()
 {
-  return store->read(coll, superblock_oid(), 0, 0).safe_then(
+  return store.read(coll, superblock_oid(), 0, 0).safe_then(
     [] (bufferlist&& bl) {
       auto p = bl.cbegin();
       OSDSuperblock superblock;
@@ -60,7 +60,7 @@ seastar::future<std::tuple<pg_pool_t,
                           std::string,
                           OSDMeta::ec_profile_t>>
 OSDMeta::load_final_pool_info(int64_t pool) {
-  return store->read(coll, final_pool_info_oid(pool),
+  return store.read(coll, final_pool_info_oid(pool),
                      0, 0).safe_then([] (bufferlist&& bl) {
     auto p = bl.cbegin();
     pg_pool_t pi;
index 84157208754d192f490b9f7ede85f9a1fd91140c..df1444180885184cfd740952753caa5b38530508 100644 (file)
@@ -23,12 +23,12 @@ namespace crimson::os {
 class OSDMeta {
   template<typename T> using Ref = boost::intrusive_ptr<T>;
 
-  crimson::os::FuturizedStore* store;
+  crimson::os::FuturizedStore& store;
   Ref<crimson::os::FuturizedCollection> coll;
 
 public:
   OSDMeta(Ref<crimson::os::FuturizedCollection> coll,
-          crimson::os::FuturizedStore* store)
+          crimson::os::FuturizedStore& store)
     : store{store}, coll{coll}
   {}
 
index 3d01246e69a3f65f74392b453acff217c516329b..32d7a0c8d633adc4af442a5ab9e686e96432aa46 100644 (file)
@@ -419,7 +419,7 @@ seastar::future<> PG::read_state(crimson::os::FuturizedStore* store)
        crimson::common::system_shutdown_exception());
   }
 
-  return seastar::do_with(PGMeta(store, pgid), [] (auto& pg_meta) {
+  return seastar::do_with(PGMeta(*store, pgid), [] (auto& pg_meta) {
     return pg_meta.load();
   }).then([this, store](auto&& ret) {
     auto [pg_info, past_intervals] = std::move(ret);
index ad538596355cbd9c7add3b30777c3b8203f09430..6ab4c58fd5b29cec926515bad2b0ba1d9ac604e2 100644 (file)
@@ -12,7 +12,7 @@
 // easily skip them
 using crimson::os::FuturizedStore;
 
-PGMeta::PGMeta(FuturizedStore* store, spg_t pgid)
+PGMeta::PGMeta(FuturizedStore& store, spg_t pgid)
   : store{store},
     pgid{pgid}
 {}
@@ -35,11 +35,11 @@ namespace {
 
 seastar::future<epoch_t> PGMeta::get_epoch()
 {
-  return store->open_collection(coll_t{pgid}).then([this](auto ch) {
-    return store->omap_get_values(ch,
-                                pgid.make_pgmeta_oid(),
-                                {string{infover_key},
-                                 string{epoch_key}}).safe_then(
+  return store.open_collection(coll_t{pgid}).then([this](auto ch) {
+    return store.omap_get_values(ch,
+                                 pgid.make_pgmeta_oid(),
+                                 {string{infover_key},
+                                  string{epoch_key}}).safe_then(
     [](auto&& values) {
       {
         // sanity check
@@ -63,13 +63,13 @@ seastar::future<epoch_t> PGMeta::get_epoch()
 
 seastar::future<std::tuple<pg_info_t, PastIntervals>> PGMeta::load()
 {
-  return store->open_collection(coll_t{pgid}).then([this](auto ch) {
-    return store->omap_get_values(ch,
-                                pgid.make_pgmeta_oid(),
-                                {string{infover_key},
-                                 string{info_key},
-                                 string{biginfo_key},
-                                 string{fastinfo_key}});
+  return store.open_collection(coll_t{pgid}).then([this](auto ch) {
+    return store.omap_get_values(ch,
+                                 pgid.make_pgmeta_oid(),
+                                 {string{infover_key},
+                                  string{info_key},
+                                  string{biginfo_key},
+                                  string{fastinfo_key}});
   }).safe_then([](auto&& values) {
     {
       // sanity check
index e0aa02716917b93dfbef1e258b4c61c0e5e750a8..3b1ab92c3878a95803295b8e64701bc6f659a8a3 100644 (file)
@@ -14,10 +14,10 @@ namespace crimson::os {
 /// PG related metadata
 class PGMeta
 {
-  crimson::os::FuturizedStore* store;
+  crimson::os::FuturizedStore& store;
   const spg_t pgid;
 public:
-  PGMeta(crimson::os::FuturizedStore *store, spg_t pgid);
+  PGMeta(crimson::os::FuturizedStorestore, spg_t pgid);
   seastar::future<epoch_t> get_epoch();
   seastar::future<std::tuple<pg_info_t, PastIntervals>> load();
 };