]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlueFS: sanity check that alloc->allocate() won't return 0 18259/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 12 Oct 2017 02:34:27 +0000 (10:34 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Thu, 12 Oct 2017 02:34:27 +0000 (10:34 +0800)
If alloc[id]->allocate() returns 0, no space is actually reclaimed.
But BlueStore treats returning 0 as success and will keep reclaiming
space from BlueFS until hit the given threshold, which turns out to
be deadloop-prone.

For now, Bitmap and Stupid never return 0-length allocated space
(which is instead converted to -ENOSPC to suggest an error to caller),
so sanity checking against result code 0 will suffice.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueFS.cc

index 5d033e7395b236c19c5cb94cde3c217721f0b39f..88f48eefec743d22509b6005bbd18efb1ffaa449 100644 (file)
@@ -195,10 +195,11 @@ 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 - MAX(0, got));
   }
-  if (got <= 0) {
+  if (got < 0) {
     derr << __func__ << " failed to allocate space to return to bluestore"
         << dendl;
     alloc[id]->dump();