]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BitAllocator: set_bits() in batch 9162/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Wed, 18 May 2016 02:34:26 +0000 (10:34 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 1 Jun 2016 05:25:50 +0000 (13:25 +0800)
Which is simpler and faster.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BitAllocator.cc

index 4d419d4f1947281ea59b92ed8829c97a6cb74ed4..68f8a7c317da513f5de3d9d867972394f2a78304 100644 (file)
@@ -163,10 +163,12 @@ void BmapEntry::clear_bits(int offset, int num_bits)
 
 void BmapEntry::set_bits(int offset, int num_bits)
 {
-  for (int i = 0; i < num_bits; i++) {
-    bmap_t bmask = bit_mask(i + offset);
-    (void) std::atomic_fetch_or(&m_bits, bmask);
+  if (num_bits == 0) {
+    return;
   }
+
+  bmap_t bmask = BmapEntry::align_mask(num_bits) >> offset;
+  (void) std::atomic_fetch_or(&m_bits, bmask);
 }
 
 /*