From: Ramesh Chander Date: Mon, 2 Jan 2017 08:01:55 +0000 (-0800) Subject: unittest_bit_alloc race fix X-Git-Tag: v12.0.0~115 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=506a06a71e18db5074c5df668d26cbf585c88afc;p=ceph.git unittest_bit_alloc race fix Signed-off-by: Ramesh Chander Reviewed-by: Sage Weil --- diff --git a/src/os/bluestore/BitAllocator.cc b/src/os/bluestore/BitAllocator.cc index 9f241dbedf62..8edd47919d89 100644 --- a/src/os/bluestore/BitAllocator.cc +++ b/src/os/bluestore/BitAllocator.cc @@ -827,6 +827,12 @@ int64_t BitMapAreaIN::get_used_blocks() return m_used_blocks; } +int64_t BitMapAreaIN::get_used_blocks_adj() +{ + std::lock_guard l(m_blocks_lock); + return m_used_blocks - m_reserved_blocks; +} + bool BitMapAreaIN::reserve_blocks(int64_t num) { bool res = false; diff --git a/src/os/bluestore/BitAllocator.h b/src/os/bluestore/BitAllocator.h index a61874ea6511..2ce6b3c70ada 100644 --- a/src/os/bluestore/BitAllocator.h +++ b/src/os/bluestore/BitAllocator.h @@ -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() {