]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: use best-effort policy when gifting space to bluefs
authorxie xingguo <xie.xingguo@zte.com.cn>
Wed, 13 Jul 2016 06:28:04 +0000 (14:28 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 13 Jul 2016 06:33:45 +0000 (14:33 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index cc91d89af6f2ac9ec476038991a965a90bf33ca4..d02846fb565cb41d1d656bd521a5c8dde265c43f 100644 (file)
@@ -2331,20 +2331,24 @@ int BlueStore::_balance_bluefs_freespace(vector<bluestore_pextent_t> *extents,
     int r = alloc->reserve(gift);
     assert(r == 0);
 
-    uint64_t eoffset;
-    uint32_t elength;
-    r = alloc->allocate(gift, min_alloc_size, 0, &eoffset, &elength);
-    if (r < 0) {
-      assert(0 == "allocate failed, wtf");
-      return r;
-    }
-    if (elength < gift) {
-      alloc->unreserve(gift - elength);
+    uint64_t hint = 0;
+    while (gift > 0) {
+      uint64_t eoffset;
+      uint32_t elength;
+      r = alloc->allocate(gift, min_alloc_size, hint, &eoffset, &elength);
+      if (r < 0) {
+        assert(0 == "allocate failed, wtf");
+        return r;
+      }
+
+      bluestore_pextent_t e(eoffset, elength);
+      dout(1) << __func__ << " gifting " << e << " to bluefs" << dendl;
+      extents->push_back(e);
+      gift -= e.length;
+      hint = e.end();
     }
+    assert(gift == 0); // otherwise there is a reservation leak
 
-    bluestore_pextent_t e(eoffset, elength);
-    dout(1) << __func__ << " gifting " << e << " to bluefs" << dendl;
-    extents->push_back(e);
     ret = 1;
   }