device_weight[dev] = w;
}
+vector <__u32> CrushTester::compact_device_weights(vector <__u32> weight)
+{
+ vector<__u32> compact_weight;
+ __u32 num_to_check = weight.size();
+ int last_id_used = 0;
+
+ for (__u32 i = 0; i < num_to_check; i++){
+ if (weight[i] > 0){
+ compact_weight.push_back( weight[i]);
+ }
+ else if (weight[i] == 0){
+
+ }
+ }
+
+ return compact_weight;
+}
+
+
+
void CrushTester::adjust_weights(vector<__u32>& weight)
{
#ifdef HAVE_BOOST_RANDOM_DISCRETE_DISTRIBUTION
for (int o = 0; o < local_devices_to_visit; o++){
int item = crush.get_bucket_item(id, o);
//err << "device " << item << " in bucket " << id << " weight " << crush.get_bucket_item_weight(id, o) << std::endl;
- weight[item] = 10;
+ weight[item] = 0; // changed from "10" possible bug?
}
}
}
if (output_utilization_all)
err << "devices weights (hex): " << hex << weight << dec << std::endl;
+ // test ability to retrieve item parent information
+ if (output_utilization_all)
+ for (int j = 0; j < weight.size(); j++)
+ err << "device " << j << " is located at " << crush.get_loc(j) << endl;
+
// make adjustments
adjust_weights(weight);
+ // create a temporary vector to hold a weight vector with no devices marked out
+ vector<__u32> compacted_weight = compact_device_weights(weight);
+
int num_devices_active = 0;
for (vector<__u32>::iterator p = weight.begin(); p != weight.end(); ++p)
num_devices_active++;
if (use_crush) {
if (output_statistics)
err << "CRUSH"; // prepend CRUSH to placement output
- crush.do_rule(r, x, out, nr, weight);
+ crush.do_rule(r, x, out, nr, compacted_weight);
} else {
if (output_statistics)
err << "RNG"; // prepend RNG to placement output to denote simulation
}
+map<string,string> CrushWrapper::get_loc(int id)
+{
+ map <string, string> loc;
+
+ if (id < 0){
+ loc["device"] = "0"; // add an actual error condition FIXME
+ return loc;
+ }
+
+ else if (id >= 0){
+ for (int bidx = 0; bidx < crush->max_buckets; bidx++) {
+ crush_bucket *b = crush->buckets[bidx];
+ if (b == 0)
+ continue;
+ for (unsigned i = 0; i < b->size; i++)
+ if (b->items[i] == id){
+ string parent_id = name_map[b->id];
+ string parent_bucket_type = type_map[b->type];
+ loc[parent_bucket_type] = parent_id;
+ }
+ }
+ }
+
+ return loc;
+}
+
+
+
void CrushWrapper::reweight(CephContext *cct)
{
set<int> roots;