}
extents->reserve(4); // 4 should be (more than) enough for most allocations
int64_t alloc_len = alloc[id]->allocate(left, min_alloc_size, 0, extents);
- if (alloc_len < (int64_t)left) {
- if (alloc_len != 0) {
+ if (alloc_len < 0 || alloc_len < (int64_t)left) {
+ if (alloc_len > 0) {
alloc[id]->release(*extents);
}
if (bdev[id])
extents.reserve(4); // 4 should be (more than) enough for most allocations
alloc_len = alloc[id]->allocate(left, min_alloc_size, hint, &extents);
}
- if (alloc_len < (int64_t)left) {
+ if (alloc_len < 0 || alloc_len < (int64_t)left) {
if (alloc_len > 0) {
alloc[id]->release(extents);
}
ceph_assert(last_alloc);
// try again
alloc_len = last_alloc->allocate(left, min_alloc_size, hint, &extents);
- if (alloc_len < (int64_t)left) {
+ if (alloc_len < 0 || alloc_len < (int64_t)left) {
if (alloc_len > 0) {
last_alloc->release(extents);
}
alloc_len = alloc->allocate(gift, cct->_conf->bluefs_alloc_size,
0, 0, extents);
- if (alloc_len) {
+ if (alloc_len > 0) {
allocated += alloc_len;
size -= alloc_len;
}
- if (alloc_len < (int64_t)gift && (min_size > allocated)) {
+ if (alloc_len < 0 ||
+ (alloc_len < (int64_t)gift && (min_size > allocated))) {
derr << __func__
<< " failed to allocate on 0x" << std::hex << gift
<< " min_size 0x" << min_size
<< " > allocated total 0x" << allocated
<< " bluefs_alloc_size 0x" << cct->_conf->bluefs_alloc_size
- << " allocated 0x" << alloc_len
+ << " allocated 0x" << (alloc_len < 0 ? 0 : alloc_len)
<< " available 0x " << alloc->get_free()
<< std::dec << dendl;
PExtentVector exts;
int64_t alloc_len = alloc->allocate(e->length, min_alloc_size,
0, 0, &exts);
- if (alloc_len < (int64_t)e->length) {
+ if (alloc_len < 0 || alloc_len < (int64_t)e->length) {
derr << __func__
<< " failed to allocate 0x" << std::hex << e->length
- << " allocated 0x " << alloc_len
+ << " allocated 0x " << (alloc_len < 0 ? 0 : alloc_len)
<< " min_alloc_size 0x" << min_alloc_size
<< " available 0x " << alloc->get_free()
<< std::dec << dendl;
prealloc_left = alloc->allocate(
need, min_alloc_size, need,
0, &prealloc);
- if (prealloc_left < (int64_t)need) {
+ if (prealloc_left < 0 || prealloc_left < (int64_t)need) {
derr << __func__ << " failed to allocate 0x" << std::hex << need
- << " allocated 0x " << prealloc_left
+ << " allocated 0x " << (prealloc_left < 0 ? 0 : prealloc_left)
<< " min_alloc_size 0x" << min_alloc_size
<< " available 0x " << alloc->get_free()
<< std::dec << dendl;