From 425f337a993fde64e36b5f76d4290b29d58a0a87 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 19 Jul 2021 09:17:29 +0800 Subject: [PATCH] crimson/osd: s/FuturizedStore*/FuturizedStore&/ in OSDMeta and PGMeta's ctors 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 --- src/crimson/osd/osd.cc | 8 ++++---- src/crimson/osd/osd_meta.cc | 10 +++++----- src/crimson/osd/osd_meta.h | 4 ++-- src/crimson/osd/pg.cc | 2 +- src/crimson/osd/pg_meta.cc | 26 +++++++++++++------------- src/crimson/osd/pg_meta.h | 4 ++-- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 17acd6f01a91e..d8927475b6ded 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -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(ch, &store); + meta_coll = make_unique(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(ch , &store); + meta_coll = make_unique(ch, store); 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(ch, &store); + meta_coll = make_unique(ch, store); return meta_coll->load_superblock(); }).then([this](OSDSuperblock&& sb) { superblock = std::move(sb); @@ -618,7 +618,7 @@ seastar::future> 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); diff --git a/src/crimson/osd/osd_meta.cc b/src/crimson/osd/osd_meta.cc index 9b9215f5b6166..02a7675b433b0 100644 --- a/src/crimson/osd/osd_meta.cc +++ b/src/crimson/osd/osd_meta.cc @@ -25,9 +25,9 @@ void OSDMeta::store_map(ceph::os::Transaction& t, seastar::future 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 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> 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; diff --git a/src/crimson/osd/osd_meta.h b/src/crimson/osd/osd_meta.h index 84157208754d1..df14441808851 100644 --- a/src/crimson/osd/osd_meta.h +++ b/src/crimson/osd/osd_meta.h @@ -23,12 +23,12 @@ namespace crimson::os { class OSDMeta { template using Ref = boost::intrusive_ptr; - crimson::os::FuturizedStore* store; + crimson::os::FuturizedStore& store; Ref coll; public: OSDMeta(Ref coll, - crimson::os::FuturizedStore* store) + crimson::os::FuturizedStore& store) : store{store}, coll{coll} {} diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index 3d01246e69a3f..32d7a0c8d633a 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -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); diff --git a/src/crimson/osd/pg_meta.cc b/src/crimson/osd/pg_meta.cc index ad538596355cb..6ab4c58fd5b29 100644 --- a/src/crimson/osd/pg_meta.cc +++ b/src/crimson/osd/pg_meta.cc @@ -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 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 PGMeta::get_epoch() seastar::future> 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 diff --git a/src/crimson/osd/pg_meta.h b/src/crimson/osd/pg_meta.h index e0aa02716917b..3b1ab92c3878a 100644 --- a/src/crimson/osd/pg_meta.h +++ b/src/crimson/osd/pg_meta.h @@ -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::FuturizedStore& store, spg_t pgid); seastar::future get_epoch(); seastar::future> load(); }; -- 2.39.5