]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cls/rbd: object map update now utilizes constant-time bit vector operations
authorJason Dillaman <dillaman@redhat.com>
Fri, 13 Oct 2017 15:06:38 +0000 (11:06 -0400)
committerJason Dillaman <dillaman@redhat.com>
Sun, 15 Oct 2017 13:13:07 +0000 (09:13 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/cls/rbd/cls_rbd.cc

index be5f19ec6cc7c82afefd2f1215a7470da857dc88..ab854c36aba0b91085dfccc92444ac3bbe6da26b 100644 (file)
@@ -2460,7 +2460,7 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out
     CLS_ERR("object map footer read failed");
     return r;
   }
+
   try {
     bufferlist::iterator it = footer_bl.begin();
     object_map.decode_footer(it);
@@ -2496,13 +2496,14 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out
   }
 
   bool updated = false;
-  for (uint64_t object_no = start_object_no; object_no < end_object_no;
-       ++object_no) {
-    uint8_t state = object_map[object_no];
+  auto it = object_map.begin() + start_object_no;
+  auto end_it = object_map.begin() + end_object_no;
+  for (; it != end_it; ++it) {
+    uint8_t state = *it;
     if ((!current_object_state || state == *current_object_state ||
         (*current_object_state == OBJECT_EXISTS &&
          state == OBJECT_EXISTS_CLEAN)) && state != new_object_state) {
-      object_map[object_no] = new_object_state;
+      *it = new_object_state;
       updated = true;
     }
   }