]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: try to gift large extents, then fall back to small extents 29740/head
authorSage Weil <sage@redhat.com>
Mon, 19 Aug 2019 15:09:36 +0000 (10:09 -0500)
committerSage Weil <sage@redhat.com>
Tue, 20 Aug 2019 15:29:27 +0000 (10:29 -0500)
First try to gift using the larger alloc_size (normally bluefs_alloc_size,
but here max(bluefs_alloc_size,bluefs_shared_alloc_size) just in case the
settings are weird.  If that fails, then try the shared_alloc_size.  If
that fails, fail and complain as before, with an more accurate error
message.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc

index 06fdddd599d731307a934a6c4e77da12b312fff8..190189fb6bbaf7fc4d01789e6f80a545be5d798b 100644 (file)
@@ -5346,21 +5346,40 @@ int BlueStore::_balance_bluefs_freespace(PExtentVector *extents)
   }
 
   if (gift) {
-    // round up to alloc size
-    gift = P2ROUNDUP(gift, cct->_conf->bluefs_alloc_size);
-
     // hard cap to fit into 32 bits
     gift = MIN(gift, 1ull<<31);
     dout(10) << __func__ << " gifting " << gift
             << " (" << byte_u_t(gift) << ")" << dendl;
 
-    int64_t alloc_len = alloc->allocate(gift,
-                                       cct->_conf->bluefs_shared_alloc_size,
+    // first try to allocate larger chunks (usually the bluefs alloc
+    // size is larger, but behave regardless)
+    auto max_alloc_size = std::max<uint64_t>(
+      cct->_conf->bluefs_alloc_size,
+      cct->_conf->bluefs_shared_alloc_size);
+    int64_t first_attempt = std::min<int64_t>(P2ROUNDUP(gift, max_alloc_size),
+                                             1ull<<31);
+    int64_t alloc_len = alloc->allocate(first_attempt, max_alloc_size,
                                        0, 0, extents);
-
     if (alloc_len <= 0) {
-      dout(0) << __func__ << " no allocate on 0x" << std::hex << gift
-              << " min_alloc_size 0x" << min_alloc_size << std::dec << dendl;
+      // if that fails, then try the shared size...
+      int64_t second_attempt =
+       std::min<int64_t>(P2ROUNDUP(gift, cct->_conf->bluefs_shared_alloc_size),
+                         1ull<<31);
+      dout(10) << __func__ << " failed to alloc 0x " << std::hex << first_attempt
+              << " with larger chunks (0x"
+              << max_alloc_size
+              << "), fall back to 0x" << second_attempt
+              << " shared_alloc_size (0x"
+              << cct->_conf->bluefs_shared_alloc_size
+              << std::dec << ")" << dendl;
+      alloc_len = alloc->allocate(
+       second_attempt,
+       cct->_conf->bluefs_shared_alloc_size,
+       0, 0, extents);
+    }
+    if (alloc_len <= 0 || alloc_len < gift) {
+      dout(0) << __func__ << " no allocate on 0x" << std::hex << gift << std::dec
+             << dendl;
       _dump_alloc_on_rebalance_failure();
       return 0;
     } else if (alloc_len < (int64_t)gift) {