From f03e770f9bb99a0043a6b5bd1fad7aa14b3dc4fb Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Thu, 29 Dec 2011 18:30:57 -0800 Subject: [PATCH] RadosModel: allow TestOps to pass data to their finish methods This will allow nested writes to keep track of which write actually completed. Also remove finish() and _finish() from TestOp subclasses that had the same implementation as the superclass. Signed-off-by: Josh Durgin --- src/test/osd/RadosModel.cc | 6 ++-- src/test/osd/RadosModel.h | 60 ++++++++++++++++---------------------- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/src/test/osd/RadosModel.cc b/src/test/osd/RadosModel.cc index 664d336c60c..4665a352ce9 100644 --- a/src/test/osd/RadosModel.cc +++ b/src/test/osd/RadosModel.cc @@ -15,13 +15,13 @@ void TestOp::begin() _begin(); } -void TestOp::finish() +void TestOp::finish(TestOp::CallbackInfo *info) { - _finish(); + _finish(info); //if (stat && finished()) stat->end(this); } void callback(librados::completion_t cb, void *arg) { TestOp *op = static_cast(arg); - op->finish(); + op->finish(NULL); } diff --git a/src/test/osd/RadosModel.h b/src/test/osd/RadosModel.h index 3eba3dbd06d..0be27250fe0 100644 --- a/src/test/osd/RadosModel.h +++ b/src/test/osd/RadosModel.h @@ -50,8 +50,29 @@ public: virtual ~TestOp(); + /** + * This struct holds data to be passed by a callback + * to a TestOp::finish method. + */ + struct CallbackInfo { + uint64_t id; + CallbackInfo(uint64_t id) : id(id) {} + virtual ~CallbackInfo() {}; + }; + virtual void _begin() = 0; - virtual void _finish() = 0; + + /** + * Called when the operation completes. + * This should be overridden by asynchronous operations. + * + * @param info information stored by a callback, or NULL - + * useful for multi-operation TestOps + */ + virtual void _finish(CallbackInfo *info) + { + return; + } virtual string getType() = 0; virtual bool finished() { @@ -59,7 +80,7 @@ public: } void begin(); - void finish(); + void finish(CallbackInfo *info); }; class TestOpGenerator { @@ -322,7 +343,7 @@ public: } } - void _finish() + void _finish(CallbackInfo *info) { context->state_lock.Lock(); assert(!done); @@ -415,17 +436,6 @@ public: context->oid_in_use.erase(oid); context->oid_not_in_use.insert(oid); context->state_lock.Unlock(); - finish(); - } - - void _finish() - { - return; - } - - bool finished() - { - return true; } string getType() @@ -476,7 +486,7 @@ public: } } - void _finish() + void _finish(CallbackInfo *info) { context->state_lock.Lock(); assert(!done); @@ -537,13 +547,6 @@ public: context->state_lock.Lock(); context->add_snap(snap); context->state_lock.Unlock(); - - finish(); - } - - void _finish() - { - return; } string getType() @@ -570,12 +573,6 @@ public: context->state_lock.Unlock(); assert(!context->io_ctx.selfmanaged_snap_remove(snap)); - finish(); - } - - void _finish() - { - return; } string getType() @@ -621,15 +618,8 @@ public: cerr << "r is " << r << std::endl; assert(0); } - finish(); } - void _finish() - { - return; - } - - string getType() { return "RollBackOp";