]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/BlueStore: Fixes improper blob length assignment when creating a new blob for... 9549/head
authorIgor Fedotov <ifedotov@mirantis.com>
Tue, 7 Jun 2016 13:34:32 +0000 (16:34 +0300)
committerIgor Fedotov <ifedotov@mirantis.com>
Tue, 7 Jun 2016 13:37:04 +0000 (16:37 +0300)
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
src/os/bluestore/BlueStore.cc
src/test/objectstore/store_test.cc

index 637a12344961ae94cc95b451956169758249563e..27f163990bd05e80281e9f0f12f4993ddd98ca66 100644 (file)
@@ -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;
   }
 }
 
index 8666af71f1c5e3d6f6a916c788f47e97f5308fbe..cf4938b6ff68b588963f8b424f174cec03d2e02f 100644 (file)
@@ -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);