]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: cleanup around allocator calls
authorSage Weil <sage@redhat.com>
Fri, 16 Aug 2019 21:44:57 +0000 (16:44 -0500)
committerSage Weil <sage@redhat.com>
Tue, 20 Aug 2019 15:29:22 +0000 (10:29 -0500)
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 <ifedotov@suse.com>
(cherry picked from commit a1246da5705e2a699656c2561cebc5ed29628c90)

- allocator fallback not there
- allocator fallback not there

src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueStore.cc

index c3ea01389911c68e959b9f09e30c14761d7e4dda..c357f44c144e803a63c82d00ec8659b1463aeaa5 100644 (file)
@@ -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) {
index e353ab6e063a6d99718e0a70619fc8e9b82224e6..b06c5d629b3d9d128d783b7edc416426e103db37 100644 (file)
@@ -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);