From e7446ef2fd9053019a8f5dc9eb76001592a040fb Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Tue, 7 Jun 2016 16:34:32 +0300 Subject: [PATCH] os/BlueStore: Fixes improper blob length assignment when creating a new blob for large writes Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueStore.cc | 14 +++++++------- src/test/objectstore/store_test.cc | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 637a12344961a..27f163990bd05 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -5766,18 +5766,18 @@ void BlueStore::_do_write_big( while (length > 0) { int64_t blob; bluestore_blob_t *b = o->onode.add_blob(&blob); - b->length = MIN(max_blob_len, length); + auto l = b->length = MIN(max_blob_len, length); bufferlist t; - blp.copy(b->length, t); + blp.copy(l, t); wctx->write(b, 0, t); - o->onode.punch_hole(offset, length, &wctx->lex_old); - o->onode.extent_map[offset] = bluestore_lextent_t(blob, 0, length, 0); - b->ref_map.get(0, length); + o->onode.punch_hole(offset, l, &wctx->lex_old); + o->onode.extent_map[offset] = bluestore_lextent_t(blob, 0, l, 0); + b->ref_map.get(0, l); dout(20) << __func__ << " lex 0x" << std::hex << offset << std::dec << ": " << o->onode.extent_map[offset] << dendl; dout(20) << __func__ << " blob " << *b << dendl; - offset += b->length; - length -= b->length; + offset += l; + length -= l; } } diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 8666af71f1c5e..cf4938b6ff68b 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -838,6 +838,31 @@ TEST_P(StoreTest, CompressionTest) { ASSERT_TRUE(newdata.contents_equal(expected)); } } + { + ObjectStore::Transaction t; + t.remove(cid, hoid); + cerr << "Cleaning object" << std::endl; + r = apply_transaction(store, &osr, std::move(t)); + ASSERT_EQ(r, 0); + } + { + g_conf->set_val("bluestore_compression_min_blob_size", "262144"); + g_ceph_context->_conf->apply_changes(NULL); + data.resize(0x10000*6); + + for(size_t i = 0;i < data.size(); i++) + data[i] = i / 256; + ObjectStore::Transaction t; + bufferlist bl, newdata; + bl.append(data); + t.write(cid, hoid, 0, bl.length(), bl); + cerr << "CompressibleData large blob" << std::endl; + r = apply_transaction(store, &osr, std::move(t)); + ASSERT_EQ(r, 0); + EXPECT_EQ(store->umount(), 0); + EXPECT_EQ(store->mount(), 0); + } + { ObjectStore::Transaction t; t.remove(cid, hoid); -- 2.39.5