]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: Added tests for chunk_sizes for big-writes-deferred
authorAdam Kupczyk <akupczyk@redhat.com>
Fri, 3 Apr 2020 09:43:18 +0000 (11:43 +0200)
committerIgor Fedotov <ifedotov@suse.com>
Fri, 3 Apr 2020 11:03:20 +0000 (14:03 +0300)
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
src/test/objectstore/store_test.cc
src/test/objectstore/store_test_fixture.cc
src/test/objectstore/store_test_fixture.h

index 7dd561f719ee0f870eb396fd24679832b58a6768..9226ce302e5765fb798e6b97098fc9305e95e1bc 100644 (file)
@@ -7109,6 +7109,105 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
   }
 }
 
+
+TEST_P(StoreTestSpecificAUSize, DeferredDifferentChunks) {
+
+  if (string(GetParam()) != "bluestore")
+    return;
+
+  size_t alloc_size = 4096;
+  size_t large_object_size = 1 * 1024 * 1024;
+  // this will enable continuous allocations
+  SetVal(g_conf(), "bluestore_allocator", "avl");
+  StartDeferred(alloc_size);
+  SetVal(g_conf(), "bluestore_max_blob_size", "131072");
+  SetVal(g_conf(), "bluestore_prefer_deferred_size", "65536");
+  g_conf().apply_changes(nullptr);
+
+  int r;
+  coll_t cid;
+  const PerfCounters* logger = store->get_perf_counters();
+  size_t exp_bluestore_write_big = 0;
+  size_t exp_bluestore_write_big_deferred = 0;
+
+  ObjectStore::CollectionHandle ch = store->create_new_collection(cid);
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    r = queue_transaction(store, ch, std::move(t));
+    ASSERT_EQ(r, 0);
+  }
+  for (size_t expected_write_size = 1024; expected_write_size <= 65536; expected_write_size *= 2) {
+    //create object with hint
+    ghobject_t hoid(hobject_t("test-"+to_string(expected_write_size), "", CEPH_NOSNAP, 0, -1, ""));
+    {
+      ObjectStore::Transaction t;
+      t.touch(cid, hoid);
+      t.set_alloc_hint(cid, hoid, large_object_size, expected_write_size,
+                      CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_READ |
+                      CEPH_OSD_ALLOC_HINT_FLAG_APPEND_ONLY);
+      r = queue_transaction(store, ch, std::move(t));
+      ASSERT_EQ(r, 0);
+    }
+
+    //fill object
+    {
+      ObjectStore::Transaction t;
+      bufferlist bl;
+      bl.append(std::string(large_object_size, 'h'));
+      t.write(cid, hoid, 0, bl.length(), bl,
+             CEPH_OSD_OP_FLAG_FADVISE_NOCACHE);
+      r = queue_transaction(store, ch, std::move(t));
+      ++exp_bluestore_write_big;
+      ASSERT_EQ(r, 0);
+    }
+    ASSERT_EQ(logger->get(l_bluestore_write_big), exp_bluestore_write_big);
+    ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), exp_bluestore_write_big_deferred);
+
+    // check whether write will properly use deferred
+    {
+      ObjectStore::Transaction t;
+      bufferlist bl;
+      bl.append(std::string(alloc_size + 2, 'z'));
+      t.write(cid, hoid, large_object_size - 2 * alloc_size - 1, bl.length(), bl,
+             CEPH_OSD_OP_FLAG_FADVISE_NOCACHE);
+      r = queue_transaction(store, ch, std::move(t));
+      ++exp_bluestore_write_big;
+      ++exp_bluestore_write_big_deferred;
+      ASSERT_EQ(r, 0);
+    }
+    ASSERT_EQ(logger->get(l_bluestore_write_big), exp_bluestore_write_big);
+    ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), exp_bluestore_write_big_deferred);
+  }
+  ch.reset(nullptr);
+  CloseAndReopen();
+  ch = store->open_collection(cid);
+  // check values
+  for (size_t expected_write_size = 1024; expected_write_size <= 65536; expected_write_size *= 2) {
+    ghobject_t hoid(hobject_t("test-"+to_string(expected_write_size), "", CEPH_NOSNAP, 0, -1, ""));
+    {
+      bufferlist bl, expected;
+      r = store->read(ch, hoid, 0, large_object_size, bl);
+      ASSERT_EQ(r, large_object_size);
+      expected.append(string(large_object_size - 2 * alloc_size - 1, 'h'));
+      expected.append(string(alloc_size + 2, 'z'));
+      expected.append(string(alloc_size - 1, 'h'));
+      ASSERT_TRUE(bl_eq(expected, bl));
+    }
+  }
+  {
+    ObjectStore::Transaction t;
+    for (size_t expected_write_size = 1024; expected_write_size <= 65536; expected_write_size *= 2) {
+      ghobject_t hoid(hobject_t("test-"+to_string(expected_write_size), "", CEPH_NOSNAP, 0, -1, ""));
+      t.remove(cid, hoid);
+    }
+    t.remove_collection(cid);
+    cerr << "Cleaning" << std::endl;
+    r = queue_transaction(store, ch, std::move(t));
+    ASSERT_EQ(r, 0);
+  }
+}
+
 TEST_P(StoreTestSpecificAUSize, BlobReuseOnOverwriteReverse) {
 
   if (string(GetParam()) != "bluestore")
index 33d4618a31b007e558aeb46b6650abdadd246a03..6b7a652f8fc66f9ca61e55c11a8ff0aa8eba5c59 100644 (file)
@@ -101,3 +101,29 @@ void StoreTestFixture::PopSettings(size_t pos)
     conf->apply_changes(NULL);
   }
 }
+
+void StoreTestFixture::CloseAndReopen() {
+  ceph_assert(store != nullptr);
+  g_conf()._clear_safe_to_start_threads();
+  int r = store->umount();
+  EXPECT_EQ(0, r);
+  ch.reset(nullptr);
+  store.reset(nullptr);
+  store.reset(ObjectStore::create(g_ceph_context,
+                                  type,
+                                  data_dir,
+                                  string("store_test_temp_journal")));
+  if (!store) {
+    cerr << __func__ << ": objectstore type " << type << " failed to reopen!" << std::endl;
+  }
+  ASSERT_TRUE(store);
+#if defined(WITH_BLUESTORE)
+  if (type == "bluestore") {
+    BlueStore *s = static_cast<BlueStore*>(store.get());
+    // better test coverage!
+    s->set_cache_shards(5);
+  }
+#endif
+  ASSERT_EQ(0, store->mount());
+  g_conf().set_safe_to_start_threads();
+}
index d816dbdf49de7a71783c96d5670c0363e65e10c2..f3baa66d9bdf9ae997ef38a1f79aa6ebff77b41f 100644 (file)
@@ -39,4 +39,5 @@ public:
     return SettingsBookmark(*this, saved_settings.size());
   }
   void PopSettings(size_t);
+  void CloseAndReopen();
 };