From cb1a5190cd733449633f2f5d2157627cccd23382 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 27 Feb 2017 20:41:48 -0600 Subject: [PATCH] osd: set min_epoch for push/pull/reply Signed-off-by: Sage Weil --- src/messages/MOSDPGPull.h | 15 ++++++++++++--- src/messages/MOSDPGPush.h | 15 ++++++++++++--- src/messages/MOSDPGPushReply.h | 15 ++++++++++++--- src/osd/ECBackend.cc | 2 ++ src/osd/ReplicatedBackend.cc | 4 ++++ 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/messages/MOSDPGPull.h b/src/messages/MOSDPGPull.h index 442836e3da2..281b26f20db 100644 --- a/src/messages/MOSDPGPull.h +++ b/src/messages/MOSDPGPull.h @@ -18,7 +18,7 @@ #include "MOSDFastDispatchOp.h" class MOSDPGPull : public MOSDFastDispatchOp { - static const int HEAD_VERSION = 2; + static const int HEAD_VERSION = 3; static const int COMPAT_VERSION = 2; vector pulls; @@ -26,12 +26,15 @@ class MOSDPGPull : public MOSDFastDispatchOp { public: pg_shard_t from; spg_t pgid; - epoch_t map_epoch; + epoch_t map_epoch, min_epoch; uint64_t cost; epoch_t get_map_epoch() const override { return map_epoch; } + epoch_t get_min_epoch() const override { + return min_epoch; + } spg_t get_spg() const override { return pgid; } @@ -69,6 +72,11 @@ public: ::decode(cost, p); ::decode(pgid.shard, p); ::decode(from, p); + if (header.version >= 3) { + ::decode(min_epoch, p); + } else { + min_epoch = map_epoch; + } } void encode_payload(uint64_t features) override { @@ -78,13 +86,14 @@ public: ::encode(cost, payload); ::encode(pgid.shard, payload); ::encode(from, payload); + ::encode(min_epoch, payload); } const char *get_type_name() const override { return "MOSDPGPull"; } void print(ostream& out) const override { out << "MOSDPGPull(" << pgid - << " e" << map_epoch + << " e" << map_epoch << "/" << min_epoch << " cost " << cost << ")"; } diff --git a/src/messages/MOSDPGPush.h b/src/messages/MOSDPGPush.h index 50abe8475c2..4f45048412c 100644 --- a/src/messages/MOSDPGPush.h +++ b/src/messages/MOSDPGPush.h @@ -18,13 +18,13 @@ #include "MOSDFastDispatchOp.h" class MOSDPGPush : public MOSDFastDispatchOp { - static const int HEAD_VERSION = 2; + static const int HEAD_VERSION = 3; static const int COMPAT_VERSION = 2; public: pg_shard_t from; spg_t pgid; - epoch_t map_epoch; + epoch_t map_epoch, min_epoch; vector pushes; private: @@ -47,6 +47,9 @@ public: epoch_t get_map_epoch() const override { return map_epoch; } + epoch_t get_min_epoch() const override { + return min_epoch; + } spg_t get_spg() const override { return pgid; } @@ -68,6 +71,11 @@ public: ::decode(cost, p); ::decode(pgid.shard, p); ::decode(from, p); + if (header.version >= 3) { + ::decode(min_epoch, p); + } else { + min_epoch = map_epoch; + } } void encode_payload(uint64_t features) override { @@ -77,13 +85,14 @@ public: ::encode(cost, payload); ::encode(pgid.shard, payload); ::encode(from, payload); + ::encode(min_epoch, payload); } const char *get_type_name() const override { return "MOSDPGPush"; } void print(ostream& out) const override { out << "MOSDPGPush(" << pgid - << " " << map_epoch + << " " << map_epoch << "/" << min_epoch << " " << pushes; out << ")"; } diff --git a/src/messages/MOSDPGPushReply.h b/src/messages/MOSDPGPushReply.h index 3ac5467a2fe..c60007c8187 100644 --- a/src/messages/MOSDPGPushReply.h +++ b/src/messages/MOSDPGPushReply.h @@ -18,19 +18,22 @@ #include "MOSDFastDispatchOp.h" class MOSDPGPushReply : public MOSDFastDispatchOp { - static const int HEAD_VERSION = 2; + static const int HEAD_VERSION = 3; static const int COMPAT_VERSION = 2; public: pg_shard_t from; spg_t pgid; - epoch_t map_epoch; + epoch_t map_epoch, min_epoch; vector replies; uint64_t cost; epoch_t get_map_epoch() const override { return map_epoch; } + epoch_t get_min_epoch() const override { + return min_epoch; + } spg_t get_spg() const override { return pgid; } @@ -61,6 +64,11 @@ public: ::decode(cost, p); ::decode(pgid.shard, p); ::decode(from, p); + if (header.version >= 3) { + ::decode(min_epoch, p); + } else { + min_epoch = map_epoch; + } } void encode_payload(uint64_t features) override { @@ -70,11 +78,12 @@ public: ::encode(cost, payload); ::encode(pgid.shard, payload); ::encode(from, payload); + ::encode(min_epoch, payload); } void print(ostream& out) const override { out << "MOSDPGPushReply(" << pgid - << " " << map_epoch + << " " << map_epoch << "/" << min_epoch << " " << replies; out << ")"; } diff --git a/src/osd/ECBackend.cc b/src/osd/ECBackend.cc index 14f7a0bda8e..84e0838f863 100644 --- a/src/osd/ECBackend.cc +++ b/src/osd/ECBackend.cc @@ -480,6 +480,7 @@ void ECBackend::dispatch_recovery_messages(RecoveryMessages &m, int priority) MOSDPGPush *msg = new MOSDPGPush(); msg->set_priority(priority); msg->map_epoch = get_parent()->get_epoch(); + msg->min_epoch = get_parent()->get_last_peering_reset_epoch(); msg->from = get_parent()->whoami_shard(); msg->pgid = spg_t(get_parent()->get_info().pgid.pgid, i->first.shard); msg->pushes.swap(i->second); @@ -496,6 +497,7 @@ void ECBackend::dispatch_recovery_messages(RecoveryMessages &m, int priority) MOSDPGPushReply *msg = new MOSDPGPushReply(); msg->set_priority(priority); msg->map_epoch = get_parent()->get_epoch(); + msg->min_epoch = get_parent()->get_last_peering_reset_epoch(); msg->from = get_parent()->whoami_shard(); msg->pgid = spg_t(get_parent()->get_info().pgid.pgid, i->first.shard); msg->replies.swap(i->second); diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 9363115ef44..9be7a255c00 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -824,6 +824,7 @@ void ReplicatedBackend::_do_push(OpRequestRef op) reply->set_priority(m->get_priority()); reply->pgid = get_info().pgid; reply->map_epoch = m->map_epoch; + reply->min_epoch = m->min_epoch; reply->replies.swap(replies); reply->compute_cost(cct); @@ -902,6 +903,7 @@ void ReplicatedBackend::_do_pull_response(OpRequestRef op) reply->set_priority(m->get_priority()); reply->pgid = get_info().pgid; reply->map_epoch = m->map_epoch; + reply->min_epoch = m->min_epoch; reply->set_pulls(&replies); reply->compute_cost(cct); @@ -1847,6 +1849,7 @@ void ReplicatedBackend::send_pushes(int prio, map > & msg->from = get_parent()->whoami_shard(); msg->pgid = get_parent()->primary_spg_t(); msg->map_epoch = get_osdmap()->get_epoch(); + msg->min_epoch = get_parent()->get_last_peering_reset_epoch(); msg->set_priority(prio); for (; (j != i->second.end() && @@ -1882,6 +1885,7 @@ void ReplicatedBackend::send_pulls(int prio, map > &p msg->set_priority(prio); msg->pgid = get_parent()->primary_spg_t(); msg->map_epoch = get_osdmap()->get_epoch(); + msg->min_epoch = get_parent()->get_last_peering_reset_epoch(); msg->set_pulls(&i->second); msg->compute_cost(cct); get_parent()->send_message_osd_cluster(msg, con);