Skip to content

Commit

Permalink
osdmap: store new range_blocklist, updated as we do the existing bloc…
Browse files Browse the repository at this point in the history
…klist

Signed-off-by: Greg Farnum <[email protected]>
  • Loading branch information
gregsfortytwo committed Apr 13, 2022
1 parent 8941450 commit c0b87d9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
54 changes: 51 additions & 3 deletions src/osd/OSDMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons
}

{
uint8_t target_v = 9; // if bumping this, be aware of stretch_mode target_v 10!
uint8_t target_v = 9; // if bumping this, be aware of range_blocklist 11
if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
target_v = 2;
} else if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
Expand All @@ -657,6 +657,10 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons
if (change_stretch_mode) {
target_v = std::max((uint8_t)10, target_v);
}
if (!new_range_blocklist.empty() ||
!old_range_blocklist.empty()) {
target_v = std::max((uint8_t)11, target_v);
}
ENCODE_START(target_v, 1, bl); // extended, osd-only data
if (target_v < 7) {
encode_addrvec_map_as_addr(new_hb_back_up, bl, features);
Expand Down Expand Up @@ -706,6 +710,10 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons
encode(new_stretch_mode_bucket, bl);
encode(stretch_mode_enabled, bl);
}
if (target_v >= 11) {
encode(new_range_blocklist, bl, features);
encode(old_range_blocklist, bl, features);
}
ENCODE_FINISH(bl); // osd-only data
}

Expand Down Expand Up @@ -980,7 +988,10 @@ void OSDMap::Incremental::decode(ceph::buffer::list::const_iterator& bl)
decode(new_stretch_mode_bucket, bl);
decode(stretch_mode_enabled, bl);
}

if (struct_v >= 11) {
decode(new_range_blocklist, bl);
decode(old_range_blocklist, bl);
}
DECODE_FINISH(bl); // osd-only data
}

Expand Down Expand Up @@ -1226,6 +1237,17 @@ void OSDMap::Incremental::dump(Formatter *f) const
for (const auto &blist : old_blocklist)
f->dump_stream("addr") << blist;
f->close_section();
f->open_array_section("new_range_blocklist");
for (const auto &blist : new_range_blocklist) {
stringstream ss;
ss << blist.first;
f->dump_stream(ss.str().c_str()) << blist.second;
}
f->close_section();
f->open_array_section("old_range_blocklist");
for (const auto &blist : old_range_blocklist)
f->dump_stream("addr") << blist;
f->close_section();

f->open_array_section("new_xinfo");
for (const auto &xinfo : new_xinfo) {
Expand Down Expand Up @@ -2287,6 +2309,14 @@ int OSDMap::apply_incremental(const Incremental &inc)
for (const auto &addr : inc.old_blocklist)
blocklist.erase(addr);

if (!inc.new_range_blocklist.empty()) {
range_blocklist.insert(inc.new_range_blocklist.begin(),
inc.new_range_blocklist.end());
new_blocklist_entries = true;
}
for (const auto &addr : inc.old_range_blocklist)
range_blocklist.erase(addr);

for (auto& i : inc.new_crush_node_flags) {
if (i.second) {
crush_node_flags[i.first] = i.second;
Expand Down Expand Up @@ -3037,7 +3067,7 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const
{
// NOTE: any new encoding dependencies must be reflected by
// SIGNIFICANT_FEATURES
uint8_t target_v = 9; // when bumping this, be aware of stretch_mode target_v 10!
uint8_t target_v = 9; // when bumping this, be aware of range blocklist
if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
target_v = 1;
} else if (!HAVE_FEATURE(features, SERVER_MIMIC)) {
Expand All @@ -3048,6 +3078,9 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const
if (stretch_mode_enabled) {
target_v = std::max((uint8_t)10, target_v);
}
if (!range_blocklist.empty()) {
target_v = std::max((uint8_t)11, target_v);
}
ENCODE_START(target_v, 1, bl); // extended, osd-only data
if (target_v < 7) {
encode_addrvec_pvec_as_addr(osd_addrs->hb_back_addrs, bl, features);
Expand Down Expand Up @@ -3103,6 +3136,9 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const
encode(recovering_stretch_mode, bl);
encode(stretch_mode_bucket, bl);
}
if (target_v >= 11) {
::encode(range_blocklist, bl, features);
}
ENCODE_FINISH(bl); // osd-only data
}

Expand Down Expand Up @@ -3442,6 +3478,9 @@ void OSDMap::decode(ceph::buffer::list::const_iterator& bl)
recovering_stretch_mode = 0;
stretch_mode_bucket = 0;
}
if (struct_v >= 11) {
decode(range_blocklist, bl);
}
DECODE_FINISH(bl); // osd-only data
}

Expand Down Expand Up @@ -3654,6 +3693,13 @@ void OSDMap::dump(Formatter *f) const
f->dump_stream(ss.str().c_str()) << addr.second;
}
f->close_section();
f->open_object_section("range_blocklist");
for (const auto &addr : range_blocklist) {
stringstream ss;
ss << addr.first;
f->dump_stream(ss.str().c_str()) << addr.second;
}
f->close_section();

dump_erasure_code_profiles(erasure_code_profiles, f);

Expand Down Expand Up @@ -3918,6 +3964,8 @@ void OSDMap::print(ostream& out) const

for (const auto &addr : blocklist)
out << "blocklist " << addr.first << " expires " << addr.second << "\n";
for (const auto &addr : range_blocklist)
out << "range blocklist " << addr.first << " expires " << addr.second << "\n";
}

class OSDTreePlainDumper : public CrushTreeDumper::Dumper<TextTable> {
Expand Down
3 changes: 3 additions & 0 deletions src/osd/OSDMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ class OSDMap {

mempool::osdmap::map<entity_addr_t,utime_t> new_blocklist;
mempool::osdmap::vector<entity_addr_t> old_blocklist;
mempool::osdmap::map<entity_addr_t,utime_t> new_range_blocklist;
mempool::osdmap::vector<entity_addr_t> old_range_blocklist;
mempool::osdmap::map<int32_t, entity_addrvec_t> new_hb_back_up;
mempool::osdmap::map<int32_t, entity_addrvec_t> new_hb_front_up;

Expand Down Expand Up @@ -583,6 +585,7 @@ class OSDMap {
mempool::osdmap::vector<osd_xinfo_t> osd_xinfo;

mempool::osdmap::unordered_map<entity_addr_t,utime_t> blocklist;
mempool::osdmap::map<entity_addr_t,utime_t> range_blocklist;

/// queue of snaps to remove
mempool::osdmap::map<int64_t, snap_interval_set_t> removed_snaps_queue;
Expand Down

0 comments on commit c0b87d9

Please sign in to comment.