From dc7a219468b5a9313b5a1d660c1b61e1e35b718d Mon Sep 17 00:00:00 2001 From: Xiaoxi CHEN Date: Mon, 23 Apr 2018 12:58:11 -0500 Subject: [PATCH] messages/MOSDMap: significant feature bits. 1. MOSDMap go with features indicating the features this map encoded for. 2. Only reencode if significant bits mismatch between target features and my features. also update mon/OSDMonitor and osd/OSDService to adopt this change. Signed-off-by: Xiaoxi CHEN --- src/messages/MOSDMap.h | 26 +++++++++++++------------- src/mon/OSDMonitor.cc | 8 ++++---- src/osd/OSD.cc | 6 ++++-- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/messages/MOSDMap.h b/src/messages/MOSDMap.h index beaef358c8166..27aae15570d53 100644 --- a/src/messages/MOSDMap.h +++ b/src/messages/MOSDMap.h @@ -27,6 +27,7 @@ class MOSDMap : public Message { public: uuid_d fsid; + uint64_t encode_features = 0; map maps; map incremental_maps; epoch_t oldest_map =0, newest_map = 0; @@ -63,13 +64,12 @@ class MOSDMap : public Message { MOSDMap() : Message(CEPH_MSG_OSD_MAP, HEAD_VERSION, COMPAT_VERSION) { } - MOSDMap(const uuid_d &f) + MOSDMap(const uuid_d &f, const uint64_t features) : Message(CEPH_MSG_OSD_MAP, HEAD_VERSION, COMPAT_VERSION), - fsid(f), + fsid(f), encode_features(features), oldest_map(0), newest_map(0) { } private: ~MOSDMap() override {} - public: // marshalling void decode_payload() override { @@ -93,12 +93,8 @@ public: header.version = HEAD_VERSION; header.compat_version = COMPAT_VERSION; encode(fsid, payload); - if ((features & CEPH_FEATURE_PGID64) == 0 || - (features & CEPH_FEATURE_PGPOOL3) == 0 || - (features & CEPH_FEATURE_OSDENC) == 0 || - (features & CEPH_FEATURE_OSDMAP_ENC) == 0 || - (features & CEPH_FEATURE_MSG_ADDR2) == 0 || - !HAVE_FEATURE(features, SERVER_LUMINOUS)) { + if (OSDMap::get_significant_features(encode_features) != + OSDMap::get_significant_features(features)) { if ((features & CEPH_FEATURE_PGID64) == 0 || (features & CEPH_FEATURE_PGPOOL3) == 0) header.version = 1; // old old_client version @@ -117,13 +113,15 @@ public: OSDMap::Incremental inc; bufferlist::iterator q = p->second.begin(); inc.decode(q); + // always encode with subset of osdmaps canonical features + uint64_t f = inc.encode_features & features; p->second.clear(); if (inc.fullmap.length()) { // embedded full map? OSDMap m; m.decode(inc.fullmap); inc.fullmap.clear(); - m.encode(inc.fullmap, features | CEPH_FEATURE_RESERVED); + m.encode(inc.fullmap, f | CEPH_FEATURE_RESERVED); } if (inc.crush.length()) { // embedded crush map @@ -131,17 +129,19 @@ public: auto p = inc.crush.begin(); c.decode(p); inc.crush.clear(); - c.encode(inc.crush, features); + c.encode(inc.crush, f); } - inc.encode(p->second, features | CEPH_FEATURE_RESERVED); + inc.encode(p->second, f | CEPH_FEATURE_RESERVED); } for (map::iterator p = maps.begin(); p != maps.end(); ++p) { OSDMap m; m.decode(p->second); + // always encode with subset of osdmaps canonical features + uint64_t f = m.get_encoding_features() & features; p->second.clear(); - m.encode(p->second, features | CEPH_FEATURE_RESERVED); + m.encode(p->second, f | CEPH_FEATURE_RESERVED); } } encode(incremental_maps, payload); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index ea050535cac70..f12815b349a71 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2055,7 +2055,7 @@ bool OSDMonitor::preprocess_get_osdmap(MonOpRequestRef op) features = m->get_session()->con_features; dout(10) << __func__ << " " << *m << dendl; - MOSDMap *reply = new MOSDMap(mon->monmap->fsid); + MOSDMap *reply = new MOSDMap(mon->monmap->fsid, features); epoch_t first = get_first_committed(); epoch_t last = osdmap.get_epoch(); int max = g_conf->osd_map_message_max; @@ -3341,7 +3341,7 @@ void OSDMonitor::send_latest(MonOpRequestRef op, epoch_t start) MOSDMap *OSDMonitor::build_latest_full(uint64_t features) { - MOSDMap *r = new MOSDMap(mon->monmap->fsid); + MOSDMap *r = new MOSDMap(mon->monmap->fsid, features); get_version_full(osdmap.get_epoch(), features, r->maps[osdmap.get_epoch()]); r->oldest_map = get_first_committed(); r->newest_map = osdmap.get_epoch(); @@ -3351,7 +3351,7 @@ MOSDMap *OSDMonitor::build_latest_full(uint64_t features) MOSDMap *OSDMonitor::build_incremental(epoch_t from, epoch_t to, uint64_t features) { dout(10) << "build_incremental [" << from << ".." << to << "] with features " << std::hex << features << dendl; - MOSDMap *m = new MOSDMap(mon->monmap->fsid); + MOSDMap *m = new MOSDMap(mon->monmap->fsid, features); m->oldest_map = get_first_committed(); m->newest_map = osdmap.get_epoch(); @@ -3429,7 +3429,7 @@ void OSDMonitor::send_incremental(epoch_t first, } if (first < get_first_committed()) { - MOSDMap *m = new MOSDMap(osdmap.get_fsid()); + MOSDMap *m = new MOSDMap(osdmap.get_fsid(), features); m->oldest_map = get_first_committed(); m->newest_map = osdmap.get_epoch(); diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 9b8891e96ba30..d2b7a317b8cde 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1299,7 +1299,8 @@ void OSDService::got_stop_ack() MOSDMap *OSDService::build_incremental_map_msg(epoch_t since, epoch_t to, OSDSuperblock& sblock) { - MOSDMap *m = new MOSDMap(monc->get_fsid()); + MOSDMap *m = new MOSDMap(monc->get_fsid(), + osdmap->get_encoding_features()); m->oldest_map = max_oldest_map; m->newest_map = sblock.newest_map; @@ -1339,7 +1340,8 @@ void OSDService::send_incremental_map(epoch_t since, Connection *con, OSDSuperblock sblock(get_superblock()); if (since < sblock.oldest_map) { // just send latest full map - MOSDMap *m = new MOSDMap(monc->get_fsid()); + MOSDMap *m = new MOSDMap(monc->get_fsid(), + osdmap->get_encoding_features()); m->oldest_map = max_oldest_map; m->newest_map = sblock.newest_map; get_map_bl(to, m->maps[to]); -- 2.39.5