]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: add an ability to reproduce issue #21040 and verify if
authorIgor Fedotov <ifedotov@suse.com>
Mon, 8 Jan 2018 15:06:01 +0000 (18:06 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Wed, 21 Feb 2018 15:16:50 +0000 (18:16 +0300)
fsck repair fixes it.

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/common/legacy_config_opts.h
src/common/options.cc
src/os/bluestore/BlueStore.cc
src/test/objectstore/store_test.cc

index 298721ef83bdec318dfcd9bcf3f5ccdd157525c7..b76042db94a0a4037c1f5c79748046adbb4e07a4 100644 (file)
@@ -1073,6 +1073,7 @@ OPTION(bluestore_debug_omit_kv_commit, OPT_BOOL)
 OPTION(bluestore_debug_permit_any_bdev_label, OPT_BOOL)
 OPTION(bluestore_shard_finishers, OPT_BOOL)
 OPTION(bluestore_debug_random_read_err, OPT_DOUBLE)
+OPTION(bluestore_debug_inject_bug21040, OPT_BOOL)
 
 OPTION(kstore_max_ops, OPT_U64)
 OPTION(kstore_max_bytes, OPT_U64)
index 628fc57269f6b1aca5ae8695fddae567683cfa26..7f469ffd65cb6efaa072cf48d753a6a3e68c2f2e 100644 (file)
@@ -3926,6 +3926,9 @@ std::vector<Option> get_global_options() {
     .set_default(0)
     .set_description(""),
 
+    Option("bluestore_debug_inject_bug21040", Option::TYPE_BOOL, Option::LEVEL_DEV)
+    .set_default(false)
+    .set_description(""),
     // -----------------------------------------
     // kstore
 
index 618ad3e45838ab680045dd2af73863e94476982c..a2c97e1394d9a3c2b3b8b7bd293f7a76c54fe787 100644 (file)
@@ -1990,6 +1990,8 @@ void BlueStore::ExtentMap::dup(BlueStore* b, TransContext* txc,
   uint64_t& length, uint64_t& dstoff) {
 
   auto cct = onode->c->store->cct;
+  bool inject_21040 =
+    cct->_conf->bluestore_debug_inject_bug21040;  
   vector<BlobRef> id_to_blob(oldo->extent_map.extent_map.size());
   for (auto& e : oldo->extent_map.extent_map) {
     e.blob->last_encoded_id = -1;
@@ -2019,10 +2021,13 @@ void BlueStore::ExtentMap::dup(BlueStore* b, TransContext* txc,
       // make sure it is shared
       if (!blob.is_shared()) {
         c->make_blob_shared(b->_assign_blobid(txc), e.blob);
-        if (!src_dirty) {
-          src_dirty = true; 
+       if (!inject_21040 && !src_dirty) {
+          src_dirty = true;
           dirty_range_begin = e.logical_offset;
-        }
+       } else if (inject_21040 &&
+                  dirty_range_begin == 0 && dirty_range_end == 0) {
+         dirty_range_begin = e.logical_offset;
+       }        
         assert(e.logical_end() > 0);
         // -1 to exclude next potential shard
         dirty_range_end = e.logical_end() - 1;
@@ -2072,7 +2077,8 @@ void BlueStore::ExtentMap::dup(BlueStore* b, TransContext* txc,
     dout(20) << __func__ << "  dst " << *ne << dendl;
     ++n;
   }
-  if (src_dirty) {
+  if ((!inject_21040 && src_dirty) ||
+       (inject_21040 && dirty_range_end > dirty_range_begin)) {
     oldo->extent_map.dirty_range(dirty_range_begin,
       dirty_range_end - dirty_range_begin);
     txc->write_onode(oldo);
@@ -11608,7 +11614,6 @@ int BlueStore::_do_clone_range(
   _dump_onode(newo);
 
   oldo->extent_map.dup(this, txc, c, oldo, newo, srcoff, length, dstoff);
-
   _dump_onode(oldo);
   _dump_onode(newo);
   return 0;
index 13ef8173bd7bedad440e36970d2cd0bb2333c74a..ffba370b06eb6c6e8e18ac031069e3a589c1ad81 100644 (file)
@@ -6937,6 +6937,7 @@ TEST_P(StoreTest, BluestoreRepairTest) {
   int r;
   const size_t repeats = 16;
   {
+    auto ch = store->create_new_collection(cid);
     cerr << "create collection + write" << std::endl;
     ObjectStore::Transaction t;
     t.create_collection(cid, 0);
@@ -7020,6 +7021,43 @@ TEST_P(StoreTest, BluestoreRepairTest) {
 
   ASSERT_EQ(bstore->fsck(true), 0);
 
+  // reproducing issues #21040 & 20983
+  g_ceph_context->_conf->set_val(
+    "bluestore_debug_inject_bug21040", "true");
+  g_ceph_context->_conf->apply_changes(NULL);
+  bstore->mount();
+
+  cerr << "repro bug #21040" << std::endl;
+  {
+    auto ch = store->open_collection(cid);
+    {
+      ObjectStore::Transaction t;
+      bl.append("0123456789012345");
+      t.write(cid, hoid3, offs_base, bl.length(), bl);
+      bl.clear();
+      bl.append('!');
+      t.write(cid, hoid3, 0, bl.length(), bl);
+
+      r = queue_transaction(store, ch, std::move(t));
+      ASSERT_EQ(r, 0);
+    }
+    {
+      ObjectStore::Transaction t;
+      t.clone(cid, hoid3, hoid3_cloned);
+      r = queue_transaction(store, ch, std::move(t));
+      ASSERT_EQ(r, 0);
+    }
+
+    bstore->umount();
+    ASSERT_EQ(bstore->fsck(false), 3);
+    ASSERT_LE(bstore->repair(false), 0);
+    ASSERT_EQ(bstore->fsck(false), 0);
+    g_ceph_context->_conf->set_val(
+      "bluestore_debug_inject_bug21040", "true");
+    g_ceph_context->_conf->apply_changes(NULL);
+  }
+
+
   cerr << "Completing" << std::endl;
   bstore->mount();
   g_ceph_context->_conf->set_val("bluestore_fsck_on_mount", "true");