]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Minor cleanup
authortridao <daominhtri0503@gmail.com>
Sat, 8 Jul 2023 14:54:20 +0000 (11:54 -0300)
committertridao <daominhtri0503@gmail.com>
Mon, 17 Jul 2023 02:16:44 +0000 (23:16 -0300)
Signed-off-by: Tri Dao <daominhtri0503@gmail.com>
src/test/objectstore/Fragmentation_simulator.cc
src/test/objectstore/ObjectStoreImitator.cc
src/test/objectstore/ObjectStoreImitator.h

index d93ca86204c7957b11708edb8fdb60902a4e33ef..cbf29ccabbedb8e2394db340e1ffc8c8bb947647 100644 (file)
@@ -7,6 +7,7 @@
 #include "common/ceph_argparse.h"
 #include "common/common_init.h"
 #include "common/hobject.h"
+#include "global/global_context.h"
 #include "global/global_init.h"
 #include "include/buffer_fwd.h"
 #include "os/ObjectStore.h"
@@ -34,8 +35,6 @@ static bufferlist make_bl(size_t len, char c) {
 
 class FragmentationSimulator : public ::testing::TestWithParam<std::string> {
 public:
-  static boost::intrusive_ptr<CephContext> cct;
-
   struct WorkloadGenerator {
     virtual int generate_txns(ObjectStore::CollectionHandle &ch,
                               ObjectStoreImitator *os) = 0;
@@ -51,12 +50,15 @@ public:
   void init(const std::string &alloc_type, uint64_t size,
             uint64_t min_alloc_size = 4096);
 
-  static void TearDownTestSuite() { cct.reset(); }
+  static void TearDownTestSuite() {}
   static void SetUpTestSuite() {}
   void TearDown() final {}
 
   FragmentationSimulator() = default;
-  ~FragmentationSimulator() = default;
+  ~FragmentationSimulator() {
+    if (os != nullptr)
+      delete os;
+  }
 
 private:
   ObjectStoreImitator *os;
@@ -158,6 +160,7 @@ struct SimpleCWGenerator : public FragmentationSimulator::WorkloadGenerator {
 
     os->queue_transactions(ch, tls);
     os->verify_objects(ch);
+    tls.clear();
     return 0;
   }
 };
@@ -231,11 +234,14 @@ struct RandomCWGenerator : public FragmentationSimulator::WorkloadGenerator {
       os->read(ch, obj2, offset, size, dummy);
     }
 
+    tls.clear();
     return 0;
   }
 };
 
-// Testing the Imitator with multiple threads
+// Testing the Imitator with multiple threads. We're mainly testing for
+// Collection correctness, as only one thread can act on an object at once in
+// BlueStore
 struct MultiThreadedCWGenerator
     : public FragmentationSimulator::WorkloadGenerator {
   std::string name() override { return "MultiThreadedCW"; }
@@ -312,16 +318,12 @@ TEST_P(FragmentationSimulator, MultiThreadedCWGenerator) {
 INSTANTIATE_TEST_SUITE_P(Allocator, FragmentationSimulator,
                          ::testing::Values("stupid", "bitmap", "avl", "btree"));
 
-boost::intrusive_ptr<CephContext> FragmentationSimulator::cct;
-
 int main(int argc, char **argv) {
   auto args = argv_to_vec(argc, argv);
-  FragmentationSimulator::cct =
+  auto cct =
       global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
                   CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
-  common_init_finish(FragmentationSimulator::cct->get());
-
-  FragmentationSimulator::cct->_conf->bluestore_clone_cow = false;
+  common_init_finish(g_ceph_context);
 
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
index e366a7b7dc23ce27fe73c0d7b1973b0cb098b5ce..149a1aee68f108ea1530dd89b0fc2ff229a95ceb 100644 (file)
@@ -1041,7 +1041,6 @@ void ObjectStoreImitator::_do_remove_collection(CollectionRef *c) {
 int ObjectStoreImitator::_create_collection(const coll_t &cid, unsigned bits,
                                             CollectionRef *c) {
   int r;
-  bufferlist bl;
 
   {
     std::unique_lock l(coll_lock);
@@ -1057,7 +1056,6 @@ int ObjectStoreImitator::_create_collection(const coll_t &cid, unsigned bits,
     new_coll_map.erase(p);
   }
 
-  encode((*c)->cnode, bl);
   r = 0;
 
 out:
index a92f07e7a8e57e209f949a8b3500148b14c95004..2e68658cb8b90e9932dd6090d6472e8d025eec94 100644 (file)
@@ -32,7 +32,7 @@ private:
   class Collection;
   typedef boost::intrusive_ptr<Collection> CollectionRef;
 
-  struct Object : public RefCountedObject {
+  struct Object : public RefCountedObjectSafe {
     Collection *c;
     ghobject_t oid;
     bool exists;
@@ -114,7 +114,7 @@ private:
       if (!create)
         return nullptr;
 
-      return objects[oid] = new Object(this, oid);
+      return objects[oid] = ceph::make_ref<Object>(this, oid);
     }
 
     bool flush_commit(Context *c) override { return false; }