#include "mon/MonCommand.h"
#include "mon/NVMeofGwMap.h"
#include "include/types.h"
+#include "mon/NVMeofGwBeaconConstants.h"
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_LEGACY; // minimum version to decode enhanced format
protected:
std::string gw_id;
public:
MNVMeofGwBeacon()
: PaxosServiceMessage{MSG_MNVMEOF_GW_BEACON, 0, BEACON_VERSION_ENHANCED,
- COMPAT_VERSION}, sequence(0)
+ BEACON_VERSION_LEGACY}, sequence(0)
{
set_priority(CEPH_MSG_PRIO_HIGH);
}
bool enable_diff = false) // default to legacy behavior for backward compatibility
: PaxosServiceMessage{MSG_MNVMEOF_GW_BEACON,
static_cast<version_t>(enable_diff ? 1 : 0), // user_version: 1=enhanced, 0=legacy
- enable_diff ? BEACON_VERSION_ENHANCED :
- BEACON_VERSION_LEGACY, COMPAT_VERSION},// Minimum compatible version
+ enable_diff ? BEACON_VERSION_ENHANCED :
+ BEACON_VERSION_LEGACY, BEACON_VERSION_LEGACY},// Minimum compatible version
gw_id(gw_id_), gw_pool(gw_pool_), gw_group(gw_group_), subsystems(subsystems_),
availability(availability_), last_osd_epoch(last_osd_epoch_),
last_gwmap_epoch(last_gwmap_epoch_), sequence(sequence_)
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2025 IBM, Inc.
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ */
+
+#ifndef CEPH_NVMEOFGWBEACONCONSTANTS_H
+#define CEPH_NVMEOFGWBEACONCONSTANTS_H
+
+// This header contains version constants used across multiple files
+// to avoid duplication and maintain consistency.
+
+// Beacon version constants
+#define BEACON_VERSION_LEGACY 1 // Legacy beacon format (no diff support)
+#define BEACON_VERSION_ENHANCED 2 // Enhanced beacon format (with diff support)
+
+#endif /* CEPH_NVMEOFGWBEACONCONSTANTS_H */
#ifndef MON_NVMEOFGWSERIALIZE_H_
#define MON_NVMEOFGWSERIALIZE_H_
+#include "mon/NVMeofGwBeaconConstants.h"
+
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_mon
#undef dout_prefix
#define dout_prefix *_dout << MODULE_PREFFIX << __PRETTY_FUNCTION__ << " "
#define MAX_SUPPORTED_ANA_GROUPS 16
-// Local version constants that match MNVMeofGwBeacon.h
-// We can't include that header here due to circular dependencies
-#define BEACON_SUBSYS_VERSION_LEGACY 1 // Legacy beacon format (no diff support)
-#define BEACON_SUBSYS_VERSION_ENHANCED 2 // Enhanced beacon format (with diff support)
-
inline std::ostream& operator<<(
std::ostream& os, const gw_exported_states_per_group_t value) {
switch (value) {
inline void encode(const NvmeGwClientState& state, ceph::bufferlist &bl, uint64_t features) {
uint8_t version = 1;
if (HAVE_FEATURE(features, NVMEOF_BEACON_DIFF)) {
- version = BEACON_SUBSYS_VERSION_ENHANCED;
+ version = BEACON_VERSION_ENHANCED;
}
ENCODE_START(version, version, bl);
encode(state.group_id, bl);
}
inline void encode(const BeaconNamespace& ns, ceph::bufferlist &bl) {
- ENCODE_START(BEACON_SUBSYS_VERSION_LEGACY, BEACON_SUBSYS_VERSION_LEGACY, bl);
+ ENCODE_START(BEACON_VERSION_LEGACY, BEACON_VERSION_LEGACY, bl);
encode(ns.anagrpid, bl);
encode(ns.nonce, bl);
ENCODE_FINISH(bl);
}
inline void encode(const BeaconListener& ls, ceph::bufferlist &bl) {
- ENCODE_START(BEACON_SUBSYS_VERSION_LEGACY, BEACON_SUBSYS_VERSION_LEGACY, bl);
+ ENCODE_START(BEACON_VERSION_LEGACY, BEACON_VERSION_LEGACY, bl);
encode(ls.address_family, bl);
encode(ls.address, bl);
encode(ls.svcid, bl);
}
inline void encode(const BeaconSubsystem& sub, ceph::bufferlist &bl, uint64_t features) {
- uint8_t version = BEACON_SUBSYS_VERSION_LEGACY; // Default to legacy version
+ uint8_t version = BEACON_VERSION_LEGACY; // Default to legacy version
if (HAVE_FEATURE(features, NVMEOF_BEACON_DIFF)) {
- version = BEACON_SUBSYS_VERSION_ENHANCED; // Use enhanced version if feature supported
+ version = BEACON_VERSION_ENHANCED; // Use enhanced version if feature supported
}
// For legacy encoding, skip deleted subsystems to maintain compatibility
- if (version == BEACON_SUBSYS_VERSION_LEGACY &&
+ if (version == BEACON_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
encode((uint32_t)sub.namespaces.size(), bl);
for (const auto& ns: sub.namespaces)
encode(ns, bl);
- if (version >= BEACON_SUBSYS_VERSION_ENHANCED) {
+ if (version >= BEACON_VERSION_ENHANCED) {
encode((uint32_t)sub.change_descriptor, bl);
dout(20) << "encode BeaconSubsystems change-descr: " << (uint32_t)sub.change_descriptor << dendl;
}
}
inline void decode(BeaconSubsystem& sub, ceph::buffer::list::const_iterator &bl) {
- DECODE_START(BEACON_SUBSYS_VERSION_ENHANCED, bl); // Always decode with enhanced version support
+ DECODE_START(BEACON_VERSION_ENHANCED, bl); // Always decode with enhanced version support
decode(sub.nqn, bl);
dout(20) << "decode BeaconSubsystems " << sub.nqn << dendl;
uint32_t s;
decode(ns, bl);
sub.namespaces.push_back(ns);
}
- if (struct_v >= BEACON_SUBSYS_VERSION_ENHANCED) {
+ if (struct_v >= BEACON_VERSION_ENHANCED) {
uint32_t change_desc;
decode(change_desc, bl);
sub.change_descriptor = static_cast<subsystem_change_t>(change_desc);
- dout(20) << "decode BeaconSubsystems version >= " << BEACON_SUBSYS_VERSION_ENHANCED << dendl;
+ dout(20) << "decode BeaconSubsystems version >= " << BEACON_VERSION_ENHANCED << dendl;
}
DECODE_FINISH(bl);
}