]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
unittest_bit_alloc race fix
authorRamesh Chander <Ramesh.Chander@sandisk.com>
Mon, 2 Jan 2017 08:01:55 +0000 (00:01 -0800)
committerSage Weil <sage@redhat.com>
Mon, 23 Jan 2017 15:19:48 +0000 (10:19 -0500)
Signed-off-by: Ramesh Chander <Ramesh.Chander@sandisk.com>
Reviewed-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BitAllocator.cc
src/os/bluestore/BitAllocator.h

index 9f241dbedf62fa188e32174097627e06c40f3b6a..8edd47919d89cee1931354985bfa06395e2c96f5 100644 (file)
@@ -827,6 +827,12 @@ int64_t BitMapAreaIN::get_used_blocks()
   return m_used_blocks;
 }
 
+int64_t BitMapAreaIN::get_used_blocks_adj()
+{
+  std::lock_guard<std::mutex> l(m_blocks_lock);
+  return m_used_blocks - m_reserved_blocks;
+}
+
 bool BitMapAreaIN::reserve_blocks(int64_t num)
 {
   bool res = false;
index a61874ea6511e042690369d9edf4b5b80ca18af8..2ce6b3c70adadffc4890b7661883cf7b01b31105 100644 (file)
@@ -416,6 +416,7 @@ public:
   virtual void unreserve(int64_t num_blocks, int64_t allocated);
   virtual int64_t get_reserved_blocks();
   virtual int64_t get_used_blocks();
+  virtual int64_t get_used_blocks_adj();
   virtual int64_t size() {
     return m_total_blocks;
   }
@@ -530,7 +531,7 @@ public:
     return m_total_blocks - m_extra_blocks;
   }
   int64_t get_used_blocks() {
-    return BitMapAreaIN::get_used_blocks() - (m_extra_blocks + m_reserved_blocks);
+    return (BitMapAreaIN::get_used_blocks_adj() - m_extra_blocks);
   }
 
   BitAllocatorStats *get_stats() {