From: tridao Date: Sat, 8 Jul 2023 14:54:20 +0000 (-0300) Subject: Minor cleanup X-Git-Tag: v19.0.0~773^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9e95ffb9249295e7508719644de14d74b22a3462;p=ceph.git Minor cleanup Signed-off-by: Tri Dao --- diff --git a/src/test/objectstore/Fragmentation_simulator.cc b/src/test/objectstore/Fragmentation_simulator.cc index d93ca86204c7..cbf29ccabbed 100644 --- a/src/test/objectstore/Fragmentation_simulator.cc +++ b/src/test/objectstore/Fragmentation_simulator.cc @@ -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 { public: - static boost::intrusive_ptr 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 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(); diff --git a/src/test/objectstore/ObjectStoreImitator.cc b/src/test/objectstore/ObjectStoreImitator.cc index e366a7b7dc23..149a1aee68f1 100644 --- a/src/test/objectstore/ObjectStoreImitator.cc +++ b/src/test/objectstore/ObjectStoreImitator.cc @@ -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: diff --git a/src/test/objectstore/ObjectStoreImitator.h b/src/test/objectstore/ObjectStoreImitator.h index a92f07e7a8e5..2e68658cb8b9 100644 --- a/src/test/objectstore/ObjectStoreImitator.h +++ b/src/test/objectstore/ObjectStoreImitator.h @@ -32,7 +32,7 @@ private: class Collection; typedef boost::intrusive_ptr 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(this, oid); } bool flush_commit(Context *c) override { return false; }