diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index e93040c33c..4680488bdb 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -1090,22 +1090,26 @@ uint64_t OSDMap::get_features(int entity_type, uint64_t *pmask) const return features; } -uint64_t OSDMap::get_up_osd_features() const +void OSDMap::_calc_up_osd_features() { bool first = true; - uint64_t features = 0; + cached_up_osd_features = 0; for (int osd = 0; osd < max_osd; ++osd) { if (!is_up(osd)) continue; const osd_xinfo_t &xi = get_xinfo(osd); if (first) { - features = xi.features; + cached_up_osd_features = xi.features; first = false; } else { - features &= xi.features; + cached_up_osd_features &= xi.features; } } - return features; +} + +uint64_t OSDMap::get_up_osd_features() const +{ + return cached_up_osd_features; } void OSDMap::dedup(const OSDMap *o, OSDMap *n) @@ -1258,6 +1262,7 @@ int OSDMap::apply_incremental(const Incremental &inc) return -EINVAL; assert(inc.epoch == epoch+1); + epoch++; modified = inc.modified; @@ -1439,6 +1444,7 @@ int OSDMap::apply_incremental(const Incremental &inc) } calc_num_osds(); + _calc_up_osd_features(); return 0; } @@ -2196,6 +2202,7 @@ void OSDMap::post_decode() } calc_num_osds(); + _calc_up_osd_features(); } void OSDMap::dump_erasure_code_profiles(const map > &profiles, diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index a38533db8b..ec048493e2 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -245,9 +245,13 @@ class OSDMap { string cluster_snapshot; bool new_blacklist_entries; + mutable uint64_t cached_up_osd_features; + mutable bool crc_defined; mutable uint32_t crc; + void _calc_up_osd_features(); + public: bool have_crc() const { return crc_defined; } uint32_t get_crc() const { return crc; } @@ -269,6 +273,7 @@ class OSDMap { osd_uuid(new vector), cluster_snapshot_epoch(0), new_blacklist_entries(false), + cached_up_osd_features(0), crc_defined(false), crc(0), crush(new CrushWrapper) { memset(&fsid, 0, sizeof(fsid));