]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: check_item_present
authorCaleb Miles <caleb.miles@inktank.com>
Sun, 3 Jun 2012 22:25:09 +0000 (15:25 -0700)
committerCaleb Miles <caleb.miles@inktank.com>
Sun, 3 Jun 2012 22:25:09 +0000 (15:25 -0700)
True if id is present in the map.

Signed-off-by: Caleb Miles <caleb.miles@inktank.com>
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h

index 1476286c7291905ee6cd8cc55a568c7f351c3406..fd86f36186189a235500dc93ed92cce55c2740f9 100644 (file)
@@ -240,6 +240,22 @@ int CrushWrapper::adjust_item_weight(CephContext *cct, int id, int weight)
   return -ENOENT;
 }
 
+bool CrushWrapper::check_item_present(int id)
+{
+  bool found = false;
+
+  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)
+       found = true;
+  }
+  return found;
+}
+
+
 void CrushWrapper::reweight(CephContext *cct)
 {
   set<int> roots;
index 7f843cc0feb3b454f364fa05064f74b5944099b3..fd48e64c76d3e834dcb2bdb48b61620b9f0c788d 100644 (file)
@@ -253,6 +253,10 @@ public:
   }
   void reweight(CephContext *cct);
 
+  /// check if item id is present in the map hierarchy
+  bool check_item_present(int id);
+
+
   /*** devices ***/
   int get_max_devices() const {
     if (!crush) return 0;