From 87722a42c286d4d12190b86b6d06d388e2953ba0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 11 May 2014 13:45:53 -0700 Subject: [PATCH] mon: remember osd weight when auto-marking osds out If we automatically mark an OSD out, remember its OSD weight. Signed-off-by: Sage Weil --- src/mon/OSDMonitor.cc | 5 +++++ src/osd/OSDMap.cc | 21 ++++++++++++++++----- src/osd/OSDMap.h | 3 ++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index af93d0714c8f4..94fbabec2dfbb 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -1884,6 +1884,11 @@ void OSDMonitor::tick() pending_inc.new_state[o] = 0; pending_inc.new_state[o] |= CEPH_OSD_AUTOOUT; + // remember previous weight + if (pending_inc.new_xinfo.count(o) == 0) + pending_inc.new_xinfo[o] = osdmap.osd_xinfo[o]; + pending_inc.new_xinfo[o].old_weight = osdmap.osd_weight[o]; + do_propose = true; mon->clog.info() << "osd." << o << " out (down for " << down << ")\n"; diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 24404626b09d2..6b36465b5b64c 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -95,22 +95,24 @@ void osd_xinfo_t::dump(Formatter *f) const f->dump_float("laggy_probability", laggy_probability); f->dump_int("laggy_interval", laggy_interval); f->dump_int("features", features); + f->dump_unsigned("old_weight", old_weight); } void osd_xinfo_t::encode(bufferlist& bl) const { - ENCODE_START(2, 1, bl); + ENCODE_START(3, 1, bl); ::encode(down_stamp, bl); __u32 lp = laggy_probability * 0xfffffffful; ::encode(lp, bl); ::encode(laggy_interval, bl); ::encode(features, bl); + ::encode(old_weight, bl); ENCODE_FINISH(bl); } void osd_xinfo_t::decode(bufferlist::iterator& bl) { - DECODE_START(1, bl); + DECODE_START(3, bl); ::decode(down_stamp, bl); __u32 lp; ::decode(lp, bl); @@ -120,6 +122,10 @@ void osd_xinfo_t::decode(bufferlist::iterator& bl) ::decode(features, bl); else features = 0; + if (struct_v >= 3) + ::decode(old_weight, bl); + else + old_weight = 0; DECODE_FINISH(bl); } @@ -130,13 +136,15 @@ void osd_xinfo_t::generate_test_instances(list& o) o.back()->down_stamp = utime_t(2, 3); o.back()->laggy_probability = .123; o.back()->laggy_interval = 123456; + o.back()->old_weight = 0x7fff; } ostream& operator<<(ostream& out, const osd_xinfo_t& xi) { return out << "down_stamp " << xi.down_stamp << " laggy_probability " << xi.laggy_probability - << " laggy_interval " << xi.laggy_interval; + << " laggy_interval " << xi.laggy_interval + << " old_weight " << xi.old_weight; } // ---------------------------------- @@ -1202,9 +1210,12 @@ int OSDMap::apply_incremental(const Incremental &inc) ++i) { set_weight(i->first, i->second); - // if we are marking in, clear the AUTOOUT and NEW bits. - if (i->second) + // if we are marking in, clear the AUTOOUT and NEW bits, and clear + // xinfo old_weight. + if (i->second) { osd_state[i->first] &= ~(CEPH_OSD_AUTOOUT | CEPH_OSD_NEW); + osd_xinfo[i->first].old_weight = 0; + } } for (map::const_iterator i = inc.new_primary_affinity.begin(); diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 650957d132668..6666a054bb71a 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -93,9 +93,10 @@ struct osd_xinfo_t { float laggy_probability; ///< encoded as __u32: 0 = definitely not laggy, 0xffffffff definitely laggy __u32 laggy_interval; ///< average interval between being marked laggy and recovering uint64_t features; ///< features supported by this osd we should know about + __u32 old_weight; ///< weight prior to being auto marked out osd_xinfo_t() : laggy_probability(0), laggy_interval(0), - features(0) {} + features(0), old_weight(0) {} void dump(Formatter *f) const; void encode(bufferlist& bl) const; -- 2.39.5