From: xie xingguo Date: Wed, 13 Jul 2016 06:28:04 +0000 (+0800) Subject: os/bluestore: use best-effort policy when gifting space to bluefs X-Git-Tag: ses5-milestone5~362^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=01496b97715c4fec65727207f03481bddbca2de7;p=ceph.git os/bluestore: use best-effort policy when gifting space to bluefs Signed-off-by: xie xingguo --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index cc91d89af6f2..d02846fb565c 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -2331,20 +2331,24 @@ int BlueStore::_balance_bluefs_freespace(vector *extents, int r = alloc->reserve(gift); assert(r == 0); - uint64_t eoffset; - uint32_t elength; - r = alloc->allocate(gift, min_alloc_size, 0, &eoffset, &elength); - if (r < 0) { - assert(0 == "allocate failed, wtf"); - return r; - } - if (elength < gift) { - alloc->unreserve(gift - elength); + uint64_t hint = 0; + while (gift > 0) { + uint64_t eoffset; + uint32_t elength; + r = alloc->allocate(gift, min_alloc_size, hint, &eoffset, &elength); + if (r < 0) { + assert(0 == "allocate failed, wtf"); + return r; + } + + bluestore_pextent_t e(eoffset, elength); + dout(1) << __func__ << " gifting " << e << " to bluefs" << dendl; + extents->push_back(e); + gift -= e.length; + hint = e.end(); } + assert(gift == 0); // otherwise there is a reservation leak - bluestore_pextent_t e(eoffset, elength); - dout(1) << __func__ << " gifting " << e << " to bluefs" << dendl; - extents->push_back(e); ret = 1; }