Skip to content

Commit d563856

Browse files
wip / featureful #1
This is from "wip" - Sage Weil <sage@inktank.com> Signed-off-by: Marcus Watts <mwatts@redhat.com>
1 parent 14cd471 commit d563856

58 files changed

Lines changed: 270 additions & 197 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/cls/lock/cls_lock.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ typedef struct lock_info_s {
5353
// as long as set of non expired lockers
5454
// is bigger than 0.
5555

56-
void encode(bufferlist &bl) const {
56+
void encode(bufferlist &bl, uint64_t features) const {
5757
ENCODE_START(1, 1, bl);
58-
::encode(lockers, bl);
58+
::encode(lockers, bl, features);
5959
uint8_t t = (uint8_t)lock_type;
6060
::encode(t, bl);
6161
::encode(tag, bl);
@@ -72,7 +72,7 @@ typedef struct lock_info_s {
7272
}
7373
lock_info_s() : lock_type(LOCK_NONE) {}
7474
} lock_info_t;
75-
WRITE_CLASS_ENCODER(lock_info_t)
75+
WRITE_CLASS_ENCODER_FEATURES(lock_info_t)
7676

7777

7878
static int read_lock(cls_method_context_t hctx, const string& name, lock_info_t *lock)

src/cls/lock/cls_lock_ops.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ struct cls_lock_get_info_reply
127127

128128
cls_lock_get_info_reply() : lock_type(LOCK_NONE) {}
129129

130-
void encode(bufferlist &bl) const {
130+
void encode(bufferlist &bl, uint64_t features) const {
131131
ENCODE_START(1, 1, bl);
132-
::encode(lockers, bl);
132+
::encode(lockers, bl, features);
133133
uint8_t t = (uint8_t)lock_type;
134134
::encode(t, bl);
135135
::encode(tag, bl);
@@ -147,7 +147,7 @@ struct cls_lock_get_info_reply
147147
void dump(Formatter *f) const;
148148
static void generate_test_instances(list<cls_lock_get_info_reply*>& o);
149149
};
150-
WRITE_CLASS_ENCODER(cls_lock_get_info_reply)
150+
WRITE_CLASS_ENCODER_FEATURES(cls_lock_get_info_reply)
151151

152152
struct cls_lock_list_locks_reply
153153
{

src/cls/lock/cls_lock_types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ namespace rados {
7878
locker_info_t(const utime_t& _e, const entity_addr_t& _a,
7979
const string& _d) : expiration(_e), addr(_a), description(_d) {}
8080

81-
void encode(bufferlist &bl) const {
81+
void encode(bufferlist &bl, uint64_t features) const {
8282
ENCODE_START(1, 1, bl);
8383
::encode(expiration, bl);
84-
::encode(addr, bl);
84+
::encode(addr, bl, features);
8585
::encode(description, bl);
8686
ENCODE_FINISH(bl);
8787
}
@@ -95,7 +95,7 @@ namespace rados {
9595
void dump(Formatter *f) const;
9696
static void generate_test_instances(list<locker_info_t *>& o);
9797
};
98-
WRITE_CLASS_ENCODER(rados::cls::lock::locker_info_t)
98+
WRITE_CLASS_ENCODER_FEATURES(rados::cls::lock::locker_info_t)
9999
}
100100
}
101101
}

src/common/LogEntry.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
// ----
1414
// LogEntryKey
1515

16-
void LogEntryKey::encode(bufferlist& bl) const
16+
void LogEntryKey::encode(bufferlist& bl, uint64_t features) const
1717
{
18-
::encode(who, bl);
18+
::encode(who, bl, features);
1919
::encode(stamp, bl);
2020
::encode(seq, bl);
2121
}
@@ -184,11 +184,11 @@ void LogEntry::log_to_syslog(string level, string facility)
184184
}
185185
}
186186

187-
void LogEntry::encode(bufferlist& bl) const
187+
void LogEntry::encode(bufferlist& bl, uint64_t features) const
188188
{
189189
ENCODE_START(3, 2, bl);
190190
__u16 t = prio;
191-
::encode(who, bl);
191+
::encode(who, bl, features);
192192
::encode(stamp, bl);
193193
::encode(seq, bl);
194194
::encode(t, bl);
@@ -236,11 +236,11 @@ void LogEntry::generate_test_instances(list<LogEntry*>& o)
236236

237237
// -----
238238

239-
void LogSummary::encode(bufferlist& bl) const
239+
void LogSummary::encode(bufferlist& bl, uint64_t features) const
240240
{
241241
ENCODE_START(2, 2, bl);
242242
::encode(version, bl);
243-
::encode(tail, bl);
243+
::encode(tail, bl, features);
244244
ENCODE_FINISH(bl);
245245
}
246246

src/common/LogEntry.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ struct LogEntryKey {
6262
LogEntryKey() : seq(0) {}
6363
LogEntryKey(const entity_inst_t& w, utime_t t, uint64_t s) : who(w), stamp(t), seq(s) {}
6464

65-
void encode(bufferlist& bl) const;
65+
void encode(bufferlist& bl, uint64_t features) const;
6666
void decode(bufferlist::iterator& bl);
6767
void dump(Formatter *f) const;
6868
static void generate_test_instances(list<LogEntryKey*>& o);
6969
};
70-
WRITE_CLASS_ENCODER(LogEntryKey)
70+
WRITE_CLASS_ENCODER_FEATURES(LogEntryKey)
7171

7272
static inline bool operator==(const LogEntryKey& l, const LogEntryKey& r) {
7373
return l.who == r.who && l.stamp == r.stamp && l.seq == r.seq;
@@ -87,12 +87,12 @@ struct LogEntry {
8787

8888
void log_to_syslog(string level, string facility);
8989

90-
void encode(bufferlist& bl) const;
90+
void encode(bufferlist& bl, uint64_t features) const;
9191
void decode(bufferlist::iterator& bl);
9292
void dump(Formatter *f) const;
9393
static void generate_test_instances(list<LogEntry*>& o);
9494
};
95-
WRITE_CLASS_ENCODER(LogEntry)
95+
WRITE_CLASS_ENCODER_FEATURES(LogEntry)
9696

9797
struct LogSummary {
9898
version_t version;
@@ -114,12 +114,12 @@ struct LogSummary {
114114
return false;
115115
}
116116

117-
void encode(bufferlist& bl) const;
117+
void encode(bufferlist& bl, uint64_t features) const;
118118
void decode(bufferlist::iterator& bl);
119119
void dump(Formatter *f) const;
120120
static void generate_test_instances(list<LogSummary*>& o);
121121
};
122-
WRITE_CLASS_ENCODER(LogSummary)
122+
WRITE_CLASS_ENCODER_FEATURES(LogSummary)
123123

124124
inline ostream& operator<<(ostream& out, clog_type t)
125125
{

src/include/ceph_features.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
#define CEPH_FEATURE_OSD_PROXY_FEATURES (1ULL<<49) /* overlap w/ above */
6666
#define CEPH_FEATURE_MON_METADATA (1ULL<<50)
6767

68+
#define CEPH_FEATURE_MSG_ADDR2 (1ULL<<51)
69+
6870
#define CEPH_FEATURE_RESERVED2 (1ULL<<61) /* slow down, we are almost out... */
6971
#define CEPH_FEATURE_RESERVED (1ULL<<62) /* DO NOT USE THIS ... last bit! */
7072
#define CEPH_FEATURE_RESERVED_BROKEN (1ULL<<63) /* DO NOT USE THIS; see below */
@@ -150,6 +152,7 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) {
150152
CEPH_FEATURE_CRUSH_V4 | \
151153
CEPH_FEATURE_OSD_MIN_SIZE_RECOVERY | \
152154
CEPH_FEATURE_MON_METADATA | \
155+
CEPH_FEATURE_MSG_ADDR2 | \
153156
0ULL)
154157

155158
#define CEPH_FEATURES_SUPPORTED_DEFAULT CEPH_FEATURES_ALL

src/mds/LogEvent.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,16 @@ class LogEvent {
8484
void set_stamp(utime_t t) { stamp = t; }
8585

8686
// encoding
87-
virtual void encode(bufferlist& bl) const = 0;
87+
virtual void encode(bufferlist& bl, uint64_t features) const = 0;
8888
virtual void decode(bufferlist::iterator &bl) = 0;
8989
static LogEvent *decode(bufferlist &bl);
9090
virtual void dump(Formatter *f) const = 0;
9191

92-
void encode_with_header(bufferlist& bl) {
92+
void encode_with_header(bufferlist& bl, uint64_t features) {
9393
::encode(EVENT_NEW_ENCODING, bl);
9494
ENCODE_START(1, 1, bl)
9595
::encode(_type, bl);
96-
encode(bl);
96+
encode(bl, features);
9797
ENCODE_FINISH(bl);
9898
}
9999

src/mds/MDLog.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void MDLog::_submit_thread()
366366
LogSegment *ls = le->_segment;
367367
// encode it, with event type
368368
bufferlist bl;
369-
le->encode_with_header(bl);
369+
le->encode_with_header(bl, mds->mdsmap->get_up_features());
370370

371371
uint64_t write_pos = journaler->get_write_pos();
372372

@@ -1105,7 +1105,7 @@ void MDLog::_reformat_journal(JournalPointer const &jp_in, Journaler *old_journa
11051105

11061106
if (modified) {
11071107
bl.clear();
1108-
le->encode_with_header(bl);
1108+
le->encode_with_header(bl, mds->mdsmap->get_up_features());
11091109
}
11101110

11111111
delete le;

src/mds/MDSMap.cc

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,18 +395,19 @@ void MDSMap::get_health(list<pair<health_status_t,string> >& summary,
395395

396396
void MDSMap::mds_info_t::encode_versioned(bufferlist& bl, uint64_t features) const
397397
{
398-
ENCODE_START(4, 4, bl);
398+
ENCODE_START(5, 4, bl);
399399
::encode(global_id, bl);
400400
::encode(name, bl);
401401
::encode(rank, bl);
402402
::encode(inc, bl);
403403
::encode((int32_t)state, bl);
404404
::encode(state_seq, bl);
405-
::encode(addr, bl);
405+
::encode(addr, bl, features);
406406
::encode(laggy_since, bl);
407407
::encode(standby_for_rank, bl);
408408
::encode(standby_for_name, bl);
409409
::encode(export_targets, bl);
410+
::encode(mds_features, bl);
410411
ENCODE_FINISH(bl);
411412
}
412413

@@ -420,7 +421,7 @@ void MDSMap::mds_info_t::encode_unversioned(bufferlist& bl) const
420421
::encode(inc, bl);
421422
::encode((int32_t)state, bl);
422423
::encode(state_seq, bl);
423-
::encode(addr, bl);
424+
::encode(addr, bl, 0);
424425
::encode(laggy_since, bl);
425426
::encode(standby_for_rank, bl);
426427
::encode(standby_for_name, bl);
@@ -429,7 +430,7 @@ void MDSMap::mds_info_t::encode_unversioned(bufferlist& bl) const
429430

430431
void MDSMap::mds_info_t::decode(bufferlist::iterator& bl)
431432
{
432-
DECODE_START_LEGACY_COMPAT_LEN(4, 4, 4, bl);
433+
DECODE_START_LEGACY_COMPAT_LEN(5, 4, 4, bl);
433434
::decode(global_id, bl);
434435
::decode(name, bl);
435436
::decode(rank, bl);
@@ -442,6 +443,10 @@ void MDSMap::mds_info_t::decode(bufferlist::iterator& bl)
442443
::decode(standby_for_name, bl);
443444
if (struct_v >= 2)
444445
::decode(export_targets, bl);
446+
if (struct_v >= 5)
447+
::decode(mds_features, bl);
448+
else
449+
mds_features = 0;
445450
DECODE_FINISH(bl);
446451
}
447452

@@ -634,4 +639,29 @@ void MDSMap::decode(bufferlist::iterator& p)
634639
::decode(damaged, p);
635640
}
636641
DECODE_FINISH(p);
642+
643+
decode_post();
644+
}
645+
646+
647+
void MDSMap::calc_up_in_features()
648+
{
649+
in_features = 0;
650+
bool first = true;
651+
for (set<int32_t>::iterator p = in.begin(); p != in.end(); ++p) {
652+
if (first)
653+
in_features = mds_info[up[*p]].mds_features;
654+
else
655+
in_features &= mds_info[up[*p]].mds_features;
656+
}
657+
658+
up_features = 0;
659+
for (map<uint64_t, mds_info_t>::iterator p = mds_info.begin();
660+
p != mds_info.end();
661+
++p) {
662+
if (first)
663+
up_features = p->second.mds_features;
664+
else
665+
up_features &= p->second.mds_features;
666+
}
637667
}

src/mds/MDSMap.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,22 @@ class MDSMap {
140140
mds_rank_t standby_for_rank;
141141
std::string standby_for_name;
142142
std::set<mds_rank_t> export_targets;
143+
uint64_t mds_features;
143144

144145
mds_info_t() : global_id(MDS_GID_NONE), rank(MDS_RANK_NONE), inc(0), state(STATE_STANDBY), state_seq(0),
145-
standby_for_rank(MDS_NO_STANDBY_PREF) { }
146+
standby_for_rank(MDS_NO_STANDBY_PREF),
147+
mds_features(0) { }
146148

147149
bool laggy() const { return !(laggy_since == utime_t()); }
148150
void clear_laggy() { laggy_since = utime_t(); }
149151

150152
entity_inst_t get_inst() const { return entity_inst_t(entity_name_t::MDS(rank), addr); }
151153

152154
void encode(bufferlist& bl, uint64_t features) const {
153-
if ((features & CEPH_FEATURE_MDSENC) == 0 ) encode_unversioned(bl);
154-
else encode_versioned(bl, features);
155+
if ((features & CEPH_FEATURE_MDSENC) == 0)
156+
encode_unversioned(bl);
157+
else
158+
encode_versioned(bl, features);
155159
}
156160
void decode(bufferlist::iterator& p);
157161
void dump(Formatter *f) const;
@@ -208,6 +212,16 @@ class MDSMap {
208212

209213
bool inline_data_enabled;
210214

215+
uint64_t in_features; // intersection of features for in set
216+
uint64_t up_features; // intersection of features for up set
217+
218+
void calc_up_in_features();
219+
220+
public:
221+
uint64_t get_up_features() const {
222+
return up_features;
223+
}
224+
211225
public:
212226
CompatSet compat;
213227

@@ -621,7 +635,9 @@ class MDSMap {
621635
bufferlist::iterator p = bl.begin();
622636
decode(p);
623637
}
624-
638+
void decode_post() {
639+
calc_up_in_features();
640+
}
625641

626642
void print(ostream& out);
627643
void print_summary(Formatter *f, ostream *out);

0 commit comments

Comments
 (0)