]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlueFS: handle failure to reclaim blocks without crashing
authorSage Weil <sage@redhat.com>
Wed, 18 Jan 2017 12:24:06 +0000 (06:24 -0600)
committerSage Weil <sage@redhat.com>
Wed, 18 Jan 2017 14:24:39 +0000 (08:24 -0600)
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 <sage@redhat.com>
(cherry picked from commit 6dc1bcd9e72b01c3fbf09c7eb91cd7cf4e01f94a)

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

index b9d7bf0568726e0e80965434fcf7feab180ebb8d..93bc7ec6aca4185b19f95182b568fd5faaa27aeb 100644 (file)
@@ -179,9 +179,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, g_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);
index 36004808e84ed916c56f3c326deec2725bf0a8dc..f876aa581e324d12377c717895745b40970e7d32 100644 (file)
@@ -3656,8 +3656,11 @@ int BlueStore::_balance_bluefs_freespace(vector<bluestore_pextent_t> *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);