mirror of
https://github.com/ceph/ceph
synced 2024-12-30 07:23:11 +00:00
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 <josh.durgin@dreamhost.com>
This commit is contained in:
parent
ec6530df4a
commit
f03e770f9b
@ -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<TestOp*>(arg);
|
||||
op->finish();
|
||||
op->finish(NULL);
|
||||
}
|
||||
|
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user