From 7508fffece1f1c169ba174d11b99c2610d5437e9 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Thu, 25 Apr 2019 11:40:52 -0700 Subject: [PATCH] PGStateUtils: improvements for PGStateHistory Signed-off-by: Samuel Just --- src/osd/PG.h | 2 +- src/osd/PGStateUtils.cc | 4 ++-- src/osd/PGStateUtils.h | 4 ++-- src/osd/PeeringState.cc | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/osd/PG.h b/src/osd/PG.h index d9bea3b5fc3..95fbae2b58d 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 035b0b8f9f0..5ffc1f0f16b 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 3c61d553f34..732425cdc76 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 013ed49b3a7..79a07ab8b4a 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), -- 2.39.5