From: Samuel Just Date: Thu, 25 Apr 2019 18:40:52 +0000 (-0700) Subject: PGStateUtils: improvements for PGStateHistory X-Git-Tag: v15.1.0~2774^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7508fffece1f1c169ba174d11b99c2610d5437e9;p=ceph.git PGStateUtils: improvements for PGStateHistory Signed-off-by: Samuel Just --- diff --git a/src/osd/PG.h b/src/osd/PG.h index d9bea3b5fc3d..95fbae2b58df 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -198,7 +198,7 @@ public: return recovery_state.get_osdmap(); } - epoch_t get_osdmap_epoch() const override { + epoch_t get_osdmap_epoch() const override final { return recovery_state.get_osdmap()->get_epoch(); } diff --git a/src/osd/PGStateUtils.cc b/src/osd/PGStateUtils.cc index 035b0b8f9f0a..5ffc1f0f16b0 100644 --- a/src/osd/PGStateUtils.cc +++ b/src/osd/PGStateUtils.cc @@ -22,13 +22,13 @@ NamedState::~NamedState() { void PGStateHistory::enter(const utime_t entime, const char* state) { if (pi == nullptr) { - pi = std::unique_ptr(new PGStateInstance); + pi = std::make_unique(); } pi->enter_state(entime, state); } void PGStateHistory::exit(const char* state) { - pi->setepoch(es->get_osdmap_epoch()); + pi->setepoch(es.get_osdmap_epoch()); pi->exit_state(ceph_clock_now()); if (pi->empty()) { reset(); diff --git a/src/osd/PGStateUtils.h b/src/osd/PGStateUtils.h index 3c61d553f345..732425cdc761 100644 --- a/src/osd/PGStateUtils.h +++ b/src/osd/PGStateUtils.h @@ -62,7 +62,7 @@ struct PGStateInstance { class PGStateHistory { public: - PGStateHistory(EpochSource *es) : buffer(10), es(es) {} + PGStateHistory(const EpochSource &es) : buffer(10), es(es) {} void enter(const utime_t entime, const char* state); @@ -83,5 +83,5 @@ public: private: std::unique_ptr pi; boost::circular_buffer> buffer; - EpochSource *es; + const EpochSource &es; }; diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index 013ed49b3a79..79a07ab8b4aa 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -119,7 +119,7 @@ PeeringState::PeeringState( OSDMapRef curmap, DoutPrefixProvider *dpp, PeeringListener *pl) - : state_history(pl), + : state_history(*pl), cct(cct), spgid(spgid), dpp(dpp),