]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: remember osd weight when auto-marking osds out
authorSage Weil <sage@inktank.com>
Sun, 11 May 2014 20:45:53 +0000 (13:45 -0700)
committerSage Weil <sage@inktank.com>
Sun, 11 May 2014 20:45:53 +0000 (13:45 -0700)
If we automatically mark an OSD out, remember its OSD weight.

Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/OSDMonitor.cc
src/osd/OSDMap.cc
src/osd/OSDMap.h

index af93d0714c8f4b66b1d90bb6642cb27f5513d857..94fbabec2dfbb4e978a398be192e653bb8e658db 100644 (file)
@@ -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";
index 24404626b09d25bbec29503ed5a1a66886092757..6b36465b5b64c6cf19df2d8cde521ec665f40e03 100644 (file)
@@ -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<osd_xinfo_t*>& 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<int32_t,uint32_t>::const_iterator i = inc.new_primary_affinity.begin();
index 650957d13266864d04a2013ab3c1a3ebdef76a2e..6666a054bb71ae01475874a21b709bca9d49b437 100644 (file)
@@ -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;