diff options
author | Samuel Just <sam.just@inktank.com> | 2013-10-31 00:12:19 +0100 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-11-02 00:00:12 +0100 |
commit | ca4c166b7e2ef33601016035cc8aefc85faf66e1 (patch) | |
tree | 3d0b14e1af0b62653d455776850aae13bde66390 | |
parent | test/rados/list.cc: we might get some objects more than once (diff) | |
download | ceph-ca4c166b7e2ef33601016035cc8aefc85faf66e1.tar.xz ceph-ca4c166b7e2ef33601016035cc8aefc85faf66e1.zip |
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>
-rw-r--r-- | src/test/osd/RadosModel.h | 15 | ||||
-rw-r--r-- | src/test/osd/TestRados.cc | 8 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/test/osd/RadosModel.h b/src/test/osd/RadosModel.h index ac2f336f110..902d4b970c3 100644 --- a/src/test/osd/RadosModel.h +++ b/src/test/osd/RadosModel.h @@ -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]; diff --git a/src/test/osd/TestRados.cc b/src/test/osd/TestRados.cc index 842f9d2bca3..0c1d55c7777 100644 --- a/src/test/osd/TestRados.cc +++ b/src/test/osd/TestRados.cc @@ -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: |