From: Sage Weil Date: Wed, 18 Jan 2017 12:24:06 +0000 (-0600) Subject: os/bluestore/BlueFS: handle failure to reclaim blocks without crashing X-Git-Tag: v12.0.0~139^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6dc1bcd9e72b01c3fbf09c7eb91cd7cf4e01f94a;p=ceph.git os/bluestore/BlueFS: handle failure to reclaim blocks without crashing We shouldn't fail to reclaim space in general, but if we do, do not treat it as a fatal error. Log loudly. Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 98c26d23cbd12..205ce2c51a9b2 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -181,9 +181,14 @@ 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 - got); + if (got < (int64_t)want) { + alloc[id]->unreserve(want - MAX(0, got)); + } + if (got <= 0) { + derr << __func__ << " failed to allocate space to return to bluestore" + << dendl; + return got; + } for (auto& p : *extents) { block_all[id].erase(p.offset, p.length); diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 96d5ed2f0a955..953c4121d1ab2 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -3844,8 +3844,11 @@ int BlueStore::_balance_bluefs_freespace(PExtentVector *extents) AllocExtentVector extents; int r = bluefs->reclaim_blocks(bluefs_shared_bdev, reclaim, &extents); - assert(r >= 0); - + if (r < 0) { + derr << __func__ << " failed to reclaim space from bluefs" + << dendl; + break; + } for (auto e : extents) { bluefs_extents.erase(e.offset, e.length); bluefs_extents_reclaiming.insert(e.offset, e.length);