From fc99603ea2b5b268181d38507b8b6fb55ae0a6d0 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 13 Oct 2017 11:06:38 -0400 Subject: [PATCH] cls/rbd: object map update now utilizes constant-time bit vector operations Signed-off-by: Jason Dillaman --- src/cls/rbd/cls_rbd.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc index be5f19ec6cc7c..ab854c36aba0b 100644 --- a/src/cls/rbd/cls_rbd.cc +++ b/src/cls/rbd/cls_rbd.cc @@ -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; } } -- 2.39.5