]> git.apps.os.sepia.ceph.com Git - ceph-ci.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)
committerIgor Fedotov <ifedotov@suse.com>
Tue, 10 Aug 2021 11:34:17 +0000 (14:34 +0300)
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>
src/os/bluestore/BlueStore.cc

index fbc448e32256f63e1b0208045859f20934584a67..6d6f7210156441318b3ebc294a4c8f892b82bf60 100644 (file)
@@ -14199,6 +14199,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();
@@ -14261,14 +14263,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;
@@ -14314,7 +14321,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());