From a3fdd989d941d929c07ecc245d5906d00a4a3f79 Mon Sep 17 00:00:00 2001 From: haoyixing Date: Sun, 21 Mar 2021 07:39:29 +0000 Subject: [PATCH] mon/PGMap: change hard coded 0x10000 to macro CEPH_OSD_IN 0x10000 is same with CEPH_OSD_IN for osd weight, so change them to that macro, more meaningful. Signed-off-by: haoyixing --- src/mon/PGMap.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 8c52fd6fe5e1..dd53d0f8230a 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -3,6 +3,7 @@ #include +#include "include/rados.h" #include "PGMap.h" #define dout_subsys ceph_subsys_mon @@ -3990,7 +3991,7 @@ int reweight::by_utilization( // but aggressively adjust weights up whenever possible. const double underload_util = average_util; - const unsigned max_change = (unsigned)(max_changef * (double)0x10000); + const unsigned max_change = (unsigned)(max_changef * (double)CEPH_OSD_IN); ostringstream oss; if (f) { @@ -4067,13 +4068,13 @@ int reweight::by_utilization( if (f) { f->open_object_section("osd"); f->dump_int("osd", p.first); - f->dump_float("weight", (float)weight / (float)0x10000); - f->dump_float("new_weight", (float)new_weight / (float)0x10000); + f->dump_float("weight", (float)weight / (float)CEPH_OSD_IN); + f->dump_float("new_weight", (float)new_weight / (float)CEPH_OSD_IN); f->close_section(); } else { oss << "osd." << p.first << " weight " - << (float)weight / (float)0x10000 << " -> " - << (float)new_weight / (float)0x10000 << "\n"; + << (float)weight / (float)CEPH_OSD_IN << " -> " + << (float)new_weight / (float)CEPH_OSD_IN << "\n"; } if (++num_changed >= max_osds) break; @@ -4082,13 +4083,13 @@ int reweight::by_utilization( // assign a higher weight.. if we can. unsigned new_weight = (unsigned)((average_util / util) * (float)weight); new_weight = std::min(new_weight, weight + max_change); - if (new_weight > 0x10000) - new_weight = 0x10000; + if (new_weight > CEPH_OSD_IN) + new_weight = CEPH_OSD_IN; if (new_weight > weight) { new_weights->insert({p.first, new_weight}); oss << "osd." << p.first << " weight " - << (float)weight / (float)0x10000 << " -> " - << (float)new_weight / (float)0x10000 << "\n"; + << (float)weight / (float)CEPH_OSD_IN << " -> " + << (float)new_weight / (float)CEPH_OSD_IN << "\n"; if (++num_changed >= max_osds) break; } -- 2.47.3