]> 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:22:29 +0000 (08:22 -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>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueStore.cc

index 98c26d23cbd12bf37c7925487f886c60237f8dca..205ce2c51a9b2ad6a81aab9044da03f70f887ec5 100644 (file)
@@ -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);
index 96d5ed2f0a95539d5d8c19294542dfcabbeadf89..953c4121d1ab2d2b6709ec9a4e4a12b790d7829b 100644 (file)
@@ -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);