test/osd/RadosModel.h: select and reserve roll_back_to atomically

Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Samuel Just 2013-10-30 16:12:19 -07:00 committed by Sage Weil
parent 99c5319c2c
commit ca4c166b7e
2 changed files with 15 additions and 8 deletions

View File

@ -1325,11 +1325,10 @@ public:
RollbackOp(int n,
RadosTestContext *context,
const string &_oid,
int snap,
TestOpStat *stat = 0)
: TestOp(n, context, stat),
oid(_oid),
roll_back_to(snap), done(false)
roll_back_to(-1), done(false)
{}
void _begin()
@ -1340,10 +1339,22 @@ public:
context->state_lock.Unlock();
return;
}
if (context->snaps.empty()) {
context->kick();
context->state_lock.Unlock();
done = true;
return;
}
context->oid_in_use.insert(oid);
context->oid_not_in_use.erase(oid);
roll_back_to = rand_choose(context->snaps)->first;
context->snaps_in_use.insert(roll_back_to);
cout << "rollback oid " << oid << " to " << roll_back_to << std::endl;
context->roll_back(oid, roll_back_to);
uint64_t snap = context->snaps[roll_back_to];

View File

@ -123,14 +123,10 @@ private:
}
case TEST_OP_ROLLBACK:
if (context.snaps.empty()) {
return NULL;
}
{
int snap = rand_choose(context.snaps)->first;
string oid = *(rand_choose(context.oid_not_in_use));
cout << "rollback oid " << oid << " to " << snap << std::endl;
return new RollbackOp(m_op, &context, oid, snap);
cout << "rollback oid " << oid << std::endl;
return new RollbackOp(m_op, &context, oid);
}
case TEST_OP_SETATTR: