]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BitMapAllocator: align to min_alloc_size on init_rm_free
authorSage Weil <sage@redhat.com>
Thu, 11 Aug 2016 21:12:58 +0000 (17:12 -0400)
committerSage Weil <sage@redhat.com>
Thu, 11 Aug 2016 21:12:58 +0000 (17:12 -0400)
In init_add_free we only use the min_alloc_size aligned
portion of the provided extent.  Since we have some
callers that add in free space and then take it back,
make init_rm_free do the same.  That way we can, e.g,
init_add_free 0x1000~0x400000000 (alloc will add
0x10000~0x3ffffff0000) and then
init_rm_free 0x1000~0x100000 (alloc will remove
0x10000~0xf0000).

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BitMapAllocator.cc

index 3ca40af418bd9a975c5a333fe42a8d2d65ff9a6e..6f49bdb27f656e1cc8a14fd0242ab821422b367c 100644 (file)
@@ -303,13 +303,20 @@ void BitMapAllocator::init_rm_free(uint64_t offset, uint64_t length)
            << " length 0x" << length << std::dec
            << dendl;
 
-  assert(!(offset % m_block_size));
-  assert(!(length % m_block_size));
+  // we use the same adjustment/alignment that init_add_free does
+  // above so that we can yank back some of the space.
+  uint64_t offset_adj = ROUND_UP_TO(offset, m_block_size);
+  uint64_t length_adj = ((length - (offset_adj - offset)) /
+                         m_block_size) * m_block_size;
+
+  assert(!(offset_adj % m_block_size));
+  assert(!(length_adj % m_block_size));
 
-  int64_t first_blk = offset / m_block_size;
-  int64_t count = length / m_block_size;
+  int64_t first_blk = offset_adj / m_block_size;
+  int64_t count = length_adj / m_block_size;
 
-  m_bit_alloc->set_blocks_used(first_blk, count);
+  if (count)
+    m_bit_alloc->set_blocks_used(first_blk, count);
 }