From 4be8a9d552b5a2903d6fad000a8f7c95feac64ad Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Thu, 12 Oct 2017 10:34:27 +0800 Subject: [PATCH] os/bluestore/BlueFS: sanity check that alloc->allocate() won't return 0 If alloc[id]->allocate() returns 0, no space is actually reclaimed. But BlueStore treats returning 0 as success and will keep reclaiming space from BlueFS until hit the given threshold, which turns out to be deadloop-prone. For now, Bitmap and Stupid never return 0-length allocated space (which is instead converted to -ENOSPC to suggest an error to caller), so sanity checking against result code 0 will suffice. Signed-off-by: xie xingguo --- src/os/bluestore/BlueFS.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 5d033e7395b..88f48eefec7 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -195,10 +195,11 @@ int BlueFS::reclaim_blocks(unsigned id, uint64_t want, assert(r == 0); // caller shouldn't ask for more than they can get int64_t got = alloc[id]->allocate(want, cct->_conf->bluefs_alloc_size, 0, extents); + assert(got != 0); if (got < (int64_t)want) { alloc[id]->unreserve(want - MAX(0, got)); } - if (got <= 0) { + if (got < 0) { derr << __func__ << " failed to allocate space to return to bluestore" << dendl; alloc[id]->dump(); -- 2.39.5