From: Sage Weil Date: Fri, 4 Oct 2013 04:47:26 +0000 (-0700) Subject: ceph_test_rados: do not let rollback race with snap delete X-Git-Tag: v0.71~26^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F689%2Fhead;p=ceph.git ceph_test_rados: do not let rollback race with snap delete Note that the OSD behaves in a weird way when you rollback to a non- existent snap, so the test probably isn't the only party at fault here. Fixes (test half of): #6254 Backport: dumpling, cuttlefish Signed-off-by: Sage Weil --- diff --git a/src/test/osd/RadosModel.h b/src/test/osd/RadosModel.h index 322a591b409..aba6a531c6f 100644 --- a/src/test/osd/RadosModel.h +++ b/src/test/osd/RadosModel.h @@ -143,6 +143,7 @@ public: map > pool_obj_cont; set oid_in_use; set oid_not_in_use; + set snaps_in_use; int current_snap; string pool_name; librados::IoCtx io_ctx; @@ -1315,6 +1316,8 @@ public: } context->oid_in_use.insert(oid); context->oid_not_in_use.erase(oid); + context->snaps_in_use.insert(roll_back_to); + context->roll_back(oid, roll_back_to); uint64_t snap = context->snaps[roll_back_to]; @@ -1342,6 +1345,7 @@ public: context->update_object_version(oid, comp->get_version64()); context->oid_in_use.erase(oid); context->oid_not_in_use.insert(oid); + context->snaps_in_use.erase(roll_back_to); context->kick(); } diff --git a/src/test/osd/TestRados.cc b/src/test/osd/TestRados.cc index be919161579..7158f50a74a 100644 --- a/src/test/osd/TestRados.cc +++ b/src/test/osd/TestRados.cc @@ -120,13 +120,16 @@ private: } case TEST_OP_ROLLBACK: - if (context.snaps.empty()) { + if (context.snaps.size() <= context.snaps_in_use.size()) { return NULL; - } else { + } + while (true) { int snap = rand_choose(context.snaps)->first; + if (context.snaps_in_use.count(snap)) + continue; // in use; try again! 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); + return new RollbackOp(m_op, &context, oid, snap); } case TEST_OP_SETATTR: