From: Igor Fedotov Date: Fri, 24 Jun 2016 13:42:19 +0000 (+0300) Subject: os/bluestore: move add_unused call after csum initialization as it should depend... X-Git-Tag: v11.0.0~30^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b159dd770c184d3b51ba4e93c99e61be6f306eef;p=ceph.git os/bluestore: move add_unused call after csum initialization as it should depend on chunk size. Signed-off-by: Igor Fedotov --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 3fee4fca06de..58383596a7bf 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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( diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 0ce5bf54e9dc..f65024f7e86c 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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 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)); } };