From eebc9ec2dd841946b7dad10b1aae721b97316d4d Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Fri, 30 Mar 2012 15:32:12 +0100 Subject: [PATCH] test: test_workload_gen: Add callback for collection destruction. When we remove a collection, we must cleanup after the coll_entry_t we once had on the available collections set. For some reason, we weren't doing this. This commit adds a new callback, which inherits from the 'OnReadable' callback on the WorkloadGenerator class, that will be responsible for deleting the coll_entry_t once we know the collection transaction destroying the collection has finished. --- .../test_workload_gen/workload_generator.cc | 11 ++++------- .../test_workload_gen/workload_generator.h | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/test/test_workload_gen/workload_generator.cc b/src/test/test_workload_gen/workload_generator.cc index 9009f15625a3f..a5ffcf909f84f 100644 --- a/src/test/test_workload_gen/workload_generator.cc +++ b/src/test/test_workload_gen/workload_generator.cc @@ -79,11 +79,6 @@ void WorkloadGenerator::init_args(vector args) { usage(NULL); exit(0); } - -// else if (ceph_argparse_binary_flag(args, i, &allow_coll_dest, NULL, -// "--allow-coll-destruction", (char*) NULL)) { -// m_allow_coll_destruction = (allow_coll_dest ? true : false); -// } } } @@ -286,8 +281,10 @@ void WorkloadGenerator::run() { bool destroy_collection = should_destroy_collection(); coll_entry_t *entry = get_rnd_coll_entry(destroy_collection); + Context *c; if (destroy_collection) { do_destroy_collection(t, entry); + c = new C_WorkloadGeneratorOnDestroyed(this, t, entry); } else { int obj_nr = get_random_object_nr(entry->id); hobject_t obj = get_object_by_nr(obj_nr); @@ -296,10 +293,10 @@ void WorkloadGenerator::run() { do_setattr_object(t, entry->coll, obj); do_setattr_collection(t, entry->coll); do_append_log(t, entry->coll); + c = new C_WorkloadGeneratorOnReadable(this, t); } - m_store->queue_transaction(&(entry->osr), t, - new C_WorkloadGeneratorOnReadable(this, t)); + m_store->queue_transaction(&(entry->osr), t, c); m_in_flight++; diff --git a/src/test/test_workload_gen/workload_generator.h b/src/test/test_workload_gen/workload_generator.h index 21696e32f3470..d88e3094367fb 100644 --- a/src/test/test_workload_gen/workload_generator.h +++ b/src/test/test_workload_gen/workload_generator.h @@ -132,7 +132,7 @@ public: } void finish(int r) { - dout(0) << "Got one back!" << dendl; +// dout(0) << "Got one back!" << dendl; Mutex::Locker locker(m_state->m_lock); m_state->m_in_flight--; m_state->m_nr_runs++; @@ -142,6 +142,23 @@ public: } }; + class C_WorkloadGeneratorOnDestroyed: public C_WorkloadGeneratorOnReadable { +// WorkloadGenerator *m_state; +// ObjectStore::Transaction *m_tx; + coll_entry_t *m_entry; + + public: + C_WorkloadGeneratorOnDestroyed(WorkloadGenerator *state, + ObjectStore::Transaction *t, coll_entry_t *entry) : + C_WorkloadGeneratorOnReadable(state, t), m_entry(entry) {} + + void finish(int r) { + C_WorkloadGeneratorOnReadable::finish(r); + dout(0) << "Destroyed collection " << m_entry->coll.to_str() << dendl; + delete m_entry; + } + }; + void run(void); void print_results(void); }; -- 2.39.5