From: caleb miles Date: Thu, 14 Jun 2012 23:38:51 +0000 (-0700) Subject: nightly push to local repo X-Git-Tag: v0.49~84 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1bd5d240426c2bee0f662b72efc4a291a4ed4bf3;p=ceph.git nightly push to local repo --- diff --git a/src/crush/CrushTester.cc b/src/crush/CrushTester.cc index e3ecfea570d4..a76f6bfa99ef 100644 --- a/src/crush/CrushTester.cc +++ b/src/crush/CrushTester.cc @@ -45,6 +45,26 @@ void CrushTester::set_device_weight(int dev, float f) 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 @@ -103,7 +123,7 @@ void CrushTester::adjust_weights(vector<__u32>& weight) 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? } } } @@ -137,9 +157,17 @@ int CrushTester::test() 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++; @@ -253,7 +281,7 @@ int CrushTester::test() 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 diff --git a/src/crush/CrushTester.h b/src/crush/CrushTester.h index c96ba8cb0c67..30fce00451de 100644 --- a/src/crush/CrushTester.h +++ b/src/crush/CrushTester.h @@ -32,6 +32,7 @@ class CrushTester { void adjust_weights(vector<__u32>& weight); + vector<__u32> compact_device_weights(vector <__u32> weight); public: CrushTester(CrushWrapper& c, ostream& eo, int verbosity=0) diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 15d5e140ee11..49bcdfe6e18e 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -256,6 +256,34 @@ bool CrushWrapper::check_item_present(int id) } +map CrushWrapper::get_loc(int id) +{ + map 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 roots; diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 82b9e4b2de29..6e67d3f18108 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -216,6 +216,10 @@ public: return ret; } + + map get_loc(int id); + + /** * insert an item into the map at a specific position *