]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Better handling of deferred write trigger
authorAdam Kupczyk <akupczyk@redhat.com>
Mon, 9 Aug 2021 13:59:46 +0000 (15:59 +0200)
committerNeha Ojha <nojha@redhat.com>
Thu, 12 Aug 2021 18:52:28 +0000 (18:52 +0000)
Now deferred write in _do_alloc_write does not depend on blob size,
but on size of extent allocated on disk.
It is now possible to set bluestore_prefer_deferred_size way larger than
bluestore_max_blob_size and still get desired behavior.
Example: for deferred=256K, blob=64K : when op write is 128K both blobs will be
written as deferred. When op write is 256K then all will go as regular write.

Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
(cherry picked from commit 06ac561a72a93bd24d05b6c2266d66fee49228b8)

src/os/bluestore/BlueStore.cc

index 05ce6c5bf38a10a32c54ed7b3792f3637d76cfa1..f4badadaa363a8e005c0294630bcbcb6a73bbba3 100644 (file)
@@ -14077,6 +14077,8 @@ int BlueStore::_do_alloc_write(
 
   dout(20) << __func__ << " prealloc " << prealloc << dendl;
   auto prealloc_pos = prealloc.begin();
+  ceph_assert(prealloc_pos != prealloc.end());
+  uint64_t prealloc_pos_length = prealloc_pos->length;
 
   for (auto& wi : wctx->writes) {
     bluestore_blob_t& dblob = wi.b->dirty_blob();
@@ -14139,14 +14141,19 @@ int BlueStore::_do_alloc_write(
 
     PExtentVector extents;
     int64_t left = final_length;
+    bool deferred_region_small = false;
     while (left > 0) {
       ceph_assert(prealloc_left > 0);
+      deferred_region_small |= (prealloc_pos_length <= prefer_deferred_size.load());
       if (prealloc_pos->length <= left) {
        prealloc_left -= prealloc_pos->length;
        left -= prealloc_pos->length;
        txc->statfs_delta.allocated() += prealloc_pos->length;
        extents.push_back(*prealloc_pos);
        ++prealloc_pos;
+       if (prealloc_pos != prealloc.end()) {
+         prealloc_pos_length = prealloc_pos->length;
+       }
       } else {
        extents.emplace_back(prealloc_pos->offset, left);
        prealloc_pos->offset += left;
@@ -14192,7 +14199,7 @@ int BlueStore::_do_alloc_write(
 
     // queue io
     if (!g_conf()->bluestore_debug_omit_block_device_write) {
-      if (l->length() < prefer_deferred_size.load()) {
+      if (deferred_region_small && l->length() < prefer_deferred_size.load()) {
        dout(20) << __func__ << " deferring 0x" << std::hex
                 << l->length() << std::dec << " write via deferred" << dendl;
        bluestore_deferred_op_t *op = _get_deferred_op(txc, l->length());