]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
RadosModel: assert exists on subsequent writes
authorSamuel Just <sjust@redhat.com>
Thu, 21 May 2015 18:36:42 +0000 (11:36 -0700)
committerAbhishek Lekshmanan <abhishek.lekshmanan@ril.com>
Mon, 8 Jun 2015 17:49:34 +0000 (23:19 +0530)
Signed-off-by: Samuel Just <sjust@redhat.com>
(cherry picked from commit 121aa3bc612b86281535ac3bcfe98bc99bc99ace)

src/test/osd/RadosModel.h
src/test/osd/TestRados.cc

index f9c0f9bc9e4e5b2c72dc2ee904d0caa4a8ff195a..9192c5dd19d2b18fe36d1ed68a9bb42480bef43c 100644 (file)
@@ -47,6 +47,7 @@ typename T::iterator rand_choose(T &cont) {
 enum TestOpType {
   TEST_OP_READ,
   TEST_OP_WRITE,
+  TEST_OP_WRITE_EXCL,
   TEST_OP_DELETE,
   TEST_OP_SNAP_CREATE,
   TEST_OP_SNAP_REMOVE,
@@ -61,7 +62,8 @@ enum TestOpType {
   TEST_OP_CACHE_FLUSH,
   TEST_OP_CACHE_TRY_FLUSH,
   TEST_OP_CACHE_EVICT,
-  TEST_OP_APPEND
+  TEST_OP_APPEND,
+  TEST_OP_APPEND_EXCL
 };
 
 class TestWatchContext : public librados::WatchCtx2 {
@@ -716,14 +718,17 @@ public:
   bufferlist rbuffer;
 
   bool do_append;
+  bool do_excl;
 
   WriteOp(int n,
          RadosTestContext *context,
          const string &oid,
          bool do_append,
+         bool do_excl,
          TestOpStat *stat = 0)
     : TestOp(n, context, stat),
-      oid(oid), waiting_on(0), last_acked_tid(0), do_append(do_append)
+      oid(oid), waiting_on(0), last_acked_tid(0), do_append(do_append),
+      do_excl(do_excl)
   {}
                
   void _begin()
@@ -795,6 +800,8 @@ public:
       } else {
        op.write(i->first, to_write);
       }
+      if (do_excl && tid == 1)
+       op.assert_exists();
       context->io_ctx.aio_operate(
        context->prefix+oid, completion,
        &op);
index 4d8b45cc486a6593ec53c2a53f9fd28225aefc20..e8eb0db9df05332258051d5e7c0a31f0c25a7d5e 100644 (file)
@@ -55,9 +55,9 @@ public:
       cout << m_op << ": write initial oid " << oid.str() << std::endl;
       context.oid_not_flushing.insert(oid.str());
       if (m_ec_pool) {
-       return new WriteOp(m_op, &context, oid.str(), true);
+       return new WriteOp(m_op, &context, oid.str(), true, true);
       } else {
-       return new WriteOp(m_op, &context, oid.str(), false);
+       return new WriteOp(m_op, &context, oid.str(), false, true);
       }
     } else if (m_op >= m_ops) {
       return NULL;
@@ -105,7 +105,14 @@ private:
       oid = *(rand_choose(context.oid_not_in_use));
       cout << m_op << ": " << "write oid " << oid << " current snap is "
           << context.current_snap << std::endl;
-      return new WriteOp(m_op, &context, oid, false, m_stats);
+      return new WriteOp(m_op, &context, oid, false, false, m_stats);
+
+    case TEST_OP_WRITE_EXCL:
+      oid = *(rand_choose(context.oid_not_in_use));
+      cout << m_op << ": " << "write (excl) oid "
+          << oid << " current snap is "
+          << context.current_snap << std::endl;
+      return new WriteOp(m_op, &context, oid, false, true, m_stats);
 
     case TEST_OP_DELETE:
       oid = *(rand_choose(context.oid_not_in_use));
@@ -206,7 +213,13 @@ private:
       oid = *(rand_choose(context.oid_not_in_use));
       cout << "append oid " << oid << " current snap is "
           << context.current_snap << std::endl;
-      return new WriteOp(m_op, &context, oid, true, m_stats);
+      return new WriteOp(m_op, &context, oid, true, false, m_stats);
+
+    case TEST_OP_APPEND_EXCL:
+      oid = *(rand_choose(context.oid_not_in_use));
+      cout << "append oid (excl) " << oid << " current snap is "
+          << context.current_snap << std::endl;
+      return new WriteOp(m_op, &context, oid, true, true, m_stats);
 
     default:
       cerr << m_op << ": Invalid op type " << type << std::endl;
@@ -244,6 +257,7 @@ int main(int argc, char **argv)
   } op_types[] = {
     { TEST_OP_READ, "read", true },
     { TEST_OP_WRITE, "write", false },
+    { TEST_OP_WRITE_EXCL, "write_excl", false },
     { TEST_OP_DELETE, "delete", true },
     { TEST_OP_SNAP_CREATE, "snap_create", true },
     { TEST_OP_SNAP_REMOVE, "snap_remove", true },
@@ -259,6 +273,7 @@ int main(int argc, char **argv)
     { TEST_OP_CACHE_TRY_FLUSH, "cache_try_flush", true },
     { TEST_OP_CACHE_EVICT, "cache_evict", true },
     { TEST_OP_APPEND, "append", true },
+    { TEST_OP_APPEND_EXCL, "append_excl", true },
     { TEST_OP_READ /* grr */, NULL },
   };