enum TestOpType {
TEST_OP_READ,
TEST_OP_WRITE,
+ TEST_OP_WRITE_EXCL,
TEST_OP_DELETE,
TEST_OP_SNAP_CREATE,
TEST_OP_SNAP_REMOVE,
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 {
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()
} 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);
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;
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));
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;
} 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 },
{ 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 },
};