Skip to content

Commit

Permalink
mds/MDSMap: add features to MDSMap's mds_info_t
Browse files Browse the repository at this point in the history
Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Mar 1, 2016
1 parent 9822081 commit 4ad8f72
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/mds/MDSMap.cc
Expand Up @@ -85,6 +85,7 @@ void MDSMap::mds_info_t::dump(Formatter *f) const
p != export_targets.end(); ++p) {
f->dump_int("mds", *p);
}
f->dump_unsigned("features", mds_features);
f->close_section();
}

Expand Down Expand Up @@ -398,7 +399,7 @@ void MDSMap::get_health(list<pair<health_status_t,string> >& summary,

void MDSMap::mds_info_t::encode_versioned(bufferlist& bl, uint64_t features) const
{
ENCODE_START(4, 4, bl);
ENCODE_START(5, 4, bl);
::encode(global_id, bl);
::encode(name, bl);
::encode(rank, bl);
Expand All @@ -410,6 +411,7 @@ void MDSMap::mds_info_t::encode_versioned(bufferlist& bl, uint64_t features) con
::encode(standby_for_rank, bl);
::encode(standby_for_name, bl);
::encode(export_targets, bl);
::encode(mds_features, bl);
ENCODE_FINISH(bl);
}

Expand All @@ -432,7 +434,7 @@ void MDSMap::mds_info_t::encode_unversioned(bufferlist& bl) const

void MDSMap::mds_info_t::decode(bufferlist::iterator& bl)
{
DECODE_START_LEGACY_COMPAT_LEN(4, 4, 4, bl);
DECODE_START_LEGACY_COMPAT_LEN(5, 4, 4, bl);
::decode(global_id, bl);
::decode(name, bl);
::decode(rank, bl);
Expand All @@ -445,6 +447,8 @@ void MDSMap::mds_info_t::decode(bufferlist::iterator& bl)
::decode(standby_for_name, bl);
if (struct_v >= 2)
::decode(export_targets, bl);
if (struct_v >= 5)
::decode(mds_features, bl);
DECODE_FINISH(bl);
}

Expand Down
14 changes: 14 additions & 0 deletions src/mds/MDSMap.h
Expand Up @@ -140,6 +140,7 @@ class MDSMap {
mds_rank_t standby_for_rank;
std::string standby_for_name;
std::set<mds_rank_t> export_targets;
uint64_t mds_features;

mds_info_t() : global_id(MDS_GID_NONE), rank(MDS_RANK_NONE), inc(0), state(STATE_STANDBY), state_seq(0),
standby_for_rank(MDS_NO_STANDBY_PREF) { }
Expand Down Expand Up @@ -350,6 +351,19 @@ class MDSMap {
s = failed;
}

// features
uint64_t get_up_features() {
uint64_t f = 0;
for (std::map<mds_rank_t, mds_gid_t>::const_iterator p = up.begin();
p != up.end();
++p) {
std::map<mds_gid_t, mds_info_t>::const_iterator q = mds_info.find(p->second);
assert(q != mds_info.end());
f |= q->second.mds_features;
}
return f;
}

/**
* Get MDS ranks which are in but not up.
*/
Expand Down

0 comments on commit 4ad8f72

Please sign in to comment.