From: wangzhengyong Date: Thu, 16 Feb 2017 08:41:56 +0000 (+0800) Subject: os/bluestore/BitAllocator: fix bug of checking required blocks X-Git-Tag: v12.0.1~291^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F13470%2Fhead;p=ceph.git os/bluestore/BitAllocator: fix bug of checking required blocks Signed-off-by: wangzhengyong@cmss.chinamobile.com --- diff --git a/src/os/bluestore/BitAllocator.cc b/src/os/bluestore/BitAllocator.cc index 4b19ac1ffd84..9e754bc0ef88 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; }