From 0aaf7334a9823916dfad8766f1bb4239a8d399ca Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 20 Jun 2012 20:41:17 -0700 Subject: [PATCH] mon: conditionally encode auth incremental with quorum feature bits If the quorum does not yet all have the MONENC feature, stick to the old encoding. It might be more polite to require a super-quorum before switching over, and take note so that thereafter we can stick to the new encoding, but that has more moving parts and I'm not sure it's worth the complexity. Signed-off-by: Sage Weil --- src/mon/AuthMonitor.cc | 2 +- src/mon/AuthMonitor.h | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index d9b698aefd5e3..c5721b96e4ebd 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -223,7 +223,7 @@ void AuthMonitor::encode_pending(bufferlist &bl) for (vector::iterator p = pending_auth.begin(); p != pending_auth.end(); p++) - p->encode(bl); + p->encode(bl, mon->get_quorum_features()); } bool AuthMonitor::preprocess_query(PaxosServiceMessage *m) diff --git a/src/mon/AuthMonitor.h b/src/mon/AuthMonitor.h index 2936b248e3753..92e7937322310 100644 --- a/src/mon/AuthMonitor.h +++ b/src/mon/AuthMonitor.h @@ -19,6 +19,7 @@ #include using namespace std; +#include "include/ceph_features.h" #include "include/types.h" #include "msg/Messenger.h" #include "PaxosService.h" @@ -47,7 +48,20 @@ public: Incremental() : inc_type(GLOBAL_ID), max_global_id(0), auth_type(0) {} - void encode(bufferlist& bl) const { + void encode(bufferlist& bl, uint64_t features=-1) const { + if ((features & CEPH_FEATURE_MONENC) == 0) { + __u8 v = 1; + ::encode(v, bl); + __u32 _type = (__u32)inc_type; + ::encode(_type, bl); + if (_type == GLOBAL_ID) { + ::encode(max_global_id, bl); + } else { + ::encode(auth_type, bl); + ::encode(auth_data, bl); + } + return; + } ENCODE_START(2, 2, bl); __u32 _type = (__u32)inc_type; ::encode(_type, bl); @@ -138,6 +152,6 @@ private: }; -WRITE_CLASS_ENCODER(AuthMonitor::Incremental); +WRITE_CLASS_ENCODER_FEATURES(AuthMonitor::Incremental); #endif -- 2.39.5