]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.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)
committerKarol Mroz <kmroz@suse.de>
Fri, 20 Oct 2017 01:50:58 +0000 (18:50 -0700)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit fc99603ea2b5b268181d38507b8b6fb55ae0a6d0)

src/cls/rbd/cls_rbd.cc

index 79795dbc37d142f916dacdef6744145257b132a2..e290d221bc725db1a0d34599c5036f94faa4828b 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;
     }
   }