]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: choose better csum_order in _do_alloc_write
authorSage Weil <sage@redhat.com>
Mon, 6 Jun 2016 17:55:57 +0000 (13:55 -0400)
committerSage Weil <sage@redhat.com>
Wed, 15 Jun 2016 19:25:29 +0000 (15:25 -0400)
Try to use the wctx hint, but set a floor based on the buffer length.

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

index 1c41b555bc38429d09307e955829d2eb230e116c..743bbfd93336b783ebcd1bc69c5927850e4c39a8 100644 (file)
@@ -22,6 +22,7 @@
 #include "BlueStore.h"
 #include "kv.h"
 #include "include/compat.h"
+#include "include/intarith.h"
 #include "include/stringify.h"
 #include "common/errno.h"
 #include "common/safe_io.h"
@@ -5918,9 +5919,10 @@ int BlueStore::_do_alloc_write(
     bufferlist *l = &wi.bl;
     uint64_t final_length = b->length;
     uint64_t csum_length = b->length;
-    size_t csum_order = wctx->csum_order;
+    unsigned csum_order;
     bufferlist compressed_bl;
     CompressorRef c;
+    bool compressed = false;
     if (wctx->compress &&
        b->length > min_alloc_size &&
        (c = compressor) != nullptr) {
@@ -5951,22 +5953,26 @@ int BlueStore::_do_alloc_write(
        l = &compressed_bl;
        final_length = newlen;
        csum_length = newlen;
+       csum_order = ctz(newlen);
        b->set_compressed(rawlen);
+       compressed = true;
       } else {
-       dout(20) << __func__ << hex << "  compressed 0x" << l->length() << " -> 0x"
-                << rawlen << " with " << chdr.type
+       dout(20) << __func__ << hex << "  compressed 0x" << l->length()
+                << " -> 0x" << rawlen << " with " << chdr.type
                 << ", leaving uncompressed"
                 << dec << dendl;
-       b->set_flag(bluestore_blob_t::FLAG_MUTABLE);
       }
-    } else {
+    }
+    if (!compressed) {
       b->set_flag(bluestore_blob_t::FLAG_MUTABLE);
-      if (l->length() != b->length &&
-         csum_order != block_size_order) {
+      if (l->length() != b->length) {
        // hrm, maybe we could do better here, but let's not bother.
-       dout(20) << __func__ << " downgrading csum_order from " << csum_order
-                << " to block_size_order " << block_size_order << dendl;
+       dout(20) << __func__ << " forcing csum_order to block_size_order "
+                << block_size_order << dendl;
        csum_order = block_size_order;
+      } else {
+       assert(b_off == 0);
+       csum_order = std::min(wctx->csum_order, ctz(l->length()));
       }
     }
     while (final_length > 0) {