]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: move add_unused call after csum initialization as it should depend...
authorIgor Fedotov <ifedotov@mirantis.com>
Fri, 24 Jun 2016 13:42:19 +0000 (16:42 +0300)
committerSage Weil <sage@redhat.com>
Mon, 27 Jun 2016 15:05:31 +0000 (08:05 -0700)
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 3fee4fca06de94fea9682927e04a9259acd46ef8..58383596a7bf1efe5fe329b072dd78d0419f8ab0 100644 (file)
@@ -5779,11 +5779,6 @@ void BlueStore::_do_write_small(
   uint64_t b_off = offset % alloc_len;
   b->bc.write(txc->seq, b_off, bl, wctx->buffered ? 0 : Buffer::FLAG_NOCACHE);
   _pad_zeros(&bl, &b_off, block_size);
-  uint64_t b_len = bl.length();
-  if (b_off)
-    b->blob.add_unused(0, b_off);
-  if (b_off + b_len < alloc_len)
-    b->blob.add_unused(b_off + b_len, alloc_len - (b_off + b_len));
   o->onode.punch_hole(offset, length, &wctx->lex_old);
   bluestore_lextent_t& lex = o->onode.extent_map[offset] =
     bluestore_lextent_t(b->id, offset % min_alloc_size, length);
@@ -5792,7 +5787,7 @@ void BlueStore::_do_write_small(
   dout(20) << __func__ << "  lex 0x" << std::hex << offset << std::dec
           << ": " << lex << dendl;
   dout(20) << __func__ << "  new " << b->id << ": " << *b << dendl;
-  wctx->write(b, alloc_len, b_off, bl);
+  wctx->write(b, alloc_len, b_off, bl, true);
   return;
 }
 
@@ -5818,7 +5813,7 @@ void BlueStore::_do_write_big(
     bufferlist t;
     blp.copy(l, t);
     b->bc.write(txc->seq, 0, t, wctx->buffered ? 0 : Buffer::FLAG_NOCACHE);
-    wctx->write(b, l, 0, t);
+    wctx->write(b, l, 0, t, false);
     o->onode.punch_hole(offset, l, &wctx->lex_old);
     o->onode.extent_map[offset] = bluestore_lextent_t(b->id, 0, l);
     b->blob.ref_map.get(0, l);
@@ -5938,6 +5933,14 @@ int BlueStore::_do_alloc_write(
       b->blob.init_csum(csum_type, csum_order, csum_length);
       b->blob.calc_csum(b_off, *l);
     }
+    if (wi.mark_unused) {
+      auto b_off = wi.b_off;
+      auto b_len = wi.bl.length();
+      if (b_off)
+        b->blob.add_unused(0, b_off);
+      if (b_off + b_len < wi.blob_length)
+        b->blob.add_unused(b_off + b_len, wi.blob_length - (b_off + b_len));
+    }
 
     // queue io
     b->blob.map_bl(
index 0ce5bf54e9dc4aabf441ccc9bf4e9e1e66689427..f65024f7e86ca63d0fe53f1c72d6a83a21105cd5 100644 (file)
@@ -1507,14 +1507,15 @@ private:
       uint64_t blob_length;
       uint64_t b_off;
       bufferlist bl;
+      bool mark_unused;
 
-      write_item(Blob *b, uint64_t blob_len, uint64_t o, bufferlist& bl)
-       : b(b), blob_length(blob_len), b_off(o), bl(bl) {}
+      write_item(Blob *b, uint64_t blob_len, uint64_t o, bufferlist& bl, bool _mark_unused)
+       : b(b), blob_length(blob_len), b_off(o), bl(bl), mark_unused(_mark_unused) {}
     };
     vector<write_item> writes;                 ///< blobs we're writing
 
-    void write(Blob *b, uint64_t blob_len, uint64_t o, bufferlist& bl) {
-      writes.emplace_back(write_item(b, blob_len, o, bl));
+    void write(Blob *b, uint64_t blob_len, uint64_t o, bufferlist& bl, bool _mark_unused) {
+      writes.emplace_back(write_item(b, blob_len, o, bl, _mark_unused));
     }
   };