From c6d8a7b18a326245b86cb3cf7f3ad5b53fbce633 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Tue, 6 Feb 2018 20:45:24 +0300 Subject: [PATCH] os/bluestore: do not assert on insufficient allocation during bluefs rebalance Signed-off-by: Igor Fedotov (cherry picked from commit 64abc7ba39fab57cc9e19463219e8a70d284eda0) --- src/os/bluestore/BlueStore.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 285424d22b773..efbfd7f33a817 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -4943,12 +4943,19 @@ int BlueStore::_balance_bluefs_freespace(PExtentVector *extents) int64_t alloc_len = alloc->allocate(gift, cct->_conf->bluefs_alloc_size, 0, 0, &exts); - if (alloc_len < (int64_t)gift) { - derr << __func__ << " allocate failed on 0x" << std::hex << gift - << " min_alloc_size 0x" << min_alloc_size << std::dec << dendl; + if (alloc_len <= 0) { + dout(1) << __func__ << " no allocate on 0x" << std::hex << gift + << " min_alloc_size 0x" << min_alloc_size << std::dec << dendl; + alloc->unreserve(gift); + alloc->dump(); + return 0; + } else if (alloc_len < (int64_t)gift) { + dout(1) << __func__ << " insufficient allocate on 0x" << std::hex << gift + << " min_alloc_size 0x" << min_alloc_size + << " allocated 0x" << alloc_len + << std::dec << dendl; + alloc->unreserve(gift - alloc_len); alloc->dump(); - assert(0 == "allocate failed, wtf"); - return -ENOSPC; } for (auto& p : exts) { bluestore_pextent_t e = bluestore_pextent_t(p); @@ -5463,7 +5470,6 @@ int BlueStore::_mount(bool kv_only) mempool_thread.init(); - mounted = true; return 0; @@ -8273,7 +8279,8 @@ void BlueStore::_txc_release_alloc(TransContext *txc) { // update allocator with full released set if (!cct->_conf->bluestore_debug_no_reuse_blocks) { - dout(10) << __func__ << " " << txc << " " << txc->released << dendl; + dout(10) << __func__ << " " << txc << " " << std::hex + << txc->released << std::dec << dendl; for (interval_set::iterator p = txc->released.begin(); p != txc->released.end(); ++p) { -- 2.39.5