From 762f3dacea9f029b6e33d480b25f73bc25f80923 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 4 Oct 2017 15:30:14 -0500 Subject: [PATCH] osd/PG: add explicit CANCEL MBackfillReserve type This lets us distinguish between REJECT and CANCEL for clarity. Signed-off-by: Sage Weil --- src/messages/MBackfillReserve.h | 20 ++++++++++++++++++-- src/osd/OSD.cc | 7 +++++++ src/osd/PG.cc | 8 ++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/messages/MBackfillReserve.h b/src/messages/MBackfillReserve.h index f70c2946b30..89d3c9ff33d 100644 --- a/src/messages/MBackfillReserve.h +++ b/src/messages/MBackfillReserve.h @@ -18,8 +18,8 @@ #include "msg/Message.h" class MBackfillReserve : public Message { - static const int HEAD_VERSION = 3; - static const int COMPAT_VERSION = 3; + static const int HEAD_VERSION = 4; + static const int COMPAT_VERSION = 4; public: spg_t pgid; epoch_t query_epoch; @@ -27,6 +27,7 @@ public: REQUEST = 0, GRANT = 1, REJECT = 2, + CANCEL = 3, }; uint32_t type; uint32_t priority; @@ -57,6 +58,9 @@ public: case REJECT: out << "REJECT "; break; + case CANCEL: + out << "CANCEL "; + break; } out << " pgid: " << pgid << ", query_epoch: " << query_epoch; if (type == REQUEST) out << ", prio: " << priority; @@ -73,6 +77,18 @@ public: } void encode_payload(uint64_t features) override { + if (!HAVE_FEATURE(features, SERVER_MIMIC)) { + header.version = 3; + header.compat_version = 3; + ::encode(pgid.pgid, payload); + ::encode(query_epoch, payload); + ::encode(type == CANCEL ? REJECT : type, payload); + ::encode(priority, payload); + ::encode(pgid.shard, payload); + return; + } + header.version = HEAD_VERSION; + header.compat_version = COMPAT_VERSION; ::encode(pgid.pgid, payload); ::encode(query_epoch, payload); ::encode(type, payload); diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index dd72fbb29f9..63cf3eaeace 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -8681,11 +8681,18 @@ void OSD::handle_pg_backfill_reserve(OpRequestRef op) } else if (m->type == MBackfillReserve::REJECT) { // NOTE: this is replica -> primary "i reject your request" // and also primary -> replica "cancel my previously-granted request" + // (for older peers) evt = PG::CephPeeringEvtRef( new PG::CephPeeringEvt( m->query_epoch, m->query_epoch, PG::RemoteReservationRejected())); + } else if (m->type == MBackfillReserve::CANCEL) { + evt = PG::CephPeeringEvtRef( + new PG::CephPeeringEvt( + m->query_epoch, + m->query_epoch, + PG::RemoteReservationCanceled())); } else { ceph_abort(); } diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 51937233363..8681187e96e 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -6199,7 +6199,7 @@ PG::RecoveryState::Backfilling::react(const DeferBackfill &c) if (con) { pg->osd->send_message_osd_cluster( new MBackfillReserve( - MBackfillReserve::REJECT, + MBackfillReserve::CANCEL, spg_t(pg->info.pgid.pgid, it->shard), pg->get_osdmap()->get_epoch()), con.get()); @@ -6228,7 +6228,7 @@ PG::RecoveryState::Backfilling::react(const RemoteReservationRejected &) if (con) { pg->osd->send_message_osd_cluster( new MBackfillReserve( - MBackfillReserve::REJECT, + MBackfillReserve::CANCEL, spg_t(pg->info.pgid.pgid, it->shard), pg->get_osdmap()->get_epoch()), con.get()); @@ -6308,7 +6308,7 @@ PG::RecoveryState::WaitRemoteBackfillReserved::react(const RemoteReservationReje PG *pg = context< RecoveryMachine >().pg; pg->osd->local_reserver.cancel_reservation(pg->info.pgid); - // Send REJECT to all previously acquired reservations + // Send CANCEL to all previously acquired reservations set::const_iterator it, begin, end, next; begin = context< Active >().remote_shards_to_reserve_backfill.begin(); end = context< Active >().remote_shards_to_reserve_backfill.end(); @@ -6321,7 +6321,7 @@ PG::RecoveryState::WaitRemoteBackfillReserved::react(const RemoteReservationReje if (con) { pg->osd->send_message_osd_cluster( new MBackfillReserve( - MBackfillReserve::REJECT, + MBackfillReserve::CANCEL, spg_t(pg->info.pgid.pgid, it->shard), pg->get_osdmap()->get_epoch()), con.get()); -- 2.39.5