From: Sage Weil Date: Fri, 16 Aug 2019 21:44:57 +0000 (-0500) Subject: os/bluestore: cleanup around allocator calls X-Git-Tag: v12.2.13~146^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=996761682bd8a132d1b045625906c593a191ede6;p=ceph.git os/bluestore: cleanup around allocator calls Both stupid and bitmap allocator returs -ENOSPC if they're unable to allocate any space. Existing callers aren't always respect this - hence doing some cleanup. Signed-off-by: Igor Fedotov (cherry picked from commit a1246da5705e2a699656c2561cebc5ed29628c90) - allocator fallback not there - allocator fallback not there --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index c3ea0138991..c357f44c144 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -1961,8 +1961,8 @@ int BlueFS::_allocate(uint8_t id, uint64_t len, 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) { + if (alloc_len < 0 || alloc_len < (int64_t)left) { + if (alloc_len > 0) { alloc[id]->release(extents); } if (id != BDEV_SLOW) { diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index e353ab6e063..b06c5d629b3 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -10523,9 +10523,12 @@ int BlueStore::_do_alloc_write( prealloc_left = alloc->allocate( need, min_alloc_size, need, 0, &prealloc); - if (prealloc_left < 0) { + if (prealloc_left < 0 || prealloc_left < (int64_t)need) { derr << __func__ << " failed to allocate 0x" << std::hex << need << std::dec << dendl; + if (prealloc_left > 0) { + alloc->release(prealloc); + } return -ENOSPC; } assert(prealloc_left == (int64_t)need);