From 70a037f6f4464871a2380420709522b3921da157 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 5 Aug 2019 22:22:15 -0500 Subject: [PATCH] osd/PeeringState: piggyback pg_lease on MOSDPGLog We only do this for primary -> replica, so we only need to proc_lease() from the replica states. Signed-off-by: Sage Weil --- src/messages/MOSDPGLog.h | 10 +++++++++- src/osd/PGPeeringEvent.cc | 10 ++++++++-- src/osd/PGPeeringEvent.h | 4 +--- src/osd/PeeringState.cc | 11 +++++++++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/messages/MOSDPGLog.h b/src/messages/MOSDPGLog.h index de3a50e0c09..0fdc65862a7 100644 --- a/src/messages/MOSDPGLog.h +++ b/src/messages/MOSDPGLog.h @@ -21,7 +21,7 @@ class MOSDPGLog : public MOSDPeeringOp { private: - static constexpr int HEAD_VERSION = 5; + static constexpr int HEAD_VERSION = 6; static constexpr int COMPAT_VERSION = 5; epoch_t epoch = 0; @@ -38,6 +38,7 @@ public: pg_log_t log; pg_missing_t missing; PastIntervals past_intervals; + std::optional lease; epoch_t get_epoch() const { return epoch; } spg_t get_pgid() const { return spg_t(info.pgid.pgid, to); } @@ -89,6 +90,9 @@ public: // swapped out by OSD code. out << "log " << log << " pi " << past_intervals; + if (lease) { + out << " " << *lease; + } } void encode_payload(uint64_t features) override { @@ -106,6 +110,7 @@ public: encode(past_intervals, payload); encode(to, payload); encode(from, payload); + encode(lease, payload); } void decode_payload() override { using ceph::decode; @@ -118,6 +123,9 @@ public: decode(past_intervals, p); decode(to, p); decode(from, p); + if (header.version >= 6) { + decode(lease, p); + } } private: template diff --git a/src/osd/PGPeeringEvent.cc b/src/osd/PGPeeringEvent.cc index 79c21b826b9..2d28c6f84ab 100644 --- a/src/osd/PGPeeringEvent.cc +++ b/src/osd/PGPeeringEvent.cc @@ -7,5 +7,11 @@ MEMPOOL_DEFINE_OBJECT_FACTORY(PGPeeringEvent, pg_peering_evt, osd); -MLogRec::MLogRec(pg_shard_t from, MOSDPGLog *msg) : - from(from), msg(msg) {} +MLogRec::MLogRec(pg_shard_t from, MOSDPGLog *msg) + : from(from), msg(msg) {} + +void MLogRec::print(std::ostream *out) const +{ + *out << "MLogRec from " << from << " "; + msg->inner_print(*out); +} diff --git a/src/osd/PGPeeringEvent.h b/src/osd/PGPeeringEvent.h index efe191d35cb..2828880f656 100644 --- a/src/osd/PGPeeringEvent.h +++ b/src/osd/PGPeeringEvent.h @@ -95,9 +95,7 @@ struct MLogRec : boost::statechart::event< MLogRec > { pg_shard_t from; boost::intrusive_ptr msg; MLogRec(pg_shard_t from, MOSDPGLog *msg); - void print(std::ostream *out) const { - *out << "MLogRec from " << from; - } + void print(std::ostream *out) const; }; struct MNotifyRec : boost::statechart::event< MNotifyRec > { diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index a3293e83015..105341698a9 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -2498,8 +2498,9 @@ void PeeringState::activate( } if (m) { - dout(10) << "activate peer osd." << peer << " sending " << m->log << dendl; - //m->log.print(cout); + dout(10) << "activate peer osd." << peer << " sending " << m->log + << dendl; + m->lease = get_lease(); pl->send_cluster_message(peer.osd, m, get_osdmap_epoch()); } @@ -5959,6 +5960,9 @@ boost::statechart::result PeeringState::ReplicaActive::react(const MLogRec& loge ObjectStore::Transaction &t = context().get_cur_transaction(); ps->merge_log(t, logevt.msg->info, logevt.msg->log, logevt.from); ceph_assert(ps->pg_log.get_head() == ps->info.last_update); + if (logevt.msg->lease) { + ps->proc_lease(*logevt.msg->lease); + } return discard_event(); } @@ -6060,6 +6064,9 @@ boost::statechart::result PeeringState::Stray::react(const MLogRec& logevt) } else { ps->merge_log(t, msg->info, msg->log, logevt.from); } + if (logevt.msg->lease) { + ps->proc_lease(*logevt.msg->lease); + } ceph_assert(ps->pg_log.get_head() == ps->info.last_update); -- 2.39.5