From 34913f9c07b77f0c0257c11540d6257c4a1beeba Mon Sep 17 00:00:00 2001 From: wangzhengyong Date: Thu, 16 Feb 2017 16:41:56 +0800 Subject: [PATCH] os/bluestore/BitAllocator: fix bug of checking required blocks Signed-off-by: wangzhengyong@cmss.chinamobile.com --- src/os/bluestore/BitAllocator.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/os/bluestore/BitAllocator.cc b/src/os/bluestore/BitAllocator.cc index 4b19ac1ffd843..9e754bc0ef889 100644 --- a/src/os/bluestore/BitAllocator.cc +++ b/src/os/bluestore/BitAllocator.cc @@ -791,6 +791,13 @@ bool BitMapAreaIN::child_check_n_lock(BitMapArea *child, int64_t required) return false; } + int64_t child_used_blocks = child->get_used_blocks(); + int64_t child_total_blocks = child->size(); + if ((child_total_blocks - child_used_blocks) < required) { + child->unlock(); + return false; + } + return true; } @@ -1101,6 +1108,14 @@ bool BitMapAreaLeaf::child_check_n_lock(BitMapArea *child, int64_t required, boo child->unlock(); return false; } + + int64_t child_used_blocks = child->get_used_blocks(); + int64_t child_total_blocks = child->size(); + if ((child_total_blocks - child_used_blocks) < required) { + child->unlock(); + return false; + } + return true; } @@ -1338,6 +1353,12 @@ bool BitAllocator::child_check_n_lock(BitMapArea *child, int64_t required) return false; } + int64_t child_used_blocks = child->get_used_blocks(); + int64_t child_total_blocks = child->size(); + if ((child_total_blocks - child_used_blocks) < required) { + child->unlock(); + return false; + } return true; } -- 2.39.5