From dbc4f4f1993ad41d65996d1833276206fe58b684 Mon Sep 17 00:00:00 2001 From: Leonid Chernin Date: Tue, 9 Sep 2025 14:20:13 +0300 Subject: [PATCH] fix beacon-dif feature/version logic set beacon compatible version back to 1 add initialiser of BeaconSubsystem change descriptor in encode of legacy beaconsubsystem ignore invalid change descriptors Signed-off-by: Leonid Chernin --- src/messages/MNVMeofGwBeacon.h | 2 +- src/mon/NVMeofGwMap.cc | 5 +++-- src/mon/NVMeofGwMon.cc | 8 +++++--- src/mon/NVMeofGwSerialize.h | 8 ++++---- src/mon/NVMeofGwTypes.h | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/messages/MNVMeofGwBeacon.h b/src/messages/MNVMeofGwBeacon.h index 0a1a54603ef..f10eba19d16 100644 --- a/src/messages/MNVMeofGwBeacon.h +++ b/src/messages/MNVMeofGwBeacon.h @@ -26,7 +26,7 @@ class MNVMeofGwBeacon final : public PaxosServiceMessage { private: static constexpr int BEACON_VERSION_LEGACY = 1; // legacy beacon format (no diff support) static constexpr int BEACON_VERSION_ENHANCED = 2; // enhanced beacon format (with diff support) - static constexpr int COMPAT_VERSION = BEACON_VERSION_ENHANCED; // minimum version to decode enhanced format + static constexpr int COMPAT_VERSION = BEACON_VERSION_LEGACY; // minimum version to decode enhanced format protected: std::string gw_id; diff --git a/src/mon/NVMeofGwMap.cc b/src/mon/NVMeofGwMap.cc index 2ebf58d9399..ce0c5adb75b 100755 --- a/src/mon/NVMeofGwMap.cc +++ b/src/mon/NVMeofGwMap.cc @@ -1157,7 +1157,7 @@ bool NVMeofGwMap::put_gw_beacon_sequence_number(const NvmeGwId &gw_id, NvmeGwMonState& gw_map = created_gws[group_key][gw_id]; //gw_map.beacon_sequence_ooo = false; - if (HAVE_FEATURE(mon->get_quorum_con_features(), NVMEOF_BEACON_DIFF) && + if (HAVE_FEATURE(mon->get_quorum_con_features(), NVMEOF_BEACON_DIFF) || (gw_version > 0) ) { if (beacon_sequence == 40 && inject1 == 0) { //Inject sequence ooo inject1 = 1; @@ -1183,9 +1183,10 @@ bool NVMeofGwMap::set_gw_beacon_sequence_number(const NvmeGwId &gw_id, int gw_version, const NvmeGroupKey& group_key, uint64_t beacon_sequence) { NvmeGwMonState& gw_map = created_gws[group_key][gw_id]; - if (HAVE_FEATURE(mon->get_quorum_con_features(), NVMEOF_BEACON_DIFF) && + if (HAVE_FEATURE(mon->get_quorum_con_features(), NVMEOF_BEACON_DIFF) || (gw_version > 0)) { gw_map.beacon_sequence = beacon_sequence; + gw_map.beacon_sequence_ooo = false; dout(10) << gw_id << " set beacon_sequence " << beacon_sequence << dendl; } return true; diff --git a/src/mon/NVMeofGwMon.cc b/src/mon/NVMeofGwMon.cc index 2ef7669bd78..251b1b9a403 100644 --- a/src/mon/NVMeofGwMon.cc +++ b/src/mon/NVMeofGwMon.cc @@ -243,7 +243,7 @@ void NVMeofGwMon::encode_pending(MonitorDBStore::TransactionRef t) pending_map.encode(bl, features); dout(10) << " has NVMEOFHA: " << HAVE_FEATURE(features, NVMEOFHA) << " has NVMEOFHAMAP: " << HAVE_FEATURE(features, NVMEOFHAMAP) - << " has BEACON_DIFF: " << HAVE_FEATURE(features,NVMEOFHAMAP) << dendl;// BEACONDIFF + << " has BEACON_DIFF: " << HAVE_FEATURE(features, NVMEOF_BEACON_DIFF) << dendl; put_version(t, pending_map.epoch, bl); put_last_committed(t, pending_map.epoch); @@ -257,7 +257,7 @@ void NVMeofGwMon::update_from_paxos(bool *need_bootstrap) { version_t version = get_last_committed(); uint64_t features = mon.get_quorum_con_features(); - dout(10) << " has BEACON_DIFF: " << HAVE_FEATURE(features,NVMEOFHAMAP) + dout(10) << " has BEACON_DIFF: " << HAVE_FEATURE(features, NVMEOF_BEACON_DIFF) << dendl; if (version != map.epoch) { dout(10) << " NVMeGW loading version " << version @@ -681,6 +681,8 @@ void NVMeofGwMon::do_send_map_ack(MonOpRequestRef op, " sending ACK due to receiving beacon_sequence out of order" << dendl; ack_map.created_gws[group_key][gw_id].beacon_sequence = stored_sequence; ack_map.created_gws[group_key][gw_id].beacon_sequence_ooo = true; + } else { + ack_map.created_gws[group_key][gw_id].beacon_sequence_ooo = false; } if (gw_propose) { dout(10) << "GW in Created " << gw_id << " ack map " << ack_map << dendl; @@ -720,7 +722,7 @@ int NVMeofGwMon::apply_beacon(const NvmeGwId &gw_id, int gw_version, pending_map.created_gws[group_key][gw_id].subsystems; auto &state = pending_map.created_gws[group_key][gw_id]; - if (!HAVE_FEATURE(mon.get_quorum_con_features(), NVMEOF_BEACON_DIFF) || + if (!HAVE_FEATURE(mon.get_quorum_con_features(), NVMEOF_BEACON_DIFF) && gw_version == 0) { if (gw_subs != sub) { dout(10) << "BEACON_DIFF logic not applied." diff --git a/src/mon/NVMeofGwSerialize.h b/src/mon/NVMeofGwSerialize.h index 664bc3fa85d..e8f6803eb22 100755 --- a/src/mon/NVMeofGwSerialize.h +++ b/src/mon/NVMeofGwSerialize.h @@ -856,11 +856,11 @@ inline void encode(const BeaconSubsystem& sub, ceph::bufferlist &bl, uint64_t f if (HAVE_FEATURE(features, NVMEOF_BEACON_DIFF)) { version = BEACON_SUBSYS_VERSION_ENHANCED; // Use enhanced version if feature supported } - // For legacy encoding, skip deleted subsystems to maintain compatibility - if (version == BEACON_SUBSYS_VERSION_LEGACY && sub.change_descriptor == subsystem_change_t::SUBSYSTEM_DELETED) { - dout(20) << "encode BeaconSubsystem: skipping deleted subsystem " << sub.nqn << " in legacy mode" << dendl; - return; // Skip encoding this subsystem entirely + if (version == BEACON_SUBSYS_VERSION_LEGACY && sub.change_descriptor != subsystem_change_t::SUBSYSTEM_ADDED) { + dout(4) << "encode BeaconSubsystem: skipping subsystem " << sub.nqn + << " with change_descriptor " << (int)sub.change_descriptor << " in legacy mode" << dendl; + return; // Skip encoding this subsystem entirely } ENCODE_START(version, version, bl); diff --git a/src/mon/NVMeofGwTypes.h b/src/mon/NVMeofGwTypes.h index 7922a106ba0..6f6df237c6a 100755 --- a/src/mon/NVMeofGwTypes.h +++ b/src/mon/NVMeofGwTypes.h @@ -97,7 +97,7 @@ struct BeaconSubsystem { NvmeNqnId nqn; std::list listeners; std::list namespaces; - subsystem_change_t change_descriptor; + subsystem_change_t change_descriptor = subsystem_change_t::SUBSYSTEM_ADDED; // Define the equality operator bool operator==(const BeaconSubsystem& other) const { -- 2.39.5