Skip to content

Commit

Permalink
osd: fix rewewight_by_utilization
Browse files Browse the repository at this point in the history
Update the incremental, not the in-memory OSDMap!

Fixes: ceph#2454
Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
liewegas committed May 30, 2012
1 parent 07498d6 commit 519fadb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,13 @@ int OSDMonitor::reweight_by_utilization(int oload, std::string& out_str)
// Assign a lower weight to overloaded OSDs. The current weight
// is a factor to take into account the original weights,
// to represent e.g. differing storage capacities
float weight = osdmap.get_weightf(p->first);
float new_weight = (average_util / util) * weight;
osdmap.set_weightf(p->first, new_weight);
unsigned weight = osdmap.get_weight(p->first);
unsigned new_weight = (unsigned)((average_util / util) * (float)weight);
pending_inc.new_weight[p->first] = new_weight;
char buf[128];
snprintf(buf, sizeof(buf), "%d [%04f -> %04f]", p->first,
weight, new_weight);
(float)weight / (float)0x10000,
(float)new_weight / (float)0x10000);
oss << buf << sep;
}
}
Expand Down

0 comments on commit 519fadb

Please sign in to comment.